Skip to content

Instantly share code, notes, and snippets.

@mshirdel
Created June 7, 2023 11:04
Show Gist options
  • Save mshirdel/ee92593325e5cd53c9593006f641d316 to your computer and use it in GitHub Desktop.
Save mshirdel/ee92593325e5cd53c9593006f641d316 to your computer and use it in GitHub Desktop.
DockerMultiStage
# syntax=docker/dockerfile:1
FROM golang:1.20 AS build-stage
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o /linky
FROM gcr.io/distroless/base-debian11 AS build-release-stage
WORKDIR /
COPY --from=build-stage /linky /linky
COPY --from=build-stage /app/config-docker.yaml /config-docker.yaml
EXPOSE 8080
USER nonroot:nonroot
CMD ["./linky", "migrate", "--config", "/config-docker.yaml"]
CMD ["./linky", "serve", "--config", "/config-docker.yaml"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment