-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
43 lines (25 loc) · 749 Bytes
/
Dockerfile
File metadata and controls
43 lines (25 loc) · 749 Bytes
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
FROM golang:1.24-bullseye AS build-base
WORKDIR /app
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go mod download
FROM build-base AS build-production
RUN useradd -u 1001 nonroot
COPY . .
RUN go build \
-ldflags="-linkmode external -extldflags -static" \
-tags netgo \
-o todo-api ./cmd/todo-api/
FROM golang:1.24-bullseye
ENV GIN_MODE=release
WORKDIR /
COPY --from=build-production /etc/passwd /etc/passwd
COPY --from=build-production /app/todo-api todo-api
RUN mkdir -p /task-data && chown -R 1001:1001 /task-data
COPY ./docs /app/docs
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
USER nonroot
EXPOSE 8080
ENTRYPOINT ["/entrypoint.sh"]