Switch to docker so can use mjml easily

This commit is contained in:
Seb 2020-05-27 09:35:13 +10:00
parent 12a6cd119d
commit 7b8fc5fe18
6 changed files with 61 additions and 24 deletions

9
.dockerignore Normal file
View File

@ -0,0 +1,9 @@
var/
venv/
*.egg-info/
dist/
.idea
.DS_Store
.vscode
build/
__pycache__/

2
.gitignore vendored
View File

@ -1,9 +1,7 @@
var/
venv/
*.egg-info/
node_modules/
dist/
birdsongtestbed/static
*.pyc
*.local
.tmp

20
Dockerfile.dev Normal file
View File

@ -0,0 +1,20 @@
FROM python:3.6
WORKDIR /srv
ENV PYTHONUNBUFFERED=1 \
PYTHONIOENCODING=UTF-8 \
PYTHONDONTWRITEBYTECODE=1 \
LC_ALL=C.UTF-8 \
LANG=C.UTF-8 \
PYTHONPATH=/srv/ \
DJANGO_SETTINGS_MODULE=settings_dev \
DJANGO_SUPERUSER_PASSWORD=p
COPY . /srv/
RUN pip install -e .
RUN django-admin migrate
RUN django-admin createsuperuser --no-input --username admin --email admin@email.com
CMD [ "django-admin" , "runserver", "0.0.0.0:8080"]

26
docker-compose.yml Normal file
View File

@ -0,0 +1,26 @@
version: "3"
services:
birdsong:
build:
context: .
dockerfile: Dockerfile.dev
restart: always
command: django-admin runserver 0.0.0.0:8080
links:
- mjml
ports:
- "8080:8080"
container_name: 'birdsong_dev'
working_dir: '/srv'
volumes:
- './tests:/srv/tests'
- './birdsong:/srv/birdsong'
- './settings_dev.py:/srv/settings_dev.py'
# - './local.sqlite3:/srv/local.sqlite3'
mjml:
image: liminspace/mjml-tcpserver:latest
restart: always
ports:
- "28101"

View File

@ -1,21 +0,0 @@
#!/usr/bin/env python3.6
import os
import shutil
import sys
def run():
from django.core.management import execute_from_command_line
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings_dev'
args = sys.argv[:]
if len(args) == 2 and sys.argv[1] == 'runserver':
# Default to serving externally if not told otherwise
args = sys.argv + ['0.0.0.0:8080']
execute_from_command_line(args)
if __name__ == '__main__':
run()

View File

@ -8,4 +8,9 @@ DATABASES = {
},
}
ALLOWED_HOSTS = ['*']
ALLOWED_HOSTS = ['*']
MJML_BACKEND_MODE = 'tcpserver'
MJML_TCPSERVERS = [
('mjml', 28101), # host and port
]