This repository has been archived on 2024-04-25. You can view files and clone it, but cannot push or open issues or pull requests.
golang-rest-example/Dockerfile
2024-02-02 15:39:13 +01:00

22 lines
575 B
Docker

# Base
ARG GO_VERSION=1.21
FROM golang:${GO_VERSION} as base
WORKDIR /app
COPY . .
RUN go mod download
# Development
FROM base as dev
RUN go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@v4.1.0
RUN curl -sSfL https://raw.githubusercontent.com/cosmtrek/air/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
CMD ["air"]
# Build
FROM base as build
RUN go build cmd/server.go
# Production
FROM gcr.io/distroless/static-debian12 as prod
COPY --from=build /app/server /app/
COPY --from=build /app/migrations /app/migrations
ENTRYPOINT ["/server"]