Skip to content

Commit

Permalink
#56 - change docker image and refactor (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHDOLEK committed Nov 20, 2023
1 parent 691d394 commit 3d303ce
Show file tree
Hide file tree
Showing 54 changed files with 662 additions and 1,758 deletions.
44 changes: 44 additions & 0 deletions .docker/dev/ngnix/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
daemon off;

user nginx;
worker_processes auto;

error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;

server {
listen 80 default;
server_name keating-nginx;

access_log /dev/stdout;
error_log /dev/stderr;

root /application/public;
index index.php;

if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}
60 changes: 60 additions & 0 deletions .docker/dev/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
FROM composer/composer:2.6.2-bin as composer-bin

FROM php:8.2.10-fpm-bullseye

COPY --from=composer-bin ./composer /usr/bin/composer

ARG USER_NAME=host-user
ARG USER_ID=1000
ARG PHP_FPM_GROUP=www-data

RUN adduser \
--disabled-password \
--uid ${USER_ID} \
${USER_NAME} \
&& usermod \
--append \
--groups \
${PHP_FPM_GROUP} \
${USER_NAME}

# Use the default development configuration
RUN mv "${PHP_INI_DIR}/php.ini-development" "${PHP_INI_DIR}/php.ini"

# For other versions check: http://nginx.org/packages/mainline/debian/pool/nginx/n/nginx/
ARG NGINX_VERSION="1.25.2-1~bullseye"
ARG PHPREDIS_VERSION=6.0.0

RUN apt-get update \
&& apt-get install --assume-yes gpg \
&& curl https://nginx.org/keys/nginx_signing.key | gpg --dearmour --output /etc/apt/trusted.gpg.d/apt.nginx.org.gpg > /dev/null \
&& echo "deb https://nginx.org/packages/mainline/debian bullseye nginx" | tee /etc/apt/sources.list.d/nginx.list \
&& apt-get update && apt-get install --assume-yes \
nginx=${NGINX_VERSION} \
libzip-dev \
libpq-dev \
supervisor \
cron \
&& pecl install redis-${PHPREDIS_VERSION} \
&& docker-php-ext-install \
zip \
pdo_pgsql \
sockets \
pcntl \
&& docker-php-ext-enable \
pcntl \
redis

ARG XDEBUG_VERSION=3.2.1
ARG INSTALL_XDEBUG=true

RUN if [ ${INSTALL_XDEBUG} = true ]; then \
pecl install xdebug-${XDEBUG_VERSION} \
&& docker-php-ext-enable xdebug \
;fi

COPY ./entrypoint.sh /entrypoint.sh

WORKDIR /application

ENTRYPOINT ["/entrypoint.sh"]
12 changes: 12 additions & 0 deletions .docker/dev/php/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# -e is for "automatic error detection", tell shell to abort any time an error occurred
set -e

# bash is not responding to the sigterm and container always have 10 second timeout (when stop/restart)
# exec is related with
# https://docs.docker.com/compose/faq/#why-do-my-services-take-10-seconds-to-recreate-or-stop
# https://github.com/moby/moby/issues/3766
# https://unix.stackexchange.com/a/196053

exec supervisord --configuration /etc/supervisor/custom-supervisord.conf
8 changes: 8 additions & 0 deletions .docker/dev/php/php-fpm.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[global]
daemonize = no

[www]
listen = /run/php-fpm.sock
listen.owner = nginx

user = host-user
6 changes: 5 additions & 1 deletion .docker/php/conf/xdebug.ini → .docker/dev/php/php.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
xdebug.mode=develop,debug
[PHP]
memory_limit = 256M

[xdebug]
xdebug.mode=develop,debug,coverage
xdebug.client_host=host.docker.internal
xdebug.start_with_request=yes
xdebug.client_port=9003
22 changes: 22 additions & 0 deletions .docker/dev/php/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
; For more information on the config file, please see:
; http://supervisord.org/configuration.html

[supervisord]
logfile = /var/log/supervisor/supervisord.log
pidfile = /var/run/supervisord.pid
user = root
nodaemon = true

[program:nginx]
command=nginx
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0

[program:php-fpm]
command = php-fpm
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0
53 changes: 0 additions & 53 deletions .docker/nginx/nginx.conf

This file was deleted.

45 changes: 0 additions & 45 deletions .docker/php/Dockerfile

This file was deleted.

34 changes: 0 additions & 34 deletions .docker/php/Dockerfile-dev

This file was deleted.

10 changes: 0 additions & 10 deletions .docker/php/bin/entrypoint.sh

This file was deleted.

17 changes: 0 additions & 17 deletions .docker/php/conf/horizon.conf

This file was deleted.

9 changes: 0 additions & 9 deletions .docker/php/conf/opcache.ini

This file was deleted.

17 changes: 0 additions & 17 deletions .docker/php/conf/php-fpm.conf

This file was deleted.

19 changes: 0 additions & 19 deletions .docker/php/conf/php.ini

This file was deleted.

Loading

0 comments on commit 3d303ce

Please sign in to comment.