Skip to content

Commit

Permalink
v1.1.0 (#6)
Browse files Browse the repository at this point in the history
* fix(mysql): add timezone IT to mysql

(cherry picked from commit 3032a0d)

* chore: move docker configurations into service folder in .docker; move docker-compose.yml in .docker folder

* upd: new .env template

* fix: align env variable in docker-compose & paths

* upd: add default taskfile

* upd: add support multi environment

* ref: move conf.d files into config

* upd: add multi php version

* fix: compatibility with docker-extension

* upd: add php8 configuration

* fix: rename executable file

* chore: update README.md

Co-authored-by: Kasui92 <Rododendro92>
  • Loading branch information
Kasui92 authored Jul 25, 2022
1 parent 3032a0d commit 20d0a0d
Show file tree
Hide file tree
Showing 19 changed files with 461 additions and 75 deletions.
12 changes: 12 additions & 0 deletions .docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: "3.8"

services:

mailhog:
build:
context: "services/mailhog"
image: "${PROJECT}_mailhog"
container_name: "${PROJECT}_mailhog"
#restart: always
ports:
- "${MAILHOG_PORT}:8025"
1 change: 1 addition & 0 deletions .docker/docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version: "3.8"
47 changes: 18 additions & 29 deletions docker-compose.yml → .docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,46 @@ services:

php:
build:
context: "./.docker/php"
context: "services/php"
dockerfile: "Dockerfile.${PHP_VERSION}"
args:
uid: "${UID}"
uid: "${PHP_UID}"
image: "${PROJECT}_php"
container_name: "${PROJECT}_php"
ports:
- '9000:9000'
volumes:
- ./.docker/php/conf.d:/usr/local/etc/php/conf.d:ro
- ./service:/var/www/html
- ./services/php/config/conf.d:/usr/local/etc/php/conf.d:ro
- ../service:/var/www/html
environment:
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}

nginx:
build:
context: .
dockerfile: .docker/nginx/Dockerfile
context: "services/nginx"
image: "${PROJECT}_nginx"
container_name: "${PROJECT}_nginx"
ports:
- "${NGINX_PORT}:80"
- "${SERVICE_PORT}:80"
- "${PMA_PORT}:8080"
volumes:
- ./service:/var/www/html
- ./.docker/nginx/conf.d:/etc/nginx/conf.d
- ./logs/nginx:/var/log/nginx
- phpmyadmindata:/var/www/phpmyadmin
- ../service:/var/www/html
- ./services/nginx/config/conf.d:/etc/nginx/conf.d
- ../logs/nginx:/var/log/nginx
- phpmyadmin-data:/var/www/phpmyadmin
depends_on:
- php

database:
build:
context: "./.docker/database"
context: "services/database"
image: "${PROJECT}_database"
container_name: "${PROJECT}_database"
#restart: // always;unless-stopped
ports:
- "${DB_PORT}:3306"
volumes:
- ./.docker/database/conf.d/my.cnf:/etc/mysql/conf.d/my.cnf
- databasedata:/var/lib/mysql
- ./services/database/config/conf.d/my.cnf:/etc/mysql/conf.d/my.cnf
- database-data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
Expand All @@ -54,24 +52,15 @@ services:

phpmyadmin:
build:
context: "./.docker/phpmyadmin"
context: "services/phpmyadmin"
image: "${PROJECT}_phpmyadmin"
container_name: "${PROJECT}_phpmyadmin"
volumes:
- phpmyadmindata:/var/www/html
- phpmyadmin-data:/var/www/html
environment:
PMA_HOST: database

mailhog:
build:
context: "./.docker/mailhog"
image: "${PROJECT}_mailhog"
container_name: "${PROJECT}_mailhog"
#restart: always
ports:
- "${MAILHOG_PORT}:8025"

# Volumes
volumes:
databasedata:
phpmyadmindata:
database-data:
phpmyadmin-data:
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
104 changes: 104 additions & 0 deletions .docker/services/php/Dockerfile.php73
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Create image based on the official PHP-FMP image
FROM php:7.3-fpm

# Arguments defined in docker-compose.yml
ARG uid

# Update the base libraries
RUN apt-get -y update --fix-missing && apt-get upgrade -y

# Install useful tools and install important libaries
RUN apt-get -y --no-install-recommends install --fix-missing \
git nano wget dialog \
apt-utils build-essential \
zip openssl curl \
libmcrypt4 \
libfreetype6 \
libjpeg62-turbo \
libpng16-16 \
libxpm4 \
libsqlite3-dev \
libsqlite3-0 \
default-mysql-client \
libmcrypt-dev \
zlib1g-dev \
libzip-dev \
libicu-dev \
libpng-dev \
libjpeg-dev \
libfreetype6-dev \
libxpm-dev \
libvpx-dev \
libonig-dev \
libcurl3-dev \
libcurl3-openssl-dev \
libmemcached-dev \
zlib1g-dev

# Other PHP5.6 Extensions
RUN echo "Installing PHP extensions" && \
docker-php-ext-install pdo_mysql && \
docker-php-ext-install pdo_sqlite && \
docker-php-ext-install mysqli && \
docker-php-ext-install curl && \
docker-php-ext-install tokenizer && \
docker-php-ext-install json && \
docker-php-ext-install zip && \
docker-php-ext-install mbstring && \
docker-php-ext-install gettext && \
docker-php-ext-install opcache && \
docker-php-ext-configure gd --with-freetype-dir=/usr/include --with-jpeg-dir=/usr/include --with-png-dir=/usr/include && \
docker-php-ext-install gd

