-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile.pytest
69 lines (52 loc) · 1.67 KB
/
Dockerfile.pytest
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
###############
# Build on Python-based image using default target platform (TARGETPLATFORM).
FROM python:3.12-bookworm
ARG TARGETPLATFORM
ARG TARGETARCH
RUN echo "Building for ${TARGETPLATFORM} platform..."
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# Note: Set the ENV and DJANGO_SETTINGS_MODULE env vars via docker compose to
# permit flexible image use.
###############
# Install OS packages.
RUN apt-get update -qqy --fix-missing && \
apt-get install -qqy --no-install-recommends \
build-essential \
ca-certificates \
curl \
g++ \
git \
libmagic1 \
postgresql-client
###############
# Download and setup Node.
ENV NODE_VERSION="v20.10.0"
RUN if [ "$TARGETARCH" = "arm64" ]; then \
NODE_ARCH="linux-arm64"; \
elif [ "$TARGETARCH" = "amd64" ]; then \
NODE_ARCH="linux-x64"; \
else \
echo "Unsupported node binary package platform architecture: ${TARGETARCH}"; \
exit 1; \
fi \
&& NODE_NAME="node-${NODE_VERSION}-${NODE_ARCH}" \
&& curl "https://nodejs.org/dist/${NODE_VERSION}/${NODE_NAME}.tar.gz" -O \
&& tar xzf "${NODE_NAME}.tar.gz" \
&& ln -s "/${NODE_NAME}/bin/node" /usr/local/bin/node \
&& ln -s "/${NODE_NAME}/bin/npm" /usr/local/bin/npm \
&& ln -s "/${NODE_NAME}/bin/npx" /usr/local/bin/npx
###############
# Install Node packages and Python packages.
WORKDIR /app
COPY package.json /app/
COPY package-lock.json /app/
RUN npm install
COPY requirements.txt /app/
RUN pip install --upgrade pip
RUN pip install -r requirements.txt --no-warn-script-location
COPY . /app/
###############
# Build static assets.
RUN npm run build
RUN python manage.py collectstatic --noinput