-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
79 lines (56 loc) · 2.13 KB
/
Copy pathDockerfile
File metadata and controls
79 lines (56 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
FROM python:3.12-slim AS python-base
LABEL maintainer="DesignSafe-CI <designsafe-ci@tacc.utexas.edu>"
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libgdal-dev \
ffmpeg \
curl \
git \
vim \
&& rm -rf /var/lib/apt/lists/*
# https://python-poetry.org/docs/configuration/#using-environment-variables
ENV POETRY_VERSION=2.1.4 \
POETRY_HOME="/opt/poetry" \
POETRY_VIRTUALENVS_IN_PROJECT=true \
PYSETUP_PATH="/opt/pysetup" \
VENV_PATH="/opt/pysetup/.venv"
# prepend venv and poetry to path
ENV PATH="$VENV_PATH/bin:$POETRY_HOME/bin:$PATH"
# Install poetry version $POETRY_VERSION to $POETRY_HOME
RUN pip3 install --no-cache-dir --upgrade pip setuptools wheel \
&& python3 -m venv "$POETRY_HOME" \
&& "$POETRY_HOME/bin/pip" install --no-cache-dir poetry~="$POETRY_VERSION"
# Copy project requirement files to ensure they will be cached.
WORKDIR $PYSETUP_PATH
COPY devops/poetry.lock devops/pyproject.toml ./
# install runtime deps - uses $POETRY_VIRTUALENVS_IN_PROJECT internally
RUN poetry install
RUN groupadd -g 1100 celeryuser
RUN useradd -s /sbin/nologin -u 1100 -g 1100 celeryuser
HEALTHCHECK --interval=120s --timeout=5s --start-period=60s --retries=3 \
CMD curl -fsS http://localhost:8000/status || exit 1
##############
# `development` image target is used for local development
FROM python-base AS development
# copy in our built poetry + venv
COPY --from=python-base $POETRY_HOME $POETRY_HOME
COPY --from=python-base $PYSETUP_PATH $PYSETUP_PATH
# Install dev dependencies
RUN poetry install --with dev
COPY geoapi /app/geoapi
ENV PYTHONPATH=/app
USER 1100:1100
WORKDIR /app/geoapi
##############
# `production` image target is used for deployed runtime environments
FROM python-base AS production
# Strip build-time tooling (Poetry + bundled pip/virtualenv/dulwich) and bump venv pip
RUN "$VENV_PATH/bin/pip" install --no-cache-dir --upgrade pip \
&& rm -rf "$POETRY_HOME" \
/root/.local/share/virtualenv \
/root/.cache
COPY geoapi /app/geoapi
ENV PYTHONPATH=/app
USER 1100:1100
WORKDIR /app/geoapi