From 417fbad51c1f17fbcf8cb7da1017b3e4a802e260 Mon Sep 17 00:00:00 2001
From: David Trattnig <david@subsquare.at>
Date: Thu, 8 Sep 2022 18:06:24 +0200
Subject: [PATCH] refact: build docker image using Poetry #30

---
 .dockerignore |  1 -
 Dockerfile    | 40 +++++++++++++++++++++++-----------------
 2 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/.dockerignore b/.dockerignore
index 9fcf246..e977bd3 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -1,6 +1,5 @@
 .travis.yaml
 .swagger-codegen-ignore
-README.md
 tox.ini
 git_push.sh
 test-requirements.txt
diff --git a/Dockerfile b/Dockerfile
index dd3f182..7130921 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,29 +1,35 @@
 FROM python:3.9-slim
-
 LABEL maintainer="David Trattnig <david.trattnig@subsquare.at>"
 
-# Initialize the project structure
+# System Dependencies
 
-RUN mkdir -p /srv
-RUN mkdir -p /var/log/aura
+RUN apt-get update && apt-get -y install \
+    apt-utils \
+    build-essential \
+    pip
+RUN python3 -m pip install --upgrade pip
+RUN pip install poetry
 
-# Copy sources and install
-
-COPY . /srv
-WORKDIR /srv
-RUN /usr/local/bin/python -m pip install --upgrade pip
-RUN pip3 install --no-cache-dir -r requirements.txt
-RUN pip3 install --no-cache-dir -r contrib/postgresql-requirements.txt
-ENV PYTHONPATH "${PYTHONPATH}:/srv/src"
+# Construct Image
 
-# Create default config
+RUN mkdir -p /srv
+RUN mkdir -p /srv/src
+RUN mkdir -p /srv/config
+RUN mkdir -p /var/log/aura
 
+COPY src /srv/src
 COPY ./config/sample/gunicorn/sample-docker.gunicorn.conf.py /srv/config/gunicorn.conf.py
 COPY ./config/sample/sample-docker.engine-api.ini /srv/config/engine-api.ini
+COPY pyproject.toml /srv
+COPY poetry.lock /srv
+COPY README.md /srv
+COPY Makefile /srv
 
-# Start the API Server
+WORKDIR /srv
+RUN poetry install --without dev --no-interaction
 
-EXPOSE 8008
-ENTRYPOINT ["bash"]
-CMD ["./run.sh", "prod"]
+# Start Service
 
+EXPOSE 8008
+ENTRYPOINT ["make"]
+CMD ["run"]
-- 
GitLab