Skip to content

Commit

Permalink
Merge pull request #11 from GDRCD/dev
Browse files Browse the repository at this point in the history
v2.0.0
  • Loading branch information
Kasui92 authored Dec 31, 2024
2 parents 0795e09 + f3e8a41 commit 02f2b43
Show file tree
Hide file tree
Showing 65 changed files with 4,281 additions and 343 deletions.
53 changes: 22 additions & 31 deletions .docker/compose.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,36 @@
services:

php:
webserver:
build:
context: "services/php"
dockerfile: "Dockerfile.${PHP_VERSION}"
context: "${STACK_DIR}"
dockerfile: "${STACK_DIR}/.docker/services/webserver/version/${PHP_VERSION}/Dockerfile"
args:
uid: "${PHP_UID}"
image: "${PROJECT}_php"
container_name: "${PROJECT}_php"
image: "${PROJECT}_webserver"
container_name: "${PROJECT}_webserver"
ports:
- "${SERVICE_PORT}:80"
volumes:
- ./services/php/config/conf.d:/usr/local/etc/php/conf.d:ro
- ../service:/var/www/html
# Log
- "${STACK_DIR}/logs/nginx:/var/log/nginx"
# PHP
- "${STACK_DIR}/.docker/services/webserver/config/conf.d:/usr/local/etc/php/conf.d:ro"
# Web
- "${STACK_DIR}/www:/var/www/html"
environment:
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}

nginx:
build:
context: "services/nginx"
image: "${PROJECT}_nginx"
container_name: "${PROJECT}_nginx"
ports:
- "${SERVICE_PORT}:80"
- "${PMA_PORT}:8080"
volumes:
- ../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: "services/database"
image: "${PROJECT}_database"
container_name: "${PROJECT}_database"
#restart: // always;unless-stopped
ports:
- "${DB_PORT}:3306"
volumes:
- ./services/database/config/conf.d/my.cnf:/etc/mysql/conf.d/my.cnf
- database-data:/var/lib/mysql
- "${STACK_DIR}/.docker/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 @@ -53,21 +42,23 @@ services:
context: "services/phpmyadmin"
image: "${PROJECT}_phpmyadmin"
container_name: "${PROJECT}_phpmyadmin"
volumes:
- phpmyadmin-data:/var/www/html
ports:
- "${PMA_PORT}:80"
environment:
PMA_HOST: database
- PMA_HOST=database
depends_on:
- database
profiles: ["phpmyadmin"]

mailhog:
build:
context: "services/mailhog"
image: "${PROJECT}_mailhog"
container_name: "${PROJECT}_mailhog"
#restart: always
ports:
- "${MAILHOG_PORT}:8025"
profiles: ["mailhog"]

# Volumes
volumes:
database-data:
phpmyadmin-data:
2 changes: 1 addition & 1 deletion .docker/services/database/Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM mysql:5.7
FROM mysql:8.0
1 change: 0 additions & 1 deletion .docker/services/database/config/conf.d/my.cnf
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[mysqld]
collation-server = utf8mb4_unicode_ci
character-set-server = utf8mb4
sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
default_time_zone = Europe/Rome
9 changes: 0 additions & 9 deletions .docker/services/nginx/Dockerfile

This file was deleted.

15 changes: 0 additions & 15 deletions .docker/services/nginx/config/conf.d/phpmyadmin.conf

This file was deleted.

18 changes: 0 additions & 18 deletions .docker/services/nginx/config/example.php.conf

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,6 @@ extension=zip.so
; http://php.net/date.timezone
date.timezone = "Europe/Rome"

; Xdebug
; See https://xdebug.org/docs/all_settings

;PHPStorm
[Xdebug]
xdebug.remote_enable=1
xdebug.idekey=PHPSTORM
xdebug.profiler_enable=0
xdebug.max_nesting_level=700
xdebug.remote_host=192.168.0.1 # your ip
xdebug.remote_port=9000

; INTL Extension
[intl]
intl.default_locale =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ group = www-data
; specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = nginx:9000
listen = 127.0.0.0:9000


; Choose how the process manager will control the number of child processes.
Expand Down Expand Up @@ -72,4 +72,4 @@ pm.min_spare_servers = 1
; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = 3

