# шаг 0 - скачка зависимостей
# https://github.com/proxeter/go-service-template/blob/master/deployments/docker/Dockerfile
FROM golang:1.21 AS dependencies
WORKDIR /go/src/photolist
COPY go.mod .
COPY go.sum .
RUN go mod download

# 1 шаг - сборка пакета
FROM dependencies AS build
# если у вас завендорены зависимости
# FROM golang:1.21 AS build
COPY . /go/src/photolist
WORKDIR /go/src/photolist
RUN make build

# 2 шаг - создание контейнера для запуска
FROM debian:bookworm-slim
WORKDIR /app
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build /go/src/photolist/bin/* /app/
COPY --from=build /go/src/photolist/scripts/wait-for-it.sh /app/
RUN chmod +x /app/*
EXPOSE 8080/tcp
CMD /app/photolist