2023-01-30 15:18:17 +00:00
# Base image to share ENV vars that activate VENV.
2024-01-29 19:09:36 +00:00
FROM python:3.12.1-slim-bookworm AS base
2023-01-30 15:18:17 +00:00
ENV VIRTUAL_ENV = /app/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH = " $VIRTUAL_ENV /bin: $PATH "
WORKDIR /app
2023-11-16 15:18:11 +00:00
######################## - DEPLOYMENT
2023-01-31 21:14:22 +00:00
# base plus packages needed for deployment. Could just install these in final, but then we can't cache as much.
2023-02-22 20:16:13 +00:00
# vim is just for debugging
2023-01-31 21:14:22 +00:00
FROM base AS deployment
2023-10-19 18:22:52 +00:00
# git-core because the app does "git commit", etc
# curl because the docker health check uses it
2023-11-16 15:18:11 +00:00
# procps because it is useful for debugging
2023-10-19 18:22:52 +00:00
# gunicorn3 for web server
# default-mysql-client for convenience accessing mysql docker container
# vim ftw
2024-05-03 17:50:42 +00:00
# jq because it is really useful, even for scenarios where people might have environment variables with json values they might need to use for configs. about 1MB.
2024-07-14 20:31:39 +00:00
# libpq5 in order to be able to use postgres at runtime
2023-01-31 21:14:22 +00:00
RUN apt-get update \
2024-05-03 17:50:42 +00:00
&& apt-get clean -y \
2024-07-17 01:12:46 +00:00
&& apt-get install -y -q git-core curl procps gunicorn3 default-mysql-client vim-tiny jq libpq5 \
2024-05-03 17:50:42 +00:00
&& rm -rf /var/lib/apt/lists/*
2023-01-31 21:14:22 +00:00
2023-12-08 18:32:49 +00:00
# keep pip up to date
RUN pip install --upgrade pip
2024-02-28 14:49:45 +00:00
RUN pip install poetry = = 1.8.1
2023-10-19 18:22:52 +00:00
2023-11-16 15:18:11 +00:00
######################## - SETUP
2023-01-30 15:18:17 +00:00
# Setup image for installing Python dependencies.
FROM base AS setup
2022-10-12 14:22:22 +00:00
2023-03-06 21:16:55 +00:00
# poetry 1.4 seems to cause an issue where it errors with
# This error originates from the build backend, and is likely not a
# problem with poetry but with lazy-object-proxy (1.7.1) not supporting PEP 517 builds.
# You can verify this by running 'pip wheel --use-pep517 "lazy-object-proxy (==1.7.1) ; python_version >= "3.6""'.
# Pinnning to 1.3.2 to attempt to avoid it.
2023-10-19 18:22:52 +00:00
RUN pip install poetry = = 1.6.1
2022-10-12 14:22:22 +00:00
RUN useradd _gunicorn --no-create-home --user-group
2023-07-12 14:14:49 +00:00
# default-libmysqlclient-dev for mysqlclient lib
2024-07-14 20:31:39 +00:00
# libpq-dev in order to be able to poetry install postgres lib, psycopg2. See also libpq5 above in deployment image.
2023-01-30 15:18:17 +00:00
RUN apt-get update \
2024-05-03 17:50:42 +00:00
&& apt-get install -y -q gcc libssl-dev libpq-dev default-libmysqlclient-dev pkg-config libffi-dev
2022-10-12 14:22:22 +00:00
2023-02-01 12:53:35 +00:00
# poetry install takes a long time and can be cached if dependencies don't change,
# so that's why we tolerate running it twice.
COPY pyproject.toml poetry.lock /app/
RUN poetry install --without dev
2023-01-30 15:18:17 +00:00
COPY . /app
2022-11-09 20:45:49 +00:00
RUN poetry install --without dev
2022-10-12 14:22:22 +00:00
2023-11-16 15:18:11 +00:00
######################## - FINAL
2023-01-30 15:18:17 +00:00
# Final image without setup dependencies.
2023-01-31 21:14:22 +00:00
FROM deployment AS final
2022-10-12 14:22:22 +00:00
2023-11-20 21:49:30 +00:00
LABEL source = "https://github.com/sartography/spiff-arena/spiffworkflow-backend"
2023-05-13 23:53:50 +00:00
LABEL description = "Backend component of SpiffWorkflow, a software development platform for building, running, and monitoring executable diagrams"
2022-10-12 14:22:22 +00:00
2023-01-30 15:18:17 +00:00
COPY --from= setup /app /app
2022-10-12 14:22:22 +00:00
2023-01-31 21:14:22 +00:00
CMD [ "./bin/boot_server_in_docker" ]