-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Switch to moustache templating * Add option to increase number of nginx workers * Add option to use LetsEncrypt certificates * Make nginx config compatible with system setup * Add deployment scripts for VM
- Loading branch information
Showing
15 changed files
with
316 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
version: '3.4' | ||
|
||
x-shared-secret-environment: | ||
&shared-secret-environment | ||
environment: | ||
PORT: 8888 | ||
LOKOLE_STORAGE_PROVIDER: AZURE_BLOBS | ||
LOKOLE_QUEUE_BROKER_SCHEME: azureservicebus | ||
CONNEXION_SPEC: dir:/app/opwen_email_server/swagger | ||
CELERY_QUEUE_NAMES: all | ||
TESTING_UI: "False" | ||
LOKOLE_LOG_LEVEL: INFO | ||
SERVER_WORKERS: 4 | ||
QUEUE_WORKERS: 5 | ||
env_file: | ||
- ../secrets/azure.env | ||
- ../secrets/cloudflare.env | ||
- ../secrets/users.env | ||
- ../secrets/sendgrid.env | ||
volumes: | ||
- /tmp:/tmp | ||
|
||
services: | ||
|
||
webapp: | ||
image: ascoderu/opwenwebapp:latest | ||
<<: *shared-secret-environment | ||
ports: | ||
- 8080:8080 | ||
|
||
api: | ||
image: ascoderu/opwenserver_app:latest | ||
command: ["/app/docker/app/run-gunicorn.sh"] | ||
<<: *shared-secret-environment | ||
ports: | ||
- 8888:8888 | ||
|
||
worker: | ||
image: ascoderu/opwenserver_app:latest | ||
command: ["/app/docker/app/run-celery.sh"] | ||
<<: *shared-secret-environment |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
envsubst < /app/nginx.conf.template > /app/nginx.conf "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" | ||
mo < /app/nginx.conf.template > /app/nginx.conf | ||
mo < /app/server.conf.template > /etc/nginx/sites-enabled/server.conf | ||
|
||
nginx -c "/app/nginx.conf" -p "${PWD}" -g "daemon off;" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
upstream healthcheck_hosts { | ||
server {{HOSTNAME_EMAIL_RECEIVE}}; | ||
server {{HOSTNAME_CLIENT_METRICS}}; | ||
server {{HOSTNAME_CLIENT_WRITE}}; | ||
server {{HOSTNAME_CLIENT_READ}}; | ||
server {{HOSTNAME_CLIENT_REGISTER}}; | ||
} | ||
|
||
server { | ||
listen {{PORT}}; | ||
|
||
{{#LETSENCRYPT_DOMAIN}} | ||
server_name {{LETSENCRYPT_DOMAIN}}; | ||
listen [::]:443 ssl ipv6only=on; # managed by Certbot | ||
listen 443 ssl; # managed by Certbot | ||
ssl_certificate /etc/letsencrypt/live/mailserver.lokole.ca/fullchain.pem; # managed by Certbot | ||
ssl_certificate_key /etc/letsencrypt/live/mailserver.lokole.ca/privkey.pem; # managed by Certbot | ||
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot | ||
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot | ||
if ($scheme != "https") { return 301 https://$host$request_uri; } # managed by Certbot | ||
{{/LETSENCRYPT_DOMAIN}} | ||
|
||
{{#DNS_RESOLVER}} | ||
resolver {{DNS_RESOLVER}}; | ||
{{/DNS_RESOLVER}} | ||
|
||
client_max_body_size 50M; | ||
|
||
location = /favicon.ico { | ||
root {{STATIC_ROOT}}/static; | ||
} | ||
|
||
location = /robots.txt { | ||
root {{STATIC_ROOT}}/static; | ||
} | ||
|
||
location /healthcheck { | ||
proxy_pass http://healthcheck_hosts; | ||
} | ||
|
||
location /web { | ||
proxy_set_header Host $http_host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
proxy_pass http://{{HOSTNAME_WEBAPP}}; | ||
} | ||
|
||
location /api/email/sendgrid { | ||
proxy_pass http://{{HOSTNAME_EMAIL_RECEIVE}}; | ||
} | ||
|
||
location /api/email/metrics { | ||
proxy_pass http://{{HOSTNAME_CLIENT_METRICS}}; | ||
} | ||
|
||
location /api/email/upload { | ||
proxy_pass http://{{HOSTNAME_CLIENT_WRITE}}; | ||
} | ||
|
||
location /api/email/download { | ||
proxy_pass http://{{HOSTNAME_CLIENT_READ}}; | ||
} | ||
|
||
location /api/email/register { | ||
proxy_pass http://{{HOSTNAME_CLIENT_REGISTER}}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env bash | ||
## | ||
## This script upgrades an existing production deployment. | ||
## The script assumes that a kubernetes secret exists at /secrets/kube-config. | ||
## | ||
## Required environment variables: | ||
## | ||
## DOCKER_TAG | ||
## HELM_NAME | ||
## IMAGE_REGISTRY | ||
## LOKOLE_DNS_NAME | ||
## | ||
|
||
scriptdir="$(dirname "$0")" | ||
scriptname="${BASH_SOURCE[0]}" | ||
# shellcheck disable=SC1090 | ||
. "${scriptdir}/utils.sh" | ||
|
||
# | ||
# verify inputs | ||
# | ||
|
||
required_env "${scriptname}" "DOCKER_TAG" | ||
required_env "${scriptname}" "HELM_NAME" | ||
required_env "${scriptname}" "IMAGE_REGISTRY" | ||
required_env "${scriptname}" "LOKOLE_DNS_NAME" | ||
required_file "${scriptname}" "/secrets/kube-config" | ||
|
||
# | ||
# upgrade production deployment | ||
# | ||
|
||
log "Upgrading helm deployment ${HELM_NAME}" | ||
|
||
export KUBECONFIG="/secrets/kube-config" | ||
|
||
helm_init | ||
|
||
helm upgrade "${HELM_NAME}" \ | ||
--set domain="${LOKOLE_DNS_NAME}" \ | ||
--set version.imageRegistry="${IMAGE_REGISTRY}" \ | ||
--set version.dockerTag="${DOCKER_TAG}" \ | ||
"${scriptdir}/helm/opwen_cloudserver" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
## | ||
## This script upgrades an production VM. | ||
## | ||
## Required environment variables: | ||
## | ||
## LOKOLE_VM_PASSWORD | ||
## LOKOLE_DNS_NAME | ||
## | ||
|
||
scriptdir="$(dirname "$0")" | ||
scriptname="${BASH_SOURCE[0]}" | ||
# shellcheck disable=SC1090 | ||
. "${scriptdir}/utils.sh" | ||
|
||
# | ||
# verify inputs | ||
# | ||
|
||
required_env "${scriptname}" "LOKOLE_VM_PASSWORD" | ||
required_env "${scriptname}" "LOKOLE_DNS_NAME" | ||
|
||
# | ||
# upgrade production deployment | ||
# | ||
|
||
log "Upgrading VM ${LOKOLE_DNS_NAME}" | ||
|
||
exec sshpass -p "${LOKOLE_VM_PASSWORD}" ssh -o StrictHostKeyChecking=no "opwen@${LOKOLE_DNS_NAME}" < "${scriptdir}/vm.sh" |
Oops, something went wrong.