forked from CenterForOpenScience/gravyvalet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
70 lines (53 loc) · 1.9 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
59
60
61
62
63
64
65
66
67
68
69
70
# Use the official Python image AS the base image
FROM python:3.12 AS gv-base
# System Dependencies:
RUN apt-get update && apt-get install -y libpq-dev
COPY pyproject.toml /code/
COPY poetry.lock /code/
WORKDIR /code
ENV PATH="$PATH:/root/.local/bin"
# END gv-base
# BEGIN gv-runtime-base
FROM python:3.12-slim AS gv-runtime-base
# System Dependencies:
RUN apt-get update && apt-get install -y libpq-dev
COPY pyproject.toml /code/
COPY poetry.lock /code/
WORKDIR /code
ENV PATH="$PATH:/root/.local/bin"
# END gv-runtime-base
# BEGIN gv-dev-deps
FROM gv-base AS gv-dev-deps
# install dev and non-dev dependencies:
RUN curl -sSL https://install.python-poetry.org | python3 - --version 1.8.3
RUN python -m venv .venv
RUN poetry install --without release
# END gv-dev-deps
# BEGIN gv-dev
FROM gv-runtime-base AS gv-dev
COPY --from=gv-dev-deps /code/.venv/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY . /code/
# Start the Django development server
CMD ["python", "manage.py", "runserver", "0.0.0.0:8004"]
# END gv-dev
# BEGIN gv-docs
FROM gv-dev AS gv-docs
RUN python -m gravyvalet_code_docs.build
# END gv-docs
# BEGIN gv-deploy-deps
FROM gv-base AS gv-deploy-deps
# install non-dev and release-only dependencies:
RUN curl -sSL https://install.python-poetry.org | python3 - --version 1.8.3
RUN python -m venv .venv
RUN poetry install --without dev
# copy auto-generated static docs (without the dev dependencies that built them)
COPY --from=gv-docs /code/addon_service/static/gravyvalet_code_docs/ /code/addon_service/static/gravyvalet_code_docs/
# collect static files into a single directory:
# ENF gv-deploy-deps
# BEGIN gv-deploy
FROM gv-runtime-base AS gv-deploy
COPY --from=gv-deploy-deps /code/.venv/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY . /code/
RUN python manage.py collectstatic --noinput
# note: no CMD in gv-deploy -- depends on deployment
# END gv-deploy