Basic Docker deployment added with instructions
parent
b708521f73
commit
f54d4a6e73
@ -0,0 +1,7 @@
|
||||
# Datasketch.io
|
||||
|
||||
upstream datasketch_app {
|
||||
server swarm1.androiddrew.com:8000;
|
||||
server swarm2.androiddrew.com:8000;
|
||||
server swarm3.androiddrew.com:8000;
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
# Datasketch.io
|
||||
# Upstream set datasketch_app in /etc/nginx/conf.d/datasketch.http.conf
|
||||
|
||||
server {
|
||||
# HTTP CONFIG
|
||||
server_name datasketch.io;
|
||||
|
||||
|
||||
root /var/www/datasketch;
|
||||
# index index.html;
|
||||
|
||||
location / {
|
||||
|
||||
proxy_pass http://datasketch_app;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
# try_files $uri $uri/ =404;
|
||||
|
||||
}
|
||||
|
||||
listen 443 ssl; # managed by Certbot
|
||||
ssl_certificate /etc/letsencrypt/live/datasketch.io/fullchain.pem; # managed by Certbot
|
||||
ssl_certificate_key /etc/letsencrypt/live/datasketch.io/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
|
||||
|
||||
}
|
||||
|
||||
server {
|
||||
if ($host = datasketch.io) {
|
||||
return 301 https://$host$request_uri;
|
||||
} # managed by Certbot
|
||||
|
||||
|
||||
listen 80;
|
||||
server_name datasketch.io;
|
||||
return 404; # managed by Certbot
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
version: '3.6'
|
||||
|
||||
services:
|
||||
|
||||
cms:
|
||||
image: androiddrew/datasketch:latest
|
||||
deploy:
|
||||
replicas: 1
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
ports:
|
||||
- 8000:8000
|
||||
secrets:
|
||||
- datasketch_key
|
||||
- pg_passwd_datasketch
|
||||
environment:
|
||||
- DJANGO_SETTINGS_MODULE=cms.settings.production
|
||||
- DB_HOST=db
|
||||
- DB_USER=datasketch
|
||||
volumes:
|
||||
- datasketch-media-vol:/code/media
|
||||
depends_on:
|
||||
- db
|
||||
networks:
|
||||
- datasketch_net
|
||||
|
||||
db:
|
||||
image: postgres:10.5-alpine
|
||||
deploy:
|
||||
replicas: 1
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
# Docker secrets for postgres are referenced by /run/secrets/<secret_name>
|
||||
secrets:
|
||||
- pg_passwd_datasketch
|
||||
environment:
|
||||
- POSTGRES_USER=datasketch
|
||||
- POSTGRES_PASSWORD_FILE=/run/secrets/pg_passwd_datasketch
|
||||
- POSTGRES_DB=datasketch
|
||||
expose:
|
||||
- 5432
|
||||
volumes:
|
||||
- datasketch-db-vol:/var/lib/postgresql/data
|
||||
networks:
|
||||
- datasketch_net
|
||||
|
||||
|
||||
networks:
|
||||
datasketch_net:
|
||||
driver: overlay
|
||||
|
||||
volumes:
|
||||
datasketch-db-vol:
|
||||
driver: local
|
||||
driver_opts:
|
||||
type: nfs
|
||||
o: addr=nas1.androiddrew.com,rw
|
||||
device: ":/volume1/expanse/datasketch_pg_data"
|
||||
datasketch-media-vol:
|
||||
driver: local
|
||||
driver_opts:
|
||||
type: nfs
|
||||
o: addr=nas1.androiddrew.com,rw
|
||||
device: ":/volume1/expanse/datasketch_media"
|
||||
|
||||
secrets:
|
||||
pg_passwd_datasketch:
|
||||
external: true
|
||||
datasketch_key:
|
||||
external: true
|
@ -0,0 +1,26 @@
|
||||
# Datasketch CMS
|
||||
|
||||
This service is built using the [Wagtail](http://docs.wagtail.io/en/v2.3/) framework.
|
||||
|
||||
## Middleware
|
||||
|
||||
Since this application is being deployed to a Docker swarm it utilizes [Whitenoise](http://whitenoise.evans.io/en/stable/) and the Django specific whitenoise middleware to deliver static content. This solution is suitable for serving low traffic static content. To improve performance an Nginx reverse proxy could leverage HTTP caching or could be configured to serve all static content directly.
|
||||
|
||||
## Environmental Variables
|
||||
|
||||
The follow environment variables must be set for development. Note that the DB_PASSWD for production must be a docker secret.
|
||||
|
||||
```
|
||||
DB_HOST=<hostname for database>
|
||||
DB_PASSWD=ec<Password for datasketch user>
|
||||
```
|
||||
|
||||
In production you must set the `DJANGO_SETTINGS_MODULE` to the appropriate module:
|
||||
|
||||
```
|
||||
DJANGO_SETTINGS_MODULE=cms.settings.production
|
||||
```
|
||||
|
||||
## Migrations
|
||||
|
||||
The `manage.py` file is used to upgrade the backend database. You will need to log into the container on the appropriate host and execute the command `python manage.py migrate` manually.
|
@ -1,3 +1,4 @@
|
||||
Django>=2.1,<2.2
|
||||
wagtail>=2.3,<2.4
|
||||
psycopg2>=2.7.5
|
||||
psycopg2>=2.7.5
|
||||
whitenoise>=4.1
|
Loading…
Reference in New Issue