-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
39 lines (26 loc) · 967 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
# Build Stage
FROM golang:alpine AS builder
# Install necessary dependencies (git)
RUN apk update && apk add --no-cache git
# Set the working directory inside the container
WORKDIR /application
# Copy the Go module files and download dependencies
COPY go.mod go.sum ./
RUN go mod tidy
# Copy the source code into the container
COPY . .
# Build the Go application (output will be 'binary')
RUN go build -o binary .
# Final Stage (Minimal runtime image)
FROM alpine:latest
# Install necessary libraries (like ca-certificates for HTTPS requests)
RUN apk --no-cache add ca-certificates
# Set the working directory inside the container
WORKDIR /application
# Copy the compiled binary from the build stage
COPY --from=builder /application/binary /application/
COPY --from=builder /application/product.json /application/
# Expose the port the app will listen on (if needed)
EXPOSE 8080
# Set the entry point for the container
ENTRYPOINT ["/application/binary"]