From 176464a193fad0aea1e52c8d4fe10a6bed82b739 Mon Sep 17 00:00:00 2001 From: Keith Irwin Date: Mon, 7 Nov 2022 14:53:23 -0700 Subject: [PATCH] Moved env vars away from Dockerfiles --- .gitignore | 3 ++- back/admin.Dockerfile | 10 +++------- back/dashboard.Dockerfile | 10 +++------- docker-compose.yml | 21 ++++++++++++--------- 4 files changed, 20 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index 52d05a0..dba9793 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -etc/ +etc/config +etc/servers diff --git a/back/admin.Dockerfile b/back/admin.Dockerfile index 25eaa77..37a61b4 100644 --- a/back/admin.Dockerfile +++ b/back/admin.Dockerfile @@ -1,9 +1,5 @@ FROM debian:latest -# Change these -ENV LISTEN_PORT=4441 -ENV ADMIN_EMAIL='me@example.com' - # Install deps RUN apt-get update && apt-get install --yes \ sudo curl apache2 openssl wireguard-tools dnsutils ipv6calc jq \ @@ -16,8 +12,8 @@ RUN chown -R www-data:www-data /usr/lib/wgapi /var/log/wgapi /var/local/wgapi_to # Configure apache RUN a2enmod cgi rewrite -RUN sed -i "s/^Listen 80$/Listen ${LISTEN_PORT}/" /etc/apache2/ports.conf -RUN sed -i -e "s/^$//" \ +RUN sed -i "s/^Listen 80$/Listen ${ADMIN_PORT}/" /etc/apache2/ports.conf +RUN sed -i -e "s/^$//" \ -e "s|DocumentRoot .*$|DocumentRoot /usr/lib/cgi-bin\n\tSetHandler cgi-script\n\tOptions +ExecCGI|" \ -e "s/ServerAdmin .*$/ServerAdmin ${ADMIN_EMAIL}/" \ /etc/apache2/sites-available/000-default.conf @@ -33,5 +29,5 @@ COPY admin_user.cgi /usr/lib/cgi-bin/user COPY lib/ /usr/lib/wgapi/ # Run time! -EXPOSE ${LISTEN_PORT} +EXPOSE ${ADMIN_PORT} CMD ["apachectl", "-D", "FOREGROUND"] diff --git a/back/dashboard.Dockerfile b/back/dashboard.Dockerfile index 542c896..035e7f6 100644 --- a/back/dashboard.Dockerfile +++ b/back/dashboard.Dockerfile @@ -1,9 +1,5 @@ FROM debian:latest -# Change these -ENV LISTEN_PORT=4442 -ENV ADMIN_EMAIL='me@example.com' - # Install deps RUN apt-get update && apt-get install --yes \ sudo curl apache2 openssl wireguard-tools dnsutils ipv6calc jq \ @@ -16,9 +12,9 @@ RUN chown -R www-data:www-data /usr/lib/wgapi /var/log/wgapi /var/local/wgapi_to # Configure apache RUN a2enmod cgi rewrite -RUN sed -i "s/^Listen 80$/Listen ${LISTEN_PORT}/" \ +RUN sed -i "s/^Listen 80$/Listen ${DASHBOARD_PORT}/" \ /etc/apache2/ports.conf -RUN sed -i -e "s/^$//" \ +RUN sed -i -e "s/^$//" \ -e "s|DocumentRoot .*$|DocumentRoot /usr/lib/cgi-bin\n\tSetHandler cgi-script\n\tOptions +ExecCGI|" \ -e "s/ServerAdmin .*$/ServerAdmin ${ADMIN_EMAIL}/" \ /etc/apache2/sites-available/000-default.conf @@ -34,5 +30,5 @@ COPY dashboard_ssl.cgi /usr/lib/cgi-bin/ssl COPY lib/ /usr/lib/wgapi/ # Run time! -EXPOSE ${LISTEN_PORT} +EXPOSE ${DASHBOARD_PORT} CMD ["apachectl", "-D", "FOREGROUND"] diff --git a/docker-compose.yml b/docker-compose.yml index 7caa7c0..154cd53 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,42 +8,44 @@ networks: services: dashboard-backend: - build: + build: context: back dockerfile: dashboard.Dockerfile container_name: wgapi-dashboard-backend cap_add: - NET_ADMIN network_mode: host - volumes: + env_file: etc/config + volumes: - '/etc/ssl/private:/etc/ssl/private' - '/etc/wgapi:/etc/wgapi:ro' - '/var/log/wgapi:/var/log/wgapi' dashboard-frontend: - build: + build: context: front dockerfile: dashboard.Dockerfile container_name: wgapi-dashboard-frontend networks: wgapi: ipv4_address: 172.19.0.2 - + admin-backend: - build: + build: context: back dockerfile: admin.Dockerfile cap_add: - NET_ADMIN network_mode: host container_name: wgapi-admin-backend - volumes: + env_file: etc/config + volumes: - '/var/log/wgapi:/var/log/wgapi' - '/etc/ssl/private:/etc/ssl/private' - '/etc/wgapi:/etc/wgapi:ro' admin-frontend: - build: + build: context: front dockerfile: admin.Dockerfile container_name: wgapi-admin-frontend @@ -52,12 +54,13 @@ services: ipv4_address: 172.19.0.3 # fed-backend: -# build: +# build: # context: back # dockerfile: fed.Dockerfile # cap_add: # - NET_ADMIN # network_mode: host +# env_file: etc/config # container_name: wgapi-fed-backend -# volumes: +# volumes: # - '/var/log/wgapi:/var/log/wgapi'