;---------------------
;---------------------
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ server {
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_pass 127.0.0.0:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
}
7 changes: 7 additions & 0 deletions .docker/services/webserver/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -e

# PHP > Start services
service memcached start
php-fpm -D
nginx -g 'daemon off;'
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,6 @@ RUN echo "Install PHP Intl" \
&& docker-php-ext-enable intl \
&& rm -rf /tmp/*

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

# Install redis
RUN echo "Install Redis" \
&& pecl install redis-2.2.8 \
&& 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
Expand All @@ -87,20 +77,43 @@ RUN apt-get remove -y libmcrypt-dev libicu-dev libpng-dev libjpeg-dev libfreetyp
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/*

# -------------------------------------------------------
# SERVE STAGE
# -------------------------------------------------------

# Get API Base Image
FROM base-stage AS serve-stage

# Arguments defined in compose.yml
ARG uid

# Install serve dependencies
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get -y --no-install-recommends install \
nginx \
memcached \
ssl-cert

# Clean up, try to reduce image size
RUN 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
# Generate ssl certificate
RUN make-ssl-cert generate-default-snakeoil --force-overwrite

# Copy existing application directory contents
COPY . /var/www/html
# Copy nginx config
COPY .docker/services/webserver/config/sites-available/default.nginx /etc/nginx/sites-available/default

# Copy existing application directory permissions
COPY --chown=www:www . /var/www/html
# Copy entrypoint
COPY .docker/services/webserver/entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh
RUN ln -s /usr/local/bin/entrypoint.sh /

# Change current user to www
USER www
# Specify the entrypoint
ENTRYPOINT ["entrypoint.sh"]

# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm"]
# Set working dir
WORKDIR /var/www/html
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Create image based on the official PHP-FMP image
FROM php:7.4-fpm-buster
# -------------------------------------------------------
# BASE STAGE
# -------------------------------------------------------

# Arguments defined in docker-compose.yml
ARG uid
# Create image based on the official PHP-FMP image
FROM php:7.4-fpm-buster AS base-stage

# Update the base libraries
RUN apt-get -y update --fix-missing && apt-get upgrade -y
Expand Down Expand Up @@ -35,7 +36,7 @@ RUN apt-get -y --no-install-recommends install --fix-missing \
libmemcached-dev \
zlib1g-dev

# Other PHP5.6 Extensions
# Other PHP Extensions
RUN echo "Installing PHP extensions" && \
docker-php-ext-install pdo_mysql \
pdo_sqlite \
Expand All @@ -50,7 +51,7 @@ RUN echo "Installing PHP extensions" && \
docker-php-ext-configure gd --with-freetype=/usr/include --with-jpeg=/usr/include && \
docker-php-ext-install gd

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

Expand All @@ -61,16 +62,6 @@ RUN echo "Install PHP 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
Expand All @@ -82,20 +73,43 @@ RUN apt-get remove -y libmcrypt-dev libicu-dev libpng-dev libjpeg-dev libfreetyp
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/*

# -------------------------------------------------------
# SERVE STAGE
# -------------------------------------------------------

# Get API Base Image
FROM base-stage AS serve-stage

# Arguments defined in compose.yml
ARG uid

# Install serve dependencies
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get -y --no-install-recommends install \
nginx \
memcached \
ssl-cert

# Clean up, try to reduce image size
RUN 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
# Generate ssl certificate
RUN make-ssl-cert generate-default-snakeoil --force-overwrite

# Copy existing application directory contents
COPY . /var/www/html
# Copy nginx config
COPY .docker/services/webserver/config/sites-available/default.nginx /etc/nginx/sites-available/default

# Copy existing application directory permissions
COPY --chown=www:www . /var/www/html
# Copy entrypoint
COPY .docker/services/webserver/entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh
RUN ln -s /usr/local/bin/entrypoint.sh /

# Change current user to www
USER www
# Specify the entrypoint
ENTRYPOINT ["entrypoint.sh"]

# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm"]
# Set working dir
WORKDIR /var/www/html
Loading

0 comments on commit 02f2b43

Please sign in to comment.