-
Notifications
You must be signed in to change notification settings - Fork 1
/
DockerfileBuild
79 lines (64 loc) · 2.47 KB
/
DockerfileBuild
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.10-slim as backend-builder
ARG DROP_BACKEND_DIR
ARG HERENOW_DEMO_DIR
ENV DEBIAN_FRONTEND=noninteractive
# I was worried about how to get the poetry version for the python version that is installed in the base image.
# Turns out I can get the poetry version for the given python version that is
# installed per https://python-poetry.org/docs/managing-environments/
ENV PIP_DEFAULT_TIMEOUT=100 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1 \
POETRY_VERSION=1.5.1
RUN apt-get update && apt-get install -y --no-install-recommends \
git gcc g++ git sqlite3 musl-dev \
&& rm -rf /var/lib/apt/lists/*
# Experimenting with alpine
# RUN apk add --no-cache --virtual .build-deps \
# openssl-dev openssl gcc g++ git sqlite linux-headers musl-dev libffi-dev geos-dev cargo curl automake\
# && rm -rf /var/lib/apt/lists/*
RUN pip3 install "poetry==$POETRY_VERSION"
COPY ${DROP_BACKEND_DIR}/pyproject.toml /backend/
COPY ${DROP_BACKEND_DIR}/poetry.lock /backend/
WORKDIR /backend
RUN touch README.md
COPY ${DROP_BACKEND_DIR}/src /backend/src
RUN poetry check
RUN poetry build
RUN bash -c "ls -lart /backend/dist || true"
# RUN pip install /backend/dist/*.whl
# TODO: export using poetry from docker container?
# Second stage: build the app based on the backend
FROM backend-builder as app-builder
WORKDIR /app
COPY ${HERENOW_DEMO_DIR}/pyproject.toml /app/
COPY ${HERENOW_DEMO_DIR}/poetry.lock /app/
COPY ${HERENOW_DEMO_DIR}/src /app/src
RUN chmod +x /app/src/${HERENOW_DEMO_DIR}/configure_demo.py
# Updates the version of backend in the demo app
RUN python /app/src/${HERENOW_DEMO_DIR}/configure_demo.py --backend-dist-dir /backend/dist --app-dir /app
RUN touch README.md
COPY drop.db /app/
RUN poetry check
RUN poetry build
RUN pip install /app/dist/herenow_demo-*.whl
# just to test
FROM app-builder as app-tester
EXPOSE 8000
ARG SQLITE_DB_PATH
ARG RELOAD_WEBAPP
ARG SECRET_KEY
ARG ORS_API_ENDPOINT
ARG ALLOWED_ORIGINS
ARG FILE_VERSION_CONSTRAINTS
ENV SQLITE_DB_PATH=${SQLITE_DB_PATH} \
RELOAD_WEBAPP=${RELOAD_WEBAPP} \
SECRET_KEY=${SECRET_KEY} \
ORS_API_ENDPOINT=${ORS_API_ENDPOINT} \
ALLOWED_ORIGINS=${ALLOWED_ORIGINS} \
FILE_VERSION_CONSTRAINTS=${FILE_VERSION_CONSTRAINTS}
EXPOSE 8000
WORKDIR /app
ENTRYPOINT ["gunicorn", "herenow_demo.main:app"]
CMD ["--bind", "0.0.0.0:8000", "--workers", "1", "--worker-class", "uvicorn.workers.UvicornWorker"]
# TODO We now run the part that can publish the version in the app;
# This process is manual right now.