Skip to content

Commit

Permalink
feat: multi-stage docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
syahidfrd committed Jan 2, 2025
1 parent c934539 commit b940755
Showing 1 changed file with 6 additions and 21 deletions.
27 changes: 6 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
FROM golang:alpine

# Set necessary environmet variables needed for our image
ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64

# Create app directory
FROM golang:alpine AS builder
WORKDIR /app

# Copy all other source code to work directory
COPY . .
RUN CGO_ENABLED=0 go build -o binary main.go

# Expose port
EXPOSE 3000

# Download all the dependencies that are required
RUN go mod tidy

# Build the application
RUN go build -o binary main.go

ENTRYPOINT ["/app/binary"]
FROM alpine:3
RUN apk update && apk add --no-cache ca-certificates tzdata && update-ca-certificates
COPY --from=builder /app/binary .
ENTRYPOINT ["./binary"]

0 comments on commit b940755

Please sign in to comment.