-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
52 lines (32 loc) · 1.18 KB
/
Dockerfile
File metadata and controls
52 lines (32 loc) · 1.18 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
FROM golang:1.24.0-alpine AS builder
RUN apk add --no-cache build-base=0.5-r3 postgresql15-dev=15.13-r0
RUN addgroup -S nonroot \
&& adduser -S nonroot -G nonroot
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY src ./src
# Disables CGO and specifies the name for the compiled application as app
RUN CGO_ENABLED=1 GOOS=linux go build -o app ./src/backend
FROM alpine:3.21.3
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
# Install Node.js, npm, and PostgreSQL client without pinning versions
# Version pinning causes conflicts across Alpine updates, so we accept latest stable
# hadolint ignore=DL3018
RUN apk add --no-cache nodejs npm postgresql15-client
RUN addgroup -S nonroot \
&& adduser -S nonroot -G nonroot
WORKDIR /app
COPY --from=builder /app/app /app/app
COPY src /app/src
COPY src/frontend /app/src/frontend
COPY knex-migrations /app/knex-migrations
WORKDIR /app/knex-migrations
RUN npm ci --only=production
COPY entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
RUN mkdir -p /app/src/backend/backups && chown -R nonroot:nonroot /app/src/backend/backups
WORKDIR /app/src/backend
USER nonroot
EXPOSE 8080
ENTRYPOINT ["/app/entrypoint.sh"]