2020-09-03 11:14:37 +00:00
|
|
|
FROM golang:alpine as builder
|
2020-05-30 11:24:42 +00:00
|
|
|
|
2020-09-03 11:14:37 +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
|
2020-05-30 11:24:42 +00:00
|
|
|
|
2020-09-03 11:14:37 +00:00
|
|
|
# Copy the source from the current directory to the Working Directory inside the container
|
2020-05-30 11:24:42 +00:00
|
|
|
COPY . .
|
|
|
|
|
2021-05-06 12:42:37 +00:00
|
|
|
RUN go build -o twhelpdcbot .
|
2020-05-30 11:24:42 +00:00
|
|
|
|
2020-09-03 11:14:37 +00:00
|
|
|
######## Start a new stage from scratch #######
|
2021-05-06 12:42:37 +00:00
|
|
|
FROM alpine:latest
|
2020-09-03 11:14:37 +00:00
|
|
|
|
|
|
|
RUN apk --no-cache add ca-certificates
|
|
|
|
|
|
|
|
WORKDIR /root/
|
|
|
|
|
2021-05-06 12:42:37 +00:00
|
|
|
# Copy the Pre-built binary file and translations from the previous stage
|
2020-09-03 11:14:37 +00:00
|
|
|
COPY --from=builder /app/message/translations ./message/translations
|
2021-05-06 12:42:37 +00:00
|
|
|
COPY --from=builder /app/twhelpdcbot .
|
2020-09-03 11:14:37 +00:00
|
|
|
|
2021-05-06 12:42:37 +00:00
|
|
|
ENV APP_MODE=production
|
2020-09-03 11:14:37 +00:00
|
|
|
ENV GIN_MODE=release
|
|
|
|
EXPOSE 8080
|
|
|
|
|
2020-05-30 11:24:42 +00:00
|
|
|
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.2.1/wait ./wait
|
|
|
|
RUN chmod +x ./wait
|
|
|
|
|
2021-05-06 12:42:37 +00:00
|
|
|
CMD ./wait && ./twhelpdcbot
|