-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
31 lines (20 loc) · 788 Bytes
/
Copy pathDockerfile
File metadata and controls
31 lines (20 loc) · 788 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
FROM golang:1.20-alpine as builder
ENV PROJECT_NAME maritime-ports-service
ENV BASE_DIR /go/src/github.com/powerslider/${PROJECT_NAME}
WORKDIR ${BASE_DIR}
RUN apk --no-cache add git ca-certificates
# Copy only the go.mod and go.sum files to leverage caching.
COPY go.mod go.sum ${BASE_DIR}/
RUN go mod download -x
# Copy the rest of the source code
COPY . .
# Build the Go application.
RUN CGO_ENABLED=0 go build -v -o /dist/${PROJECT_NAME} ./cmd/${PROJECT_NAME}/main.go
FROM alpine
ENV PROJECT_NAME maritime-ports-service
ENV BASE_DIR /go/src/github.com/powerslider/${PROJECT_NAME}
RUN apk --no-cache add ca-certificates
COPY --from=builder /dist .
COPY --from=builder ${BASE_DIR}/fixtures fixtures
# Define the command to run the application.
CMD ["/maritime-ports-service"]