feat(base-app): Add docker setup
Adding a dockerfile as well as an `entrypoint.sh` file for deployment using `gunicorn`.
This commit is contained in:
5
.docker/entrypoint.sh
Normal file
5
.docker/entrypoint.sh
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Start Dash and run in background
|
||||||
|
echo "Starting Dash app..."
|
||||||
|
poetry run gunicorn app:server -b 0.0.0.0:8000
|
||||||
45
Dockerfile
Normal file
45
Dockerfile
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
ARG PYTHON_VERSION_TAG=3.12
|
||||||
|
ARG PYTHON_VARIANT_TAG=slim
|
||||||
|
|
||||||
|
# Use official Python image as base
|
||||||
|
# ${PYTHON_VARIANT_TAG:+-${PYTHON_VARIANT_TAG}} is a conditional expansion
|
||||||
|
# that adds a dash before the variant tag if it is not empty
|
||||||
|
FROM python:${PYTHON_VERSION_TAG}${PYTHON_VARIANT_TAG:+-${PYTHON_VARIANT_TAG}}
|
||||||
|
|
||||||
|
# Set up poetry environment
|
||||||
|
ARG POETRY_VERSION=1.8.3
|
||||||
|
|
||||||
|
ENV POETRY_HOME=/opt/poetry
|
||||||
|
ENV POETRY_VENV=/opt/poetry-venv
|
||||||
|
ENV POETRY_CACHE_DIR=/opt/.cache
|
||||||
|
|
||||||
|
# Install poetry separated from system interpreter
|
||||||
|
RUN python3 -m venv $POETRY_VENV \
|
||||||
|
&& $POETRY_VENV/bin/pip install -U pip setuptools \
|
||||||
|
&& $POETRY_VENV/bin/pip install poetry==${POETRY_VERSION}
|
||||||
|
|
||||||
|
# Add `poetry` to PATH
|
||||||
|
ENV PATH="${POETRY_VENV}/bin:${PATH}"
|
||||||
|
|
||||||
|
RUN poetry config virtualenvs.in-project true
|
||||||
|
|
||||||
|
# Export in first position so that "python" calls are from .venv
|
||||||
|
ENV PATH="/app/.venv/bin:${PATH}"
|
||||||
|
ENV PYTHONPATH="/app/:${PYTHONPATH}"
|
||||||
|
|
||||||
|
COPY pyproject.toml .
|
||||||
|
COPY poetry.lock .
|
||||||
|
COPY app/ app/
|
||||||
|
|
||||||
|
RUN poetry install --no-interaction --no-dev
|
||||||
|
|
||||||
|
COPY ./.docker/entrypoint.sh /app/entrypoint.sh
|
||||||
|
RUN chmod +x /app/entrypoint.sh
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
EXPOSE 8000
|
||||||
|
|
||||||
|
ENTRYPOINT ["./entrypoint.sh"]
|
||||||
Reference in New Issue
Block a user