Skip to content

Instantly share code, notes, and snippets.

@goodylili
Created September 22, 2023 02:47
Show Gist options
  • Save goodylili/8d130efae647ab7e8a581e1760b4df51 to your computer and use it in GitHub Desktop.
Save goodylili/8d130efae647ab7e8a581e1760b4df51 to your computer and use it in GitHub Desktop.
My Typical Dockerfile
# 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