This repository has been archived on 2022-09-04. You can view files and clone it, but cannot push or open issues or pull requests.
api/Dockerfile

33 lines
801 B
Docker
Raw Normal View History

2020-09-03 11:14:08 +00:00
FROM golang:alpine as builder
2020-06-02 15:45:21 +00:00
2020-09-03 11:14:08 +00:00
# Set the Current Working Directory inside the container
WORKDIR /app
# Copy go mod and sum files
COPY go.mod go.sum ./
2020-06-02 15:45:21 +00:00
2020-09-03 11:14:08 +00:00
# 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
2020-06-02 15:45:21 +00:00
COPY . .
RUN go build -o main .
2020-09-03 11:14:08 +00:00
######## Start a new stage from scratch #######
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
# Copy the Pre-built binary file from the previous stage
COPY --from=builder /app/main .
ENV MODE=production
ENV GIN_MODE=release
2020-06-05 15:17:46 +00:00
EXPOSE 8080
2020-06-02 15:45:21 +00:00
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.2.1/wait ./wait
RUN chmod +x ./wait
CMD ./wait && ./main