From 70fcc42a6bb21528509ddbb9ba412616fca2d40f Mon Sep 17 00:00:00 2001 From: FireMasterK <20838718+FireMasterK@users.noreply.github.com> Date: Tue, 8 Sep 2020 12:46:57 +0530 Subject: [PATCH 1/2] Alpine based docker image. --- Dockerfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 177ce04..de211b8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,12 @@ -FROM python:3 +FROM python:alpine WORKDIR /usr/src/app +RUN apk add gcc musl-dev libffi-dev openssl-dev libxml2-dev libxslt-dev file llvm-dev make g++ + COPY requirements.txt ./ + +RUN pip install wheel cryptography gunicorn pymysql RUN pip install --no-cache-dir -r requirements.txt COPY . . @@ -11,5 +15,5 @@ RUN flask db init \ && flask db migrate\ && flask db upgrade -CMD [ "flask", "run", "--host", "0.0.0.0" ] +CMD [ "gunicorn", "-b", "0.0.0.0:5000", "-w", "4", "yotter:app" ] EXPOSE 5000 From 8caf9d47637a56f92780d965c5e6fdb12204efc5 Mon Sep 17 00:00:00 2001 From: FireMasterK <20838718+FireMasterK@users.noreply.github.com> Date: Tue, 8 Sep 2020 18:15:10 +0530 Subject: [PATCH 2/2] Add a production capable docker-compose file. --- .dockerignore | 5 +++++ Dockerfile | 6 ++++-- docker-compose.yml | 28 ++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore index 331d387..ae61f74 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,7 @@ .git +.gitignore Dockerfile +docker-compose.yml +LICENSE +*.md +yotter-config.json diff --git a/Dockerfile b/Dockerfile index de211b8..a09eafd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,8 +12,10 @@ RUN pip install --no-cache-dir -r requirements.txt COPY . . RUN flask db init \ - && flask db migrate\ + && flask db migrate \ && flask db upgrade -CMD [ "gunicorn", "-b", "0.0.0.0:5000", "-w", "4", "yotter:app" ] +CMD flask db upgrade \ + && gunicorn -b 0.0.0.0:5000 -w 4 yotter:app + EXPOSE 5000 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..44c391f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,28 @@ +version: '3.4' +services: + mariadb: + image: mariadb:latest + environment: + MYSQL_ROOT_PASSWORD: changeme + MYSQL_DATABASE: yotter + MYSQL_USER: yotter + MYSQL_PASSWORD: changeme + restart: on-failure + volumes: + - /var/lib/mysql + healthcheck: + test: ["CMD", "mysqladmin", "ping", "--silent"] + yotter: + image: yotter + restart: unless-stopped + ports: + - "127.0.0.1:5000:5000" + environment: + DATABASE_URL: mysql+pymysql://yotter:changeme@mariadb:3306/yotter + depends_on: + - mariadb + ports: + - "5000:5000" + volumes: + - /usr/src/app/migrations + - ./yotter-config.json:/usr/src/app/yotter-config.json