2021-04-11 21:12:40 +02:00
|
|
|
FROM golang:1.16-alpine as backend
|
2021-04-04 05:26:53 +02:00
|
|
|
|
|
|
|
ARG GIT_BRANCH
|
|
|
|
ARG GITHUB_SHA
|
|
|
|
ARG CI
|
|
|
|
|
|
|
|
ENV GOFLAGS="-mod=vendor"
|
2021-04-11 21:12:40 +02:00
|
|
|
ENV CGO_ENABLED=0
|
2021-04-04 05:26:53 +02:00
|
|
|
|
|
|
|
ADD . /build
|
|
|
|
WORKDIR /build
|
|
|
|
|
2021-04-14 10:26:20 +02:00
|
|
|
RUN apk add --no-cache --update git tzdata ca-certificates
|
|
|
|
|
2021-04-04 05:26:53 +02:00
|
|
|
RUN \
|
|
|
|
if [ -z "$CI" ] ; then \
|
2021-04-12 00:10:40 +02:00
|
|
|
echo "runs outside of CI" && version=$(git rev-parse --abbrev-ref HEAD)-$(git log -1 --format=%h)-$(date +%Y%m%dT%H:%M:%S); \
|
2021-04-04 05:26:53 +02:00
|
|
|
else version=${GIT_BRANCH}-${GITHUB_SHA:0:7}-$(date +%Y%m%dT%H:%M:%S); fi && \
|
|
|
|
echo "version=$version" && \
|
|
|
|
cd app && go build -o /build/reproxy -ldflags "-X main.revision=${version} -s -w"
|
|
|
|
|
|
|
|
|
2021-05-03 21:38:48 +02:00
|
|
|
FROM ghcr.io/umputun/baseimage/app:v1.6.1 as base
|
|
|
|
|
2021-04-14 10:26:20 +02:00
|
|
|
FROM scratch
|
2021-05-03 21:38:48 +02:00
|
|
|
ENV REPROXY_IN_DOCKER=1
|
2021-04-11 21:22:15 +02:00
|
|
|
|
2021-04-04 05:26:53 +02:00
|
|
|
COPY --from=backend /build/reproxy /srv/reproxy
|
2021-05-03 21:38:48 +02:00
|
|
|
COPY --from=base /usr/share/zoneinfo /usr/share/zoneinfo
|
|
|
|
COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
|
|
|
COPY --from=base /etc/passwd /etc/passwd
|
|
|
|
COPY --from=base /etc/group /etc/group
|
2021-04-04 05:26:53 +02:00
|
|
|
|
2021-04-14 10:26:20 +02:00
|
|
|
WORKDIR /srv
|
|
|
|
ENTRYPOINT ["/srv/reproxy"]
|