-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
39 lines (27 loc) · 850 Bytes
/
Dockerfile
File metadata and controls
39 lines (27 loc) · 850 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
# **Base Go Dependencies**
FROM golang:1.24.1 AS deps
WORKDIR /usr/src/app
COPY go.mod go.sum ./
RUN go mod download
# **Install Swagger CLI**
FROM deps AS install-swagger
RUN go install github.com/swaggo/swag/cmd/swag@latest
# **Generate Swagger Docs (Only if files change)**
FROM deps AS swagger
COPY . ./
COPY --from=install-swagger /go/bin/swag /usr/local/bin/swag
RUN swag init --generalInfo cmd/main.go
# **Build App**
FROM deps AS builder
WORKDIR /usr/src/app
COPY . ./
COPY --from=swagger /usr/src/app/docs ./docs
RUN go build -v -o /usr/local/bin/app cmd/main.go
# **Final Stage: Minimal Image**
FROM golang:1.24.1 AS final
WORKDIR /usr/src/app
COPY --from=builder /usr/local/bin/app /usr/local/bin/app
COPY --from=builder /usr/src/app/migrations ./migrations
COPY --from=builder /usr/src/app/docs ./docs
EXPOSE 8080
CMD ["app"]