[DOCKER] Fixed docker environment to properly configure the app environment

This commit is contained in:
Hugo Sales 2020-05-06 12:04:59 +00:00 committed by Hugo Sales
parent cf1a9fe893
commit b1afa9cf91
Signed by untrusted user: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
8 changed files with 36 additions and 24 deletions

1
.gitignore vendored
View File

@ -26,3 +26,4 @@ DOCUMENTATION/database/*
!DOCUMENTATION/database/database.pdf !DOCUMENTATION/database/database.pdf
docker/certbot docker/certbot
docker/*/*.env

View File

@ -2,7 +2,7 @@ version: '3.3'
services: services:
nginx: nginx:
image: nginx:latest image: nginx:alpine
depends_on: depends_on:
- php - php
restart: always restart: always
@ -11,10 +11,20 @@ services:
- 80:80 - 80:80
- 443:443 - 443:443
volumes: volumes:
# Nginx
- ./docker/nginx/nginx.conf:/var/nginx/social.conf
- ./docker/nginx/domain.sh:/var/nginx/domain.sh
# Certbot
- ./docker/certbot/www:/var/www/certbot
- ./docker/certbot/files:/etc/letsencrypt
# Social
- ./public:/var/www/social/public - ./public:/var/www/social/public
- ./docker/nginx/nginx.conf:/etc/nginx/conf.d/social.conf env_file:
command: /bin/sh -c 'sed -ri "s/%hostname%/$domain/" /etc/nginx/conf.d/social.conf - ./docker/bootstrap/bootstrap.env
while :; do sleep 6h & wait $${!}; - ./docker/db/db.env
command: /bin/sh -c '/var/nginx/domain.sh;
while :; do
sleep 6h & wait $${!};
nginx -s reload; nginx -s reload;
done & done &
nginx -g "daemon off;"' nginx -g "daemon off;"'
@ -49,7 +59,7 @@ services:
- ./docker/social/install.sh:/var/entrypoint.d/social_install.sh - ./docker/social/install.sh:/var/entrypoint.d/social_install.sh
# Main files # Main files
- .:/var/www/social - .:/var/www/social
env_files: env_file:
- ./docker/social/social.env - ./docker/social/social.env
- ./docker/db/db.env - ./docker/db/db.env
command: /entrypoint.sh command: /entrypoint.sh

View File

@ -1,2 +0,0 @@
email=example@foo.bar
domain=domain.foo

View File

@ -1,15 +1,14 @@
#!/bin/sh #!/bin/sh
case $SOCIAL_DBMS in case $DBMS in
"mariadb") "mariadb")
CMD=mysqladmin ping --silent -hdb -uroot -p${MYSQL_ROOT_PASSWORD} CMD="mysqladmin ping --silent -hdb -uroot -p${MYSQL_ROOT_PASSWORD}"
;; ;;
"postgres") "postgres")
CMD=su postgres && pg_isready -hdb -q CMD="pg_isready -hdb -q"
;; ;;
*) *)
exit 1 exit 1
esac esac
while ! $CMD; while ! $CMD;

5
docker/nginx/domain.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
cat /var/nginx/social.conf | \
sed -r "s/%hostname%/$domain/g; s/%hostname_root%/$domain_root/g" > \
/etc/nginx/conf.d/social.conf

View File

@ -11,7 +11,15 @@ server {
server { server {
include ssl-common.conf listen [::]:443 ssl http2;
listen 443 ssl http2;
ssl_certificate /etc/letsencrypt/live/%hostname_root%/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/%hostname_root%/privkey.pem;
# Let's Encrypt best practices
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
root /var/www/social/public; root /var/www/social/public;

View File

@ -1,10 +0,0 @@
listen [::]:443 ssl http2;
listen 443 ssl http2;
ssl_certificate /etc/letsencrypt/live/hsal.es/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/hsal.es/privkey.pem;
# Let's Encrypt best practices
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

View File

@ -1,6 +1,7 @@
FROM php:fpm-alpine FROM php:fpm-alpine
RUN apk update && apk add gettext-dev icu-dev zlib-dev libpng-dev gmp-dev postgresql-dev composer > /dev/null RUN apk update && apk add gettext-dev icu-dev zlib-dev libpng-dev gmp-dev \
postgresql-dev postgresql-client composer > /dev/null
ARG exts=" bcmath exif gd gettext gmp intl mysqli opcache pdo_mysql" ARG exts=" bcmath exif gd gettext gmp intl mysqli opcache pdo_mysql"