reproxy/Dockerfile
2024-05-10 15:10:28 -05:00

30 lines
844 B
Docker

FROM golang:1.22-alpine as backend
ARG GIT_BRANCH
ARG GITHUB_SHA
ARG CI
ENV CGO_ENABLED=0
ADD . /build
WORKDIR /build
RUN apk add --no-cache --update git tzdata ca-certificates
RUN \
if [ -z "$CI" ] ; then \
echo "runs outside of CI" && version=$(git rev-parse --abbrev-ref HEAD)-$(git log -1 --format=%h)-$(date +%Y%m%dT%H:%M:%S); \
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"
FROM umputun/baseimage:scratch-latest
# enables automatic changelog generation by tools like Dependabot
LABEL org.opencontainers.image.source="https://github.com/umputun/reproxy"
ENV REPROXY_IN_DOCKER=1
COPY --from=backend /build/reproxy /srv/reproxy
WORKDIR /srv
ENTRYPOINT ["/srv/reproxy"]