From fbb4017e3ce5c29fd90cb4fa058a3408613f6ab7 Mon Sep 17 00:00:00 2001 From: Josh Krawczyk Date: Sun, 16 Feb 2020 00:30:41 -0500 Subject: [PATCH] Fixed config files that were missing from git. Added email ARGs to the config --- docker/.env.example | 8 +++++ docker/api/dockerfile | 9 +++++- docker/api/local_settings.py.keep | 53 +++++++++++++++++++++++++++++++ docker/app/.env.local.keep | 2 ++ docker/app/dockerfile | 4 +-- docker/docker-compose.yml | 7 ++++ docker/readme.md | 4 ++- 7 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 docker/api/local_settings.py.keep create mode 100644 docker/app/.env.local.keep diff --git a/docker/.env.example b/docker/.env.example index c0aa9d2a..113e1d12 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -17,5 +17,13 @@ SALT_PASS=password ADMIN_URL=admin DJANGO_SEKRET=secret12341234123412341234 +DJANGO_DEBUG=False TWO_FACTOR_OTP=3HTDZVFRYP4OPXHL + +EMAIL_TLS=True +EMAIL_HOST=smtp.gmail.com +EMAIL_USER=example@gmail.com +EMAIL_PASS=changeme +EMAIL_PORT=587 +EMAIL_ALERT_RECIPIENTS="example@gmail.com", diff --git a/docker/api/dockerfile b/docker/api/dockerfile index 34c5fe6f..d3d0212c 100644 --- a/docker/api/dockerfile +++ b/docker/api/dockerfile @@ -1,6 +1,7 @@ FROM tiangolo/uwsgi-nginx:python3.7 WORKDIR /app ARG DJANGO_SEKRET +ARG DJANGO_DEBUG ARG POSTGRES_USER ARG POSTGRES_PASS ARG POSTGRES_HOST @@ -14,6 +15,12 @@ ARG APP_HOST ARG API_HOST ARG ADMIN_URL ARG TWO_FACTOR_OTP +ARG EMAIL_TLS +ARG EMAIL_HOST +ARG EMAIL_USER +ARG EMAIL_PASS +ARG EMAIL_PORT +ARG EMAIL_RECIPIENTS EXPOSE 80 @@ -25,5 +32,5 @@ COPY ./docker/api/uwsgi.ini . COPY ./docker/api/api.conf /app/api.conf.tmp RUN envsubst '\$APP_HOST, \$API_HOST' < /app/api.conf.tmp > /app/nginx.conf && \ rm /app/api.conf.tmp -COPY ./docker/api/local_settings.py ./tacticalrmm/local_settings.py.tmp +COPY ./docker/api/local_settings.py.keep ./tacticalrmm/local_settings.py.tmp RUN envsubst < /app/tacticalrmm/local_settings.py.tmp > /app/tacticalrmm/local_settings.py && rm /app/tacticalrmm/local_settings.py.tmp \ No newline at end of file diff --git a/docker/api/local_settings.py.keep b/docker/api/local_settings.py.keep new file mode 100644 index 00000000..f5f9f826 --- /dev/null +++ b/docker/api/local_settings.py.keep @@ -0,0 +1,53 @@ +SECRET_KEY = '${DJANGO_SEKRET}' + +ALLOWED_HOSTS = ['${API_HOST}'] + +ADMIN_URL = "${ADMIN_URL}" + +CORS_ORIGIN_WHITELIST = ["https://${APP_HOST}"] + +DEBUG = ${DJANGO_DEBUG} + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': 'tacticalrmm', + 'USER': '${POSTGRES_USER}', + 'PASSWORD': '${POSTGRES_PASS}', + 'HOST': '${POSTGRES_HOST}', + 'PORT': '5432', + } +} + +REST_FRAMEWORK = { + 'DATETIME_FORMAT': "%b-%d-%Y - %H:%M", + + 'DEFAULT_PERMISSION_CLASSES': ( + 'rest_framework.permissions.IsAuthenticated', + ), + 'DEFAULT_AUTHENTICATION_CLASSES': ( + 'knox.auth.TokenAuthentication', + ), +} + +if not DEBUG: + REST_FRAMEWORK.update({ + 'DEFAULT_RENDERER_CLASSES': ( + 'rest_framework.renderers.JSONRenderer', + ) + }) + +EMAIL_USE_TLS = ${EMAIL_TLS} +EMAIL_HOST = '${EMAIL_HOST}' +EMAIL_HOST_USER = '${EMAIL_USER}' +EMAIL_HOST_PASSWORD = '${EMAIL_PASS}' +EMAIL_PORT = ${EMAIL_PORT} +EMAIL_ALERT_RECIPIENTS = [${EMAIL_RECIPIENTS}] + +SALT_USERNAME = "${SALT_USER}" +SALT_PASSWORD = "${SALT_PASS}" +MESH_USERNAME = "${MESH_USER}" +MESH_SITE = "https://${MESH_HOST}" +REDIS_HOST = "${REDIS_HOST}" +SALT_HOST = "${SALT_HOST}" +TWO_FACTOR_OTP = "${TWO_FACTOR_OTP}" \ No newline at end of file diff --git a/docker/app/.env.local.keep b/docker/app/.env.local.keep new file mode 100644 index 00000000..ac95db05 --- /dev/null +++ b/docker/app/.env.local.keep @@ -0,0 +1,2 @@ +VUE_APP_PROD_URL = "https://${APP_HOST}" +VUE_APP_DEV_URL = "http://localhost:8000" \ No newline at end of file diff --git a/docker/app/dockerfile b/docker/app/dockerfile index a867cc4d..e766097f 100644 --- a/docker/app/dockerfile +++ b/docker/app/dockerfile @@ -5,8 +5,8 @@ EXPOSE 80 WORKDIR /home/node RUN apk add gettext COPY ./web . -COPY ./docker/app/.env.local /home/.env.local.tmp -RUN envsubst '\$APP_HOST, \$API_HOST' < /home/.env.local.tmp > /home/node/.env.local && rm /home/.env.local.tmp +COPY ./docker/app/.env.local.keep /home/.env.local.tmp +RUN envsubst '\$APP_HOST' < /home/.env.local.tmp > /home/node/.env.local && rm /home/.env.local.tmp RUN npm install && npm run build COPY ./docker/app/app.conf /home/node/app.conf.tmp RUN envsubst '\$APP_HOST' < /home/node/app.conf.tmp > /home/node/app.conf diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 32c72037..0a9bfca4 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -71,6 +71,7 @@ services: dockerfile: "./docker/api/dockerfile" args: - DJANGO_SEKRET=${DJANGO_SEKRET} + - DJANGO_DEBUG=${DJANGO_DEBUG} - POSTGRES_USER=${POSTGRES_USER} - POSTGRES_PASS=${POSTGRES_PASS} - POSTGRES_HOST=${POSTGRES_HOST} @@ -84,6 +85,12 @@ services: - API_HOST=${API_HOST} - ADMIN_URL=${ADMIN_URL} - TWO_FACTOR_OTP=${TWO_FACTOR_OTP} + - EMAIL_TLS=${EMAIL_TLS} + - EMAIL_HOST=${EMAIL_HOST} + - EMAIL_USER=${EMAIL_USER} + - EMAIL_PASS=${EMAIL_PASS} + - EMAIL_PORT=${EMAIL_PORT} + - EMAIL_RECIPIENTS=${EMAIL_RECIPIENTS} networks: - proxy - database diff --git a/docker/readme.md b/docker/readme.md index 06802685..bc5fef7c 100644 --- a/docker/readme.md +++ b/docker/readme.md @@ -13,12 +13,14 @@ sudo apt-get install certbot Generate the wildcard certificate. Add the DNS entry for domain validation. -```sudo certbot certonly --manual -d *.example.com --agree-tos --no-bootstrap --manual-public-ip-logging-ok --preferred-challenges dns +``` +sudo certbot certonly --manual -d *.example.com --agree-tos --no-bootstrap --manual-public-ip-logging-ok --preferred-challenges dns ``` Copy the fullchain.pem and privkey.pem to the cert directory. ## Run the environment with Docker +Copy the .env.example to .env Change values in .env to match your environment ```