[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: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
8 changed files with 36 additions and 24 deletions

3
.gitignore vendored
View File

@ -25,4 +25,5 @@
DOCUMENTATION/database/*
!DOCUMENTATION/database/database.pdf
docker/certbot
docker/certbot
docker/*/*.env

View File

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

View File

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

View File

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

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
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"