-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
40 lines (29 loc) · 903 Bytes
/
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
FROM golang:1.22 AS build-stage
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY *.go ./
COPY data/ ./data/
COPY lib/ ./lib/
COPY types/ ./types/
COPY routes/ ./routes/
COPY templates/ ./templates/
COPY js/ ./js/
COPY css/ ./css/
COPY images/ ./images/
RUN CGO_ENABLED=1 GOOS=linux go build -o /server -a -ldflags '-linkmode external -extldflags "-static"' *.go
# Run the tests in the container
FROM build-stage AS run-test-stage
RUN go test -v ./...
# Deploy the application binary into a lean image
FROM alpine AS build-release-stage
WORKDIR /
RUN apk --no-cache add --no-check-certificate ca-certificates \
&& update-ca-certificates
COPY --from=build-stage /server /server
COPY --from=build-stage /app/templates /templates
COPY --from=build-stage /app/js /js
COPY --from=build-stage /app/css /css
COPY --from=build-stage /app/images /images
EXPOSE 3333
ENTRYPOINT ["/server"]