update Dockerfile
This commit is contained in:
parent
198a436b15
commit
fe21fa5a94
27
Dockerfile
27
Dockerfile
|
@ -1,13 +1,32 @@
|
|||
FROM golang:alpine
|
||||
RUN apk add git
|
||||
FROM golang:alpine as builder
|
||||
|
||||
ENV MODE=production
|
||||
# Set the Current Working Directory inside the container
|
||||
WORKDIR /app
|
||||
|
||||
WORKDIR /go/src/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
|
||||
COPY . .
|
||||
|
||||
RUN go build -o main .
|
||||
|
||||
######## 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
|
||||
EXPOSE 8080
|
||||
|
||||
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.2.1/wait ./wait
|
||||
RUN chmod +x ./wait
|
||||
|
||||
|
|
Reference in New Issue