From c4887530f8ececad37de5f03b90366b6492c7e21 Mon Sep 17 00:00:00 2001 From: Gertjan van den Burg Date: Wed, 27 Mar 2019 13:45:47 +0000 Subject: add initial deployment files --- Dockerfile | 37 +++++++++++++++++++++++++++++++++++++ boot.sh | 10 ++++++++++ docker-compose.yml | 19 +++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 Dockerfile create mode 100644 boot.sh create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6b34919 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,37 @@ +FROM python:3.6-alpine + +RUN adduser -D annotatechange + +WORKDIR /home/annotatechange + +# See: https://stackoverflow.com/q/53835198/ +ARG YOUR_ENV +ENV YOUR_ENV=${YOUR_ENV} \ + PYTHONFAULTHANDLER=1 \ + PYTHONUNBUFFERED=1\ + PYTHONHASHSEED=random \ + PIP_NO_CACHE_DIR=off \ + PIP_DIABLE_PIP_VERSION_CHECK=on \ + PIP_DEFAULT_TIMEOUT=100 \ + POETRY_VERSION=0.12.11 + +RUN pip install "poetry==$POETRY_VERSION" + +COPY poetry.lock pyproject.toml /home/annotatechange + +RUN poetry config settings.virtualenvs.create false \ + && poetry install $(test "$YOUR_ENV" == production && echo "--no-dev") \ + --no-interaction --no-ansi + +COPY app app +COPY migrations migrations +COPY annotate_change.py config.py boot.sh ./ +RUN chmod +x boot.sh + +ENV FLASK_APP annotate_change.py + +RUN chown -R annotate_change:annotate_change ./ +USER annotate_change + +EXPOSE 5000 +ENTRYPOINT ["./boot.sh"] diff --git a/boot.sh b/boot.sh new file mode 100644 index 0000000..9d50eef --- /dev/null +++ b/boot.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +# Activate the virtual environment +poetry shell + +# Run database migrations +flask db upgrade + +exec gunicorn -b :5000 --access-logfile - --error-logfile - annotate_change:app + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..1fe447c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,19 @@ +version: '3' + +services: + annotatechange: + build: . + labels: + - "traefik.backend=annotatechange" + - "traefik.docker.network=web" + - "traefik.frontend.rule=Host:change.gertjanvandenburg.com" + - "traefik.port=80" + networks: + - web + volumes: + - ./persist/instance:/home/annotatechange/instance + - ./persist/mysql:/home/annotatechange/mysql + +networks: + web: + external: true -- cgit v1.2.3