-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathDockerfile
More file actions
63 lines (52 loc) · 1.58 KB
/
Copy pathDockerfile
File metadata and controls
63 lines (52 loc) · 1.58 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
61
62
63
# Stage 1: Build Vue.js frontend
FROM node:20.14.0 AS vue-builder
WORKDIR /build/openrepo
COPY frontend/ ./
RUN npm install && npm run build
# Stage 2: Build Python dependencies
FROM ubuntu:24.04 AS python-builder
RUN apt-get update && apt-get install -y \
git \
libapt-pkg-dev \
libpq-dev \
python3 \
python3-pip \
python3-venv \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /build
COPY web/requirements.txt .
RUN python3 -m venv /venv && \
/venv/bin/pip install --no-cache-dir -r requirements.txt
# Stage 3: Production runtime image
FROM ubuntu:24.04
RUN apt-get update && apt-get install -y --no-install-recommends \
apt-utils \
createrepo-c \
curl \
gnupg \
gzip \
libapt-pkg6.0 \
libpq5 \
nginx \
python3 \
&& rm -rf /var/lib/apt/lists/* \
&& ln -sf /usr/bin/createrepo_c /usr/bin/createrepo
WORKDIR /app
# Copy Python virtual environment
COPY --from=python-builder /venv /venv
ENV PATH="/venv/bin:$PATH"
# Copy compiled Vue frontend
COPY --from=vue-builder /build/openrepo/dist /app/frontend-dist
# Copy Django app
COPY web/repo/templates/base.html /tmp/base.html.check
RUN echo "=== BASE.HTML AT BUILD TIME ===" && cat /tmp/base.html.check && echo "=== END ==="
COPY web /app/django
# Copy Nginx configuration
COPY deploy/nginx/nginx.conf.prod /etc/nginx/nginx.conf
# Copy entrypoint script
COPY deploy/run_openrepoweb /usr/bin/
# Document container ports (nginx serves on 8080)
EXPOSE 8080
# Collect Django static files
RUN mkdir -p /var/lib/openrepo/packages/ && \
/venv/bin/python /app/django/manage.py collectstatic --noinput