GildedRose-Refactoring-Kata/go/Dockerfile
2023-07-11 20:36:37 +01:00

46 lines
968 B
Docker
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Specifies a parent image
FROM golang:1.19.2-bullseye as build
# Creates an app directory to hold your apps source code
WORKDIR /app
# Copies everything from your root directory into /app
COPY go.* ./
ENV GOCACHE=/.cache/go-build
ENV GOMODCACHE=/go/mod/pkg
# Installs Go dependencies
RUN go mod download
COPY . ./
ENV CGO_ENABLED=0
# We will mark this image with a configurable tag
ARG BUILD_TAG=unknown
LABEL BUILD_TAG=$BUILD_TAG
# Builds your app with optional configuration
RUN go install github.com/swaggo/swag/cmd/swag@v1.16.1
RUN swag init
RUN go build -a -o target/bin/gilded-rose ./main.go
FROM scratch as runtime
WORKDIR /app
# We will mark this image with a configurable tag
ARG BUILD_TAG=unknown
LABEL BUILD_TAG=$BUILD_TAG
COPY --from=build /app/target/bin/gilded-rose /app/target/bin/gilded-rose
# Tells Docker which network port your container listens on
EXPOSE 8080
ENTRYPOINT [ "/app/target/bin/gilded-rose" ]
CMD [ "app:serve" ]