-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeb.Dockerfile
More file actions
71 lines (54 loc) · 1.68 KB
/
Web.Dockerfile
File metadata and controls
71 lines (54 loc) · 1.68 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
64
65
66
67
68
69
70
71
# This Dockerfile builds an image that serves the web backend and frontend together.
# The frontend is served by nginx on port 8080 and the backend binary is simply run.
####################
# Build Go backend #
####################
FROM golang:1.25-trixie AS backend-builder
WORKDIR /build
# Retrieve application dependencies.
# This allows the container build to reuse cached dependencies.
COPY go.* ./
RUN go mod download
# Copy in code.
COPY aqi aqi/
COPY cache cache/
COPY database database/
COPY federatedidentity federatedidentity/
COPY graph/ graph
COPY measurement measurement/
COPY measurementpb measurementpb/
COPY measurementpbutil measurementpbutil/
COPY web web/
RUN mkdir out
RUN CGO_ENABLED=0 GOOS=linux go build -v -o out ./web/...
######################
# Build React client #
######################
FROM node:24-trixie AS client-builder
COPY client /app
WORKDIR /app
# Clean before building.
RUN rm -rf .react-router build node_modules
RUN npm ci
RUN npm run lint
RUN npm run build
#######
# Run #
#######
FROM nginx:trixie
RUN set -x && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
ca-certificates tini && \
rm -rf /var/lib/apt/lists/*
COPY --from=client-builder /app/build/client /app
COPY --from=backend-builder /build/out/web /serve
# Copy in resources required at runtime.
COPY --from=backend-builder /build/web/templates /web/templates
COPY nginx.conf.template /etc/nginx/templates/default.conf.template
COPY start.sh /start.sh
RUN chmod +x /start.sh
# Use tini for its signal forwarding and zombie reaping functionality.
ENTRYPOINT ["/usr/bin/tini", "--"]
EXPOSE 8080
ENV BACKEND_HOST http://127.0.0.1
ENV BACKEND_PORT 3001
CMD ["/start.sh"]