Skip to content

Commit

Permalink
ci: add build stage
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmethakanbesel committed Oct 29, 2023
1 parent b963138 commit 796acef
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@
FROM golang:1.20-alpine

# Set destination for COPY
FROM golang:1.21-alpine as builder
WORKDIR /app
COPY go.mod ./
RUN go mod download

# Download Go modules
# COPY go.mod go.sum ./
# RUN go mod download

# Copy the source code. Note the slash at the end, as explained in
# https://docs.docker.com/engine/reference/builder/#copy
COPY . ./

# Build
RUN CGO_ENABLED=0 go build -o /finance-api

# Optional:
# To bind to a TCP port, runtime parameters must be supplied to the docker command.
# But we can document in the Dockerfile what ports
# the application is going to listen on by default.
# https://docs.docker.com/engine/reference/builder/#expose
FROM gcr.io/distroless/static-debian12
COPY --from=builder /finance-api .
EXPOSE 8080

# Run
# RUN go run main.go serve
CMD ["/finance-api", "serve", "--http=0.0.0.0:8080"]

0 comments on commit 796acef

Please sign in to comment.