/
brjiza
/
hello
Обзор
Документация
Войти
/
brjiza
/
hello
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Dockerfile
31 строка
959 B
appetito
hello init
17 ноя 2024, 00:41
17 ноя 2024, 00:41
8f6f922
Код
Авторство
О чём код?
# Use the official Golang image to create a build artifact. # This is based on Debian and sets the GOPATH to /go. FROM golang:latest AS builder ARG TARGETOS ARG TARGETARCH # Create and change to the app directory. WORKDIR /app # Copy local code to the container image. COPY . ./ # Install dependencies and tidy up the go.mod and go.sum files. RUN go mod tidy # Build the binary. # -mod=readonly ensures immutable go.mod and go.sum in container builds. RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -mod=readonly -v -o server # Use the official Alpine image for a lean production container. # https://hub.docker.com/_/alpine # https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds FROM alpine:3 RUN apk add --no-cache ca-certificates # Copy the binary to the production image from the builder stage. COPY --from=builder /app/server /server # Run the web service on container startup. CMD ["/server"]