-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
40 lines (31 loc) · 908 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:alpine
RUN apk update
RUN apk upgrade
RUN apk add bash
RUN apk add git
# Set necessary environmet variables needed for our image
ENV GO111MODULE=auto \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64
# Move to working directory /build
WORKDIR /build
# Copy and download dependency using go mod
COPY go.mod .
COPY go.sum .
RUN go mod download
# Copy the code into the container
COPY . .
# Generate swagger docs
RUN go install github.com/swaggo/swag/cmd/swag@latest
#COPY --from=itinance/swag /root/swag /usr/local/bin
RUN swag init --parseDependency --parseInternal --parseDepth 1
# Build the application
RUN go build -o main main.go
# Move to /dist directory as the place for resulting binary folder
WORKDIR /dist
COPY config/config.json config/config.json
# Copy binary from build to main folder
RUN cp /build/main .
# Command to run when starting the container
CMD ["/dist/main"]