2022-09-20 17:24:06 +00:00
|
|
|
FROM golang:1.17-alpine3.16 as builder
|
2021-04-13 04:20:43 +00:00
|
|
|
|
|
|
|
# Set the Current Working Directory inside the container
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
# Copy go mod and sum files
|
|
|
|
COPY go.mod go.sum ./
|
|
|
|
|
|
|
|
# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed
|
|
|
|
RUN go mod download
|
|
|
|
|
|
|
|
# Copy the source from the current directory to the Working Directory inside the container
|
2021-11-12 17:04:22 +00:00
|
|
|
COPY . .
|
2021-06-05 09:06:24 +00:00
|
|
|
RUN apk --no-cache add musl-dev gcc build-base
|
2021-11-12 17:04:22 +00:00
|
|
|
RUN go install github.com/99designs/gqlgen@v0.14.0
|
2021-06-04 17:46:34 +00:00
|
|
|
RUN go generate ./...
|
2022-09-20 16:53:41 +00:00
|
|
|
ENV CGO_ENABLED=0
|
2022-09-20 17:40:34 +00:00
|
|
|
RUN go build -o zdamegzawodowy ./cmd/server
|
2021-04-13 04:20:43 +00:00
|
|
|
|
|
|
|
######## Start a new stage from scratch #######
|
2022-09-20 17:09:46 +00:00
|
|
|
FROM alpine:3.16
|
2021-04-13 04:20:43 +00:00
|
|
|
|
|
|
|
RUN apk --no-cache add ca-certificates
|
|
|
|
|
|
|
|
WORKDIR /root/
|
|
|
|
|
|
|
|
# Copy the Pre-built binary file from the previous stage
|
2021-04-16 04:38:48 +00:00
|
|
|
COPY --from=builder /app/zdamegzawodowy .
|
2021-04-13 04:20:43 +00:00
|
|
|
|
2021-05-02 11:16:32 +00:00
|
|
|
ENV APP_MODE=production
|
2021-04-13 04:20:43 +00:00
|
|
|
EXPOSE 8080
|
|
|
|
|
2021-11-05 06:58:47 +00:00
|
|
|
CMD ./zdamegzawodowy
|