Created
September 22, 2023 02:47
-
-
Save goodylili/8d130efae647ab7e8a581e1760b4df51 to your computer and use it in GitHub Desktop.
My Typical Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build stage | |
FROM golang:1.20-alpine AS build | |
# Set the working directory inside the container | |
WORKDIR /app | |
# Copy the Go application source code into the container | |
COPY . . | |
# Build the Go application | |
RUN go build -o server ./cmd/server | |
# Final stage | |
FROM alpine:latest | |
# Set the working directory inside the final container | |
WORKDIR /app | |
# Copy the binary built in the previous stage | |
COPY --from=build /app/server . | |
# Expose the port your application will listen on (adjust as needed) | |
EXPOSE 8080 | |
# Run your Go application | |
CMD ["./server"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment