28 lines
814 B
Docker
28 lines
814 B
Docker
FROM golang:1.15-alpine3.12 as build
|
|
|
|
WORKDIR /go/src/app
|
|
|
|
COPY . .
|
|
|
|
RUN apk add --no-cache openssh git
|
|
|
|
ARG SSH_KEY
|
|
ENV SSH_KEY=${SSH_KEY}
|
|
ARG CI_JOB_TOKEN
|
|
ENV CI_JOB_TOKEN=${CI_JOB_TOKEN}
|
|
|
|
RUN test -n "$SSH_KEY" && \
|
|
{ mkdir /root/.ssh && ssh-keyscan gitlab.com >> /root/.ssh/known_hosts && printf "$SSH_KEY" | base64 -d > /root/.ssh/id_rsa && chmod 600 /root/.ssh/id_rsa && git config --global url."git@gitlab.com:".insteadOf "https://gitlab.com/"; } || true
|
|
|
|
RUN test -n "$CI_JOB_TOKEN" && \
|
|
{ printf "machine gitlab.com\nlogin gitlab-ci-token\npassword ${CI_JOB_TOKEN}" > ~/.netrc; } || true
|
|
|
|
RUN go build -o deploymentagent && \
|
|
rm -f /root/.ssh/id_rsa
|
|
|
|
FROM alpine:3.12
|
|
|
|
COPY --from=build /go/src/app/deploymentagent /usr/local/bin/deploymentagent
|
|
|
|
ENTRYPOINT ["/usr/local/bin/deploymentagent"]
|