-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile
58 lines (40 loc) · 1.53 KB
/
Dockerfile
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
#
# SPDX-FileCopyrightText: 2019-2022 Alliander N.V.
# SPDX-License-Identifier: MPL-2.0
#
FROM python:3.10.14-bullseye AS base-image
RUN apt-get update && \
apt-get -y install libeccodes-dev && \
apt-get -y install libeccodes-tools && \
apt-get clean
ENV ECCODES_DIR=/usr/src/eccodes
ENV ECMWFLIBS_ECCODES_DEFINITION_PATH=/usr/src/eccodes/share/eccodes/definitions
ARG APP_HOME=/app
RUN pip install poetry
# Setup WPLA user and switch to WPLA user
ARG APP_USER=wpla-user
RUN groupadd --system "$APP_USER" && \
useradd --system --gid "$APP_USER" --create-home --home "$APP_HOME" "$APP_USER"
WORKDIR $APP_HOME
USER $APP_USER
COPY --chown=$APP_USER:$APP_USER ./pyproject.toml ./pyproject.toml
COPY --chown=$APP_USER:$APP_USER ./weather_provider_api ./weather_provider_api
COPY --chown=$APP_USER:$APP_USER ./var_maps ./var_maps
RUN poetry config virtualenvs.in-project true && \
poetry install --no-interaction --no-ansi -v --no-root
ENV PATH="$APP_HOME/.venv/bin:$PATH"
# --- DEV image --
FROM base-image AS dev-image
# TODO: Hookup SSH interface
USER $APP_USER
CMD ["ls", "-l"]
# --- UVICORN image --
FROM base-image AS uvicorn-image
USER $APP_USER
EXPOSE 8000
CMD ["uvicorn", "--reload", "--host", "0.0.0.0", "--port", "8000", "weather_provider_api.core.application:WPLA_APPLICATION" ]
# --- GUNICORN image --
FROM base-image AS gunicorn-image
USER $APP_USER
EXPOSE 8000
CMD ["gunicorn", "-k", "uvicorn.workers.UvicornWorker", "-b", "0.0.0.0:8000", "weather_provider_api.core.application:WPLA_APPLICATION", "--timeout", "180"]