-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
79 lines (52 loc) · 2.23 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
71
72
73
74
75
76
77
78
79
FROM python:3.11-alpine AS common
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONBUFFERED=1
RUN apk add curl
WORKDIR /var/www/static
WORKDIR /tmp/src/
COPY ./mentions ./mentions
COPY ./tests ./tests
COPY ./pyproject.toml .
COPY ./requirements.txt .
COPY ./setup.cfg .
COPY ./runtests.py .
RUN --mount=type=cache,target=/root/.cache/pip pip install -r /tmp/src/requirements.txt
RUN python /tmp/src/runtests.py
WORKDIR /project
COPY ./sample-project/requirements.txt /project
RUN --mount=type=cache,target=/root/.cache/pip pip install -r /project/requirements.txt
# Pass a random CACHEBUST value to ensure data is updated and not taken from cache.
ARG CACHEBUST=0
RUN echo "CACHEBUST: $CACHEBUST"
WORKDIR /project
COPY ./sample-project/docker/entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
################################################################################
FROM common AS with_celery
# Install extra dependencies but remove our package - will be mounted in compose
# to allow Django runserver to reload on code changes.
RUN --mount=type=cache,target=/root/.cache/pip pip install -e /tmp/src[celery,test]
RUN pip uninstall -y django-wm
RUN rm -r /tmp/src
CMD ["python", "manage.py", "sample_app_init"]
################################################################################
FROM common AS with_wagtail
# Install extra dependencies but remove our package - will be mounted in compose
# to allow Django runserver to reload on code changes.
RUN --mount=type=cache,target=/root/.cache/pip pip install -e /tmp/src[wagtail,test]
RUN pip uninstall -y django-wm
RUN rm -r /tmp/src
CMD ["python", "manage.py", "wagtail_app_init"]
################################################################################
FROM with_celery AS with_celery_celery
ENTRYPOINT celery -A sample_project worker -l info
################################################################################
FROM with_celery AS with_celery_cron
COPY ./sample-project/docker/with-celery/cron-schedule /
RUN crontab /cron-schedule
ENTRYPOINT crond -l 2 -f
################################################################################
FROM with_wagtail AS with_wagtail_cron
COPY ./sample-project/docker/with-wagtail/cron-schedule /
RUN crontab /cron-schedule
ENTRYPOINT crond -l 2 -f