-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (48 loc) · 2.14 KB
/
Copy pathDockerfile
File metadata and controls
60 lines (48 loc) · 2.14 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
# Stage 1 — build the Vite SPA. Output ends up at /app/frontend/dist/
# and is copied into the Django app stage so collectstatic can pick it
# up via STATICFILES_DIRS. In dev (docker-compose.yml) the Vite dev
# server runs as a separate service for HMR; this stage only matters
# for production images where Django serves the built bundle.
FROM node:20-alpine AS frontend-build
WORKDIR /app/frontend
COPY frontend/package*.json ./
RUN npm ci
COPY frontend/ ./
RUN npm run build
FROM python:3.12 AS app
LABEL maintainer "DataMade <info@datamade.us>"
RUN apt-get update && \
apt-get install -y --no-install-recommends --purge postgresql-client gdal-bin cron logrotate moreutils && \
apt-get autoclean && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /tmp/*
RUN mkdir /app
WORKDIR /app
COPY ./requirements.txt /app/requirements.txt
RUN pip install -r requirements.txt
COPY . /app
# Restore the executable bit on shell scripts. Files committed from
# Windows often land in git with mode 644 because `core.fileMode`
# defaults to false there; the Linux container's OCI runtime then
# refuses to exec them. Doing this in the image avoids a per-deploy
# manual `chmod +x` on the host.
RUN chmod +x /app/docker-entrypoint.sh /app/scripts/*.sh
# Pull the production-built SPA from the node stage so the image
# contains a real `frontend/dist/` regardless of the host's state.
# In dev compose this gets shadowed by the source-mount volume — the
# developer runs `npm run build` (or uses Vite's :5173 dev server)
# instead.
COPY --from=frontend-build /app/frontend/dist /app/frontend/dist
ENV DJANGO_SECRET_KEY 'foobar'
RUN python manage.py collectstatic --no-input
# Set up cron
COPY scheduler-crontab /etc/cron.d/scheduler-crontab
RUN chmod 0644 /etc/cron.d/scheduler-crontab && \
crontab /etc/cron.d/scheduler-crontab && \
mkdir -p /var/log/cron && \
touch /var/log/cron/sync.log
# logrotate config for the cron log (#205) — 30-day retention. Triggered by a
# daily crontab line; copytruncate keeps the entrypoint's `tail -f` working.
COPY scheduler-logrotate /etc/logrotate.d/sync-log
RUN chmod 0644 /etc/logrotate.d/sync-log
ENTRYPOINT ["/app/docker-entrypoint.sh"]