Merged in deploy-frontend-alpha (pull request #3)
Deploy frontend alpha
This commit is contained in:
commit
8f24b43229
8 changed files with 103 additions and 23 deletions
|
@ -3,12 +3,6 @@ FROM python:3.6
|
|||
RUN mkdir -p /usr/src/app
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY package.json /usr/src/app/
|
||||
RUN npm install
|
||||
RUN npm install -g bower
|
||||
COPY bower.json /usr/src/app/
|
||||
RUN bower install
|
||||
|
||||
COPY requirements.txt /usr/src/app/
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
|
@ -16,3 +10,4 @@ ENV PYTHONUNBUFFERED 1
|
|||
ENV PYTHONDONTWRITEBYTECODE 1
|
||||
ENV LANG en_US.UTF-8
|
||||
ENV PYTHONIOENCODING utf_8
|
||||
|
||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
.env
|
||||
*.pyc
|
||||
.sass-cache
|
||||
.DS_Store
|
||||
|
|
|
@ -60,9 +60,14 @@ Now access the admin panel with the user account you created earlier: http://loc
|
|||
|
||||
## Production notes
|
||||
|
||||
We are using [Dokku](http://dokku.viewdocs.io/) for automated deployment.
|
||||
We suggest using Docker or [Dokku](http://dokku.viewdocs.io/) for automated deployment.
|
||||
|
||||
```
|
||||
sudo dokku apps:create phase-alpha
|
||||
sudo dokku config:set phase-alpha BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-python
|
||||
docker-compose run web python manage.py migrate
|
||||
... createsuperuser
|
||||
... compress
|
||||
... collectstatic
|
||||
|
||||
docker-compose build web
|
||||
docker-compose up -d
|
||||
```
|
|
@ -1,20 +1,31 @@
|
|||
web:
|
||||
build: .
|
||||
dockerfile: .dockerfile
|
||||
command: python manage.py runserver 0.0.0.0:5000
|
||||
command: gunicorn publichealth.wsgi:application -b 0.0.0.0:5000 -w 5 --log-file=-
|
||||
volumes:
|
||||
- ./:/usr/src/app
|
||||
- ./:/usr/src/app
|
||||
- /var/log/publichealth:/var/log/publichealth
|
||||
links:
|
||||
- redis
|
||||
- postgres
|
||||
- elasticsearch
|
||||
ports:
|
||||
- "5000:5000"
|
||||
environment:
|
||||
- DEBUG=True
|
||||
- DEV=True
|
||||
- DATABASE_URL=postgres://postgres:@postgres:5432/postgres
|
||||
- ELASTICSEARCH_URL=http://elasticsearch:9200
|
||||
- SECRET_KEY=notasecretreplaceme
|
||||
- SECRET_KEY=${SECRET_KEY}
|
||||
- ALLOWED_HOSTS=${ALLOWED_HOSTS}
|
||||
- DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE}
|
||||
- MAILGUN_KEY=${MAILGUN_KEY}
|
||||
- MAILGUN_FROM=${MAILGUN_FROM}
|
||||
- MAILGUN_DOMAIN=${MAILGUN_DOMAIN}
|
||||
- DATABASE_URL=postgres://postgres:@postgres:5432/postgres
|
||||
- ELASTICSEARCH_URL=http://elasticsearch:9200
|
||||
- REDIS_URL=redis://redis:6379
|
||||
- LOG_DIR=/var/log/publichealth
|
||||
redis:
|
||||
image: redis
|
||||
ports:
|
||||
- "6379:6379"
|
||||
postgres:
|
||||
image: postgres
|
||||
ports:
|
||||
|
@ -22,4 +33,4 @@ postgres:
|
|||
elasticsearch:
|
||||
image: orchardup/elasticsearch
|
||||
ports:
|
||||
- "9200:9200"
|
||||
- "9200:9200"
|
||||
|
|
57
docs/public-health.conf
Normal file
57
docs/public-health.conf
Normal file
|
@ -0,0 +1,57 @@
|
|||
# Public Health CMS stage
|
||||
upstream wagtail-stage {
|
||||
server localhost:5000;
|
||||
}
|
||||
server {
|
||||
listen 80;
|
||||
server_name ph-alpha.nebula1.public-health.ch;
|
||||
client_max_body_size 64M;
|
||||
|
||||
gzip on;
|
||||
gzip_types text/plain text/css application/x-javascript image/svg+xml;
|
||||
gzip_comp_level 1;
|
||||
gzip_disable msie6;
|
||||
gzip_http_version 1.0;
|
||||
gzip_proxied any;
|
||||
gzip_vary on;
|
||||
|
||||
location /static/ {
|
||||
access_log off;
|
||||
expires 3600;
|
||||
alias /opt/public-health-ch/static/;
|
||||
}
|
||||
|
||||
# Set a longer expiry for CACHE/, because the filenames are unique.
|
||||
location /static/CACHE/ {
|
||||
access_log off;
|
||||
expires 864000;
|
||||
alias /opt/public-health-ch/static/CACHE/;
|
||||
}
|
||||
|
||||
# Only server /media/images by default, not e.g. original_images/.
|
||||
location /media/images {
|
||||
expires 864000;
|
||||
alias /opt/public-health-ch/media/images;
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_redirect off;
|
||||
proxy_pass http://wagtail-stage;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80; listen 443 ssl;
|
||||
server_name conference.public-health.ch;
|
||||
location /fr {
|
||||
return 301 $scheme://sph17.organizers-congress.org/frontend/index.php?sub=89;
|
||||
}
|
||||
location / {
|
||||
return 301 $scheme://sph17.organizers-congress.org;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -44,6 +44,7 @@ INSTALLED_APPS = [
|
|||
'compressor',
|
||||
'taggit',
|
||||
'puput',
|
||||
'anymail',
|
||||
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
|
@ -187,7 +188,6 @@ WAGTAILSEARCH_BACKENDS = {
|
|||
},
|
||||
}
|
||||
|
||||
|
||||
# Wagtail settings
|
||||
|
||||
WAGTAIL_SITE_NAME = "Public Health Schweiz"
|
||||
|
|
|
@ -7,8 +7,8 @@ from .base import *
|
|||
# Instead, use environment variables or create a local.py file on the server.
|
||||
|
||||
# Disable debug mode
|
||||
DEBUG = True
|
||||
TEMPLATES[0]['OPTIONS']['debug'] = True
|
||||
DEBUG = False
|
||||
TEMPLATES[0]['OPTIONS']['debug'] = False
|
||||
|
||||
# Compress static files offline and minify CSS
|
||||
# http://django-compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_OFFLINE
|
||||
|
@ -87,6 +87,16 @@ else:
|
|||
}
|
||||
|
||||
|
||||
# Email via ESP
|
||||
|
||||
if 'MAILGUN_KEY' in os.environ:
|
||||
EMAIL_BACKEND = "anymail.backends.mailgun.EmailBackend"
|
||||
ANYMAIL = {
|
||||
"MAILGUN_API_KEY": env['MAILGUN_KEY'],
|
||||
"MAILGUN_SENDER_DOMAIN": env['MAILGUN_DOMAIN']
|
||||
}
|
||||
DEFAULT_FROM_EMAIL = env['MAILGUN_FROM']
|
||||
|
||||
# Redis
|
||||
# Redis location can either be passed through with REDIS_HOST or REDIS_SOCKET
|
||||
|
||||
|
@ -124,7 +134,7 @@ if REDIS_LOCATION is not None:
|
|||
if 'ELASTICSEARCH_URL' in env:
|
||||
WAGTAILSEARCH_BACKENDS = {
|
||||
'default': {
|
||||
'BACKEND': 'wagtail.wagtailsearch.backends.elasticsearch.ElasticSearch',
|
||||
'BACKEND': 'wagtail.wagtailsearch.backends.elasticsearch5',
|
||||
'URLS': [env['ELASTICSEARCH_URL']],
|
||||
'INDEX': APP_NAME,
|
||||
'ATOMIC_REBUILD': True,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Updated: 27.3.2017
|
||||
# Updated: 5.4.2017
|
||||
|
||||
# Core
|
||||
wagtail==1.9
|
||||
|
@ -12,7 +12,7 @@ dj-database-url==0.4.2
|
|||
puput==0.8
|
||||
|
||||
# Search
|
||||
elasticsearch==5.2.0
|
||||
elasticsearch>=5.0.0,<6.0.0
|
||||
|
||||
# Caching
|
||||
django-redis==4.7.0
|
||||
|
@ -29,3 +29,4 @@ stellar==0.4.3
|
|||
gunicorn==19.7.1
|
||||
whitenoise==3.3.0
|
||||
ConcurrentLogHandler==0.9.1
|
||||
django-anymail==0.9
|
||||
|
|
Loading…
Reference in a new issue