-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from kw1knode/main
add Dockerfile
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Build stage | ||
FROM golang:1.23-alpine AS builder | ||
|
||
WORKDIR /app | ||
|
||
# Install build dependencies | ||
RUN apk add --no-cache git | ||
|
||
# Copy source code | ||
COPY . . | ||
|
||
# Download dependencies | ||
RUN go mod download | ||
|
||
# Build the application | ||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main . | ||
|
||
# Final stage | ||
FROM alpine:latest | ||
|
||
WORKDIR /root/ | ||
|
||
# Install runtime dependencies | ||
RUN apk --no-cache add ca-certificates | ||
|
||
# Copy the binary from builder | ||
COPY --from=builder /app/main . | ||
|
||
# Expose port (adjust as needed) | ||
EXPOSE 8080 | ||
|
||
# Run the binary | ||
CMD ["./main"] |