-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
64 lines (49 loc) · 1.89 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
########################################################################
# Static files
########################################################################
FROM node:20 AS static
LABEL maintainer="Jonas Drotleff <j.drotleff@desk-lab.de>"
WORKDIR /usr/src/gcampus
COPY package*.json ./
RUN npm ci --include=dev
COPY . .
RUN npm run build && rm -rf gcampus/*/static_src package*.json node_modules
########################################################################
# gcampus Dockerfile
########################################################################
FROM python:3.12-slim-bookworm
LABEL maintainer="Jonas Drotleff <j.drotleff@desk-lab.de>"
SHELL ["/bin/sh", "-eux", "-c"]
ENV VIRTUAL_ENV=/home/gcampus/venv
ENV DJANGO_SETTINGS_MODULE gcampus.settings.prod
ENV DEBIAN_FRONTEND=noninteractive
USER root
########################################################################
# Setup GCampus
########################################################################
# Install gdal and libproj-dev
RUN apt-get update && apt-get -y upgrade && \
apt-get install -y --no-install-recommends --no-install-suggests \
binutils \
libgdal32 \
libpango-1.0-0 \
libpangoft2-1.0-0 \
libproj25 && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /var/log
# Create gcampus user
RUN useradd --create-home gcampus
USER gcampus
WORKDIR /home/gcampus
# Copy requirements.txt file
COPY --from=static --chown=gcampus /usr/src/gcampus/requirements.txt ./requirements.txt
# Create venv for gcampus
RUN python3 -m venv ${VIRTUAL_ENV}
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# Install requirements
RUN pip install --disable-pip-version-check --no-cache-dir -r requirements.txt
COPY --from=static --chown=gcampus /usr/src/gcampus ./
RUN GCAMPUS_ALLOWED_HOSTS="" python manage.py collectstatic --no-input && rm -rf gcampus/*/static
RUN chmod +x ./docker-entrypoint.sh
EXPOSE 8000
ENTRYPOINT ["./docker-entrypoint.sh"]