You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
683 B
Docker
29 lines
683 B
Docker
|
|
# Dockerfile References: https://docs.docker.com/engine/reference/builder/
|
|
|
|
# Start from the latest golang base image
|
|
FROM golang:latest as builder
|
|
|
|
|
|
# Set the Current Working Directory inside the container
|
|
WORKDIR /app
|
|
|
|
# Copy the source from the current directory to the Working Directory inside the container
|
|
COPY . .
|
|
|
|
# Build the Go app
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .
|
|
|
|
|
|
######## Start a new stage from scratch #######
|
|
FROM alpine:latest
|
|
|
|
RUN apk --no-cache add ca-certificates
|
|
|
|
WORKDIR /root/
|
|
|
|
# Copy the Pre-built binary file from the previous stage
|
|
COPY --from=builder /app/main .
|
|
|
|
# Command to run the executable
|
|
ENTRYPOINT ["./main"] |