Dockerfile 669 B

1234567891011121314151617181920
  1. FROM golang:1.22-alpine AS builder
  2. RUN apk add --no-cache git
  3. WORKDIR /app
  4. COPY go.mod ./
  5. RUN go mod download
  6. COPY . .
  7. RUN go mod tidy
  8. RUN CGO_ENABLED=0 GOOS=linux go build -o /photoplaces-api ./cmd/api
  9. FROM alpine:3.19
  10. RUN apk add --no-cache ca-certificates tzdata postgresql-client curl
  11. RUN wget -qO- https://github.com/golang-migrate/migrate/releases/download/v4.17.1/migrate.linux-amd64.tar.gz | tar xz -C /usr/local/bin migrate
  12. COPY --from=builder /photoplaces-api /photoplaces-api
  13. COPY --from=builder /app/migrations /migrations
  14. COPY docker-entrypoint.sh /docker-entrypoint.sh
  15. RUN chmod +x /docker-entrypoint.sh
  16. EXPOSE 8080
  17. ENTRYPOINT ["/docker-entrypoint.sh"]