# Other PHP5.6 Extensions
RUN echo "Enabling PHP extensions" && \
docker-php-ext-enable pdo_mysql && \
docker-php-ext-enable pdo_sqlite && \
docker-php-ext-enable mysqli && \
docker-php-ext-enable zip

# Install intl extension
RUN echo "Install PHP Intl" \
&& docker-php-ext-configure intl \
&& docker-php-ext-install -j$(nproc) intl \
&& docker-php-ext-enable intl \
&& rm -rf /tmp/*

# Install xdebug
RUN echo "Install xDebug" \
&& pecl install xdebug-2.9.2 \
&& docker-php-ext-enable xdebug

# Install redis
RUN echo "Install Redis" \
&& pecl install redis-5.3.4 \
&& docker-php-ext-enable redis

# Install sendmailer for Mailhog
RUN curl --location --output /usr/local/bin/mhsendmail https://github.com/mailhog/mhsendmail/releases/download/v0.2.0/mhsendmail_linux_amd64 \
&& chmod +x /usr/local/bin/mhsendmail

# Clean up, try to reduce image size
RUN apt-get remove -y libmcrypt-dev libicu-dev libpng-dev libjpeg-dev libfreetype6-dev libxpm-dev libvpx-dev gcc \
&& apt-get autoremove -y \
&& apt-get clean all \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/*


# Add user for web application
RUN groupadd -g $uid www
RUN useradd -u $uid -ms /bin/bash -g www www

# Copy existing application directory contents
COPY . /var/www/html

# Copy existing application directory permissions
COPY --chown=www:www . /var/www/html

# Change current user to www
USER www

# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm"]
104 changes: 104 additions & 0 deletions .docker/services/php/Dockerfile.php8
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Create image based on the official PHP-FMP image
FROM php:8.0-fpm

# Arguments defined in docker-compose.yml
ARG uid

# Update the base libraries
RUN apt-get -y update --fix-missing && apt-get upgrade -y

# Install useful tools and install important libaries
RUN apt-get -y --no-install-recommends install --fix-missing \
git nano wget dialog \
apt-utils build-essential \
zip openssl curl \
libmcrypt4 \
libfreetype6 \
libjpeg62-turbo \
libpng16-16 \
libxpm4 \
libsqlite3-dev \
libsqlite3-0 \
default-mysql-client \
libmcrypt-dev \
zlib1g-dev \
libzip-dev \
libicu-dev \
libpng-dev \
libjpeg-dev \
libfreetype6-dev \
libwebp-dev \
libonig-dev \
libcurl3-dev \
libcurl3-openssl-dev \
libmemcached-dev \
zlib1g-dev

# Other PHP5.6 Extensions
RUN echo "Installing PHP extensions" && \
docker-php-ext-install pdo && \
docker-php-ext-install pdo_mysql && \
docker-php-ext-install mysqli && \
docker-php-ext-install curl && \
docker-php-ext-install tokenizer && \
docker-php-ext-install zip && \
docker-php-ext-install mbstring && \
docker-php-ext-install gettext && \
docker-php-ext-install opcache && \
docker-php-ext-configure \
# ref: https://github.com/docker-library/php/issues/920#issuecomment-562864296
gd --enable-gd --with-freetype --with-jpeg --with-webp && \
docker-php-ext-install gd

# Other PHP5.6 Extensions
RUN echo "Enabling PHP extensions" && \
docker-php-ext-enable pdo_mysql && \
docker-php-ext-enable pdo && \
docker-php-ext-enable mysqli && \
docker-php-ext-enable zip

# Install intl extension
RUN echo "Install PHP Intl" \
&& docker-php-ext-configure intl \
&& docker-php-ext-install -j$(nproc) intl \
&& docker-php-ext-enable intl \
&& rm -rf /tmp/*

# Install xdebug
RUN echo "Install xDebug" \
&& pecl install xdebug-3.1.5 \
&& docker-php-ext-enable xdebug

# Install redis
RUN echo "Install Redis" \
&& pecl install redis-5.3.4 \
&& docker-php-ext-enable redis

# Install sendmailer for Mailhog
RUN curl --location --output /usr/local/bin/mhsendmail https://github.com/mailhog/mhsendmail/releases/download/v0.2.0/mhsendmail_linux_amd64 \
&& chmod +x /usr/local/bin/mhsendmail

# Clean up, try to reduce image size
RUN apt-get remove -y libmcrypt-dev libicu-dev libpng-dev libjpeg-dev libfreetype6-dev libxpm-dev libvpx-dev gcc \
&& apt-get autoremove -y \
&& apt-get clean all \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/*


# Add user for web application
RUN groupadd -g $uid www
RUN useradd -u $uid -ms /bin/bash -g www www

# Copy existing application directory contents
COPY . /var/www/html

# Copy existing application directory permissions
COPY --chown=www:www . /var/www/html

# Change current user to www
USER www

# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 20d0a0d

Please sign in to comment.