Last active
November 11, 2022 01:36
-
-
Save nadyshalaby/0187acb3c4598ad4abef4bd4518ab2ab to your computer and use it in GitHub Desktop.
Docker Compose & Dockerfile to build any php application.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.9" | |
services: | |
backend: | |
build: | |
context: . | |
dockerfile: Dockerfile | |
container_name: app | |
restart: unless-stopped | |
tty: true | |
ports: | |
- "80:80" | |
- "433:443" | |
volumes: | |
- .:/var/www/html | |
depends_on: | |
- db | |
networks: | |
- lan | |
db: | |
image: mysql:8.0 | |
container_name: db | |
tty: true | |
restart: unless-stopped | |
command: --default-authentication-plugin=mysql_native_password | |
environment: | |
MYSQL_ROOT_PASSWORD: mismardev@1 | |
MYSQL_DATABASE: mismar_wms | |
ports: | |
- "3306:3306" | |
volumes: | |
- dbdata:/var/lib/mysql/ | |
networks: | |
- lan | |
adminer: | |
image: adminer | |
restart: unless-stopped | |
ports: | |
- 8080:8080 | |
depends_on: | |
- db | |
networks: | |
- lan | |
volumes: | |
dbdata: | |
networks: | |
lan: | |
driver: bridge | |
external: true # Optional for hosting purposes | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM php:8.1-apache | |
RUN apt-get update && apt-get install -y git \ | |
libpng-dev \ | |
zlib1g-dev \ | |
libwebp-dev \ | |
libjpeg62-turbo-dev \ | |
libpng-dev libxpm-dev \ | |
libfreetype6-dev | |
RUN docker-php-ext-configure gd \ | |
--with-webp \ | |
--with-jpeg \ | |
--with-xpm \ | |
--with-freetype | |
RUN docker-php-ext-install gd \ | |
gettext \ | |
mysqli \ | |
pdo pdo_mysql && docker-php-ext-enable pdo_mysql | |
RUN apt-get install -y \ | |
libzip-dev \ | |
zip \ | |
&& docker-php-ext-install zip | |
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer | |
RUN a2enmod rewrite | |
RUN service apache2 restart | |
USER root | |
ARG PUID=1000 | |
ENV PUID ${PUID} | |
ARG PGID=1000 | |
ENV PGID ${PGID} | |
RUN groupadd -g ${PGID} ubuntu && \ | |
useradd -l -u ${PUID} -g ubuntu -m ubuntu -G www-data && \ | |
usermod -p "*" ubuntu -s /bin/bash | |
USER ubuntu | |
ENV NVM_DIR /home/ubuntu/.nvm | |
ENV NODE_VERSION stable # or a specific version 14.19.1 | |
# Install nvm | |
RUN git clone https://github.com/creationix/nvm.git $NVM_DIR && \ | |
cd $NVM_DIR && \ | |
git checkout `git describe --abbrev=0 --tags` | |
# Install default version of Node.js | |
RUN . $NVM_DIR/nvm.sh && \ | |
nvm install $NODE_VERSION && \ | |
nvm alias default $NODE_VERSION && \ | |
nvm use default | |
# Add nvm.sh to .bashrc for startup... | |
RUN echo ". ${NVM_DIR}/nvm.sh" >> $HOME/.bashrc && \ | |
. $HOME/.bashrc | |
ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules | |
COPY . /var/www/html | |
WORKDIR /var/www/html | |
USER root | |
RUN chown -R ubuntu:ubuntu /var/www/html | |
RUN find . -type d -exec chmod 755 {} \; | |
RUN find . -type f -exec chmod 644 {} \; | |
RUN chmod -R g+s . | |
USER ubuntu |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment