diff --git a/Dockerfile b/Dockerfile index 29689c2..a4670ff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,11 +13,14 @@ RUN composer self-update 2.1.8 RUN composer install FROM trafex/alpine-nginx-php7:ba1dd422 -RUN apk update && apk add --no-cache busybox-suid sudo php7-redis php7-pdo php7-pdo_mysql php7-fileinfo shadow gettext bash apache2-utils + +RUN apk update && apk add --no-cache busybox-suid sudo php7-redis php7-pdo php7-pdo_mysql php7-fileinfo shadow gettext bash apache2-utils logrotate + # symlink nginx logs to stdout/stderr for supervisord RUN ln -sf /dev/stdout /var/log/nginx/access.log \ && ln -sf /dev/stderr /var/log/nginx/error.log +COPY static/logrotate/pathfinder /etc/logrotate.d/pathfinder COPY static/nginx/nginx.conf /etc/nginx/templateNginx.conf # we need to create sites_enabled directory in order for entrypoint.sh being able to copy file after envsubst RUN mkdir -p /etc/nginx/sites_enabled/ diff --git a/README.md b/README.md index b7d566d..34b0292 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ Development configs and docker files can be quickly restored using: chmod +x ./development/development.sh && ./development/development.sh ``` -This creates a partial `.env` file, but you will need to add your CCP SSO client and keys manually. +This creates a partial `.env` file, but you will need to add your CCP SSO client and keys manually, if you want to copy development files without overwriting your .env file add the flag `--noenv` when running the script. It's best to create a new SSO application for development work, so that you can set the callback url to `https://localhost/sso/callbackAuthorization`. diff --git a/development/Dockerfile.development b/development/Dockerfile.development index a97ac3b..6e7ee25 100644 --- a/development/Dockerfile.development +++ b/development/Dockerfile.development @@ -1,4 +1,4 @@ -FROM php:7.2.5-fpm-alpine3.7 as build +FROM php:7.2.11-fpm-alpine3.7 as build RUN apk update \ && apk add --no-cache libpng-dev zeromq-dev git \ @@ -13,8 +13,10 @@ RUN composer self-update 2.1.8 RUN composer install FROM trafex/alpine-nginx-php7:ba1dd422 -RUN apk update && apk add --no-cache busybox-suid sudo php7-redis php7-pdo php7-pdo_mysql php7-fileinfo shadow gettext bash apache2-utils +RUN apk update && apk add --no-cache busybox-suid sudo php7-redis php7-pdo php7-pdo_mysql php7-fileinfo shadow gettext bash apache2-utils logrotate + +COPY static/logrotate/pathfinder /etc/logrotate.d/pathfinder COPY static/nginx/nginx.conf /etc/nginx/templateNginx.conf # we need to create sites_enabled directory in order for entrypoint.sh being able to copy file after envsubst RUN mkdir -p /etc/nginx/sites_enabled/ @@ -39,7 +41,6 @@ COPY static/entrypoint.sh / WORKDIR /var/www/html COPY --chown=nobody --from=build /app pathfinder - RUN chmod 0766 pathfinder/logs pathfinder/tmp/ && rm index.php && touch /etc/nginx/.setup_pass && chmod +x /entrypoint.sh COPY static/pathfinder/routes.ini /var/www/html/pathfinder/app/ COPY static/pathfinder/environment.ini /var/www/html/pathfinder/app/templateEnvironment.ini diff --git a/development/development.sh b/development/development.sh index 40b7e4f..14a327f 100755 --- a/development/development.sh +++ b/development/development.sh @@ -16,6 +16,15 @@ cp ./development/xdebug.ini ./static/php/xdebug.ini # set up launch file for vscode mkdir -p .vscode && cp ./development/launch.json ./.vscode/launch.json -# seed .env file with dev presets -echo "path=\"$(pwd)\"" > ./.env -cat ./development/.env.development >> ./.env +# seed .env unless --noenv flag is set +while true; do + case "$1" in + --noenv ) NO_ENV=true; shift ;; + * ) break ;; + esac +done +if [ ! "$NO_ENV" == "true" ]; then + echo "PROJECT_ROOT=\"$(pwd)\"" > ./.env + cat ./development/.env.development >> ./.env + echo "WARNING: .env has been replaced, remember to fill any required variables" +fi diff --git a/development/docker-compose.development.yml b/development/docker-compose.development.yml index a51a1c1..128bea9 100644 --- a/development/docker-compose.development.yml +++ b/development/docker-compose.development.yml @@ -35,6 +35,7 @@ services: hostname: socket volumes: - ${PROJECT_ROOT}/websocket:/app + - ${PROJECT_ROOT}/logs:/var/www/html/pathfinder/history/map networks: pf: aliases: @@ -54,7 +55,7 @@ services: - "traefik.http.routers.pf.entrypoints=web" - "traefik.http.routers.pf-secure.rule=Host(`${DOMAIN}`)" - "traefik.http.routers.pf-secure.entrypoints=websecure" - - "traefik.http.routers.pf-secure.tls=true" + - "traefik.http.routers.pf-secure.tls=true" - "traefik.http.middlewares.redirecthttps.redirectscheme.scheme=https" - "traefik.http.routers.pf.middlewares=redirecthttps" networks: @@ -66,6 +67,7 @@ services: - ${PROJECT_ROOT}/config/pathfinder/config.ini:/var/www/html/pathfinder/app/templateConfig.ini - ${PROJECT_ROOT}/config/pathfinder/pathfinder.ini:/var/www/html/pathfinder/app/pathfinder.ini - ${PROJECT_ROOT}/config/pathfinder/plugin.ini:/var/www/html/pathfinder/app/plugin.ini + - ${PROJECT_ROOT}/logs:/var/www/html/pathfinder/history/map depends_on: - pfdb - pf-redis diff --git a/docker-compose.yml b/docker-compose.yml index 50668c0..45ba581 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -35,6 +35,7 @@ services: hostname: socket volumes: - ${PROJECT_ROOT}/websocket:/app + - ${PROJECT_ROOT}/logs:/var/www/html/pathfinder/history/map networks: pf: aliases: @@ -67,6 +68,7 @@ services: - ${PROJECT_ROOT}/config/pathfinder/config.ini:/var/www/html/pathfinder/app/templateConfig.ini - ${PROJECT_ROOT}/config/pathfinder/pathfinder.ini:/var/www/html/pathfinder/app/pathfinder.ini - ${PROJECT_ROOT}/config/pathfinder/plugin.ini:/var/www/html/pathfinder/app/plugin.ini + - ${PROJECT_ROOT}/logs:/var/www/html/pathfinder/history/map depends_on: - pfdb - pf-redis diff --git a/logs/.gitignore b/logs/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/logs/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/static/logrotate/pathfinder b/static/logrotate/pathfinder new file mode 100644 index 0000000..837d33a --- /dev/null +++ b/static/logrotate/pathfinder @@ -0,0 +1,7 @@ +/var/www/html/pathfinder/history/map/*.log { + daily + missingok + rotate 14 + compress + notifempty +} \ No newline at end of file