Add a multi stage docker file for deploy
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
e32b1acb58
commit
5e267657ae
15
.dockerignore
Normal file
15
.dockerignore
Normal file
|
@ -0,0 +1,15 @@
|
|||
.git
|
||||
.dockerignore
|
||||
.gitignore
|
||||
.drone.yml
|
||||
.editorconfig
|
||||
.envrc
|
||||
.flake8
|
||||
dist/
|
||||
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
.pytest_cache/
|
||||
.venv
|
||||
venv
|
31
Dockerfile
Normal file
31
Dockerfile
Normal file
|
@ -0,0 +1,31 @@
|
|||
FROM python:3.9-slim-buster as base
|
||||
|
||||
ENV PYTHONUNBUFFERED=1 \
|
||||
PYTHONDONTWRITEBYTECODE=1
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
FROM base as builder
|
||||
|
||||
ENV PIP_DEFAULT_TIMEOUT=100 \
|
||||
PIP_NO_CACHE_DIR=off \
|
||||
POETRY_VERSION=1.1.4 \
|
||||
GUNICORN_VERSION=20.1.0
|
||||
|
||||
RUN pip install "poetry==$POETRY_VERSION" \
|
||||
&& python -m venv /venv
|
||||
|
||||
COPY pyproject.toml poetry.lock ./
|
||||
RUN poetry export -f requirements.txt | /venv/bin/pip install -r /dev/stdin \
|
||||
&& /venv/bin/pip install "gunicorn==$GUNICORN_VERSION"
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN poetry build && /venv/bin/pip install dist/*.whl
|
||||
|
||||
FROM base as final
|
||||
|
||||
COPY --from=builder /venv /venv
|
||||
COPY extra/entrypoint.sh ./
|
||||
|
||||
CMD ["./entrypoint.sh"]
|
13
extra/entrypoint.sh
Executable file
13
extra/entrypoint.sh
Executable file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
. /venv/bin/activate
|
||||
|
||||
poetrybot &
|
||||
|
||||
exec gunicorn --log-file=- \
|
||||
--worker-tmp-dir /dev/shm \
|
||||
--bind 0.0.0.0:5000 \
|
||||
--forwarded-allow-ips='*' \
|
||||
poetrybot.web.wsgi:app
|
|
@ -1,5 +1,6 @@
|
|||
from .application import create_app
|
||||
|
||||
app = create_app()
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = create_app()
|
||||
app.run()
|
||||
|
|
Loading…
Reference in a new issue