30 lines
756 B
Docker
30 lines
756 B
Docker
# BUILD
|
|
FROM golang:1.20.3-alpine AS build
|
|
|
|
# Update packages and clear cache
|
|
RUN apk add --no-cache curl
|
|
# Set work directory
|
|
WORKDIR /app
|
|
# Create binary directory
|
|
RUN mkdir /app/bin -p
|
|
# Add main files to app
|
|
RUN apk add git
|
|
ADD . .
|
|
ENV GOPRIVATE=penahub.gitlab.yandexcloud.net/backend/penahub_common
|
|
RUN git config --global url."https://buildToken:glpat-axA8ttckx3aPf_xd2Dym@penahub.gitlab.yandexcloud.net/".insteadOf "https://penahub.gitlab.yandexcloud.net/"
|
|
RUN go mod download
|
|
# Build app
|
|
RUN GOOS=linux go build -o bin ./...
|
|
|
|
# PRODUCTION
|
|
FROM alpine:3.18.3 AS production
|
|
|
|
# Install packages
|
|
RUN apk --no-cache add ca-certificates
|
|
# Create home directory
|
|
WORKDIR /app
|
|
# Copy build file
|
|
COPY --from=build /app/bin/codeword ./app
|
|
# CMD
|
|
CMD ["./app"]
|