golang[75]-useDocker

在docker中编译 Go mod程序。需要用到gitlab的私有仓库:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
FROM golang:alpine

RUN apk update
RUN apk add --no-cache git
RUN apk add openssh
ADD id_ed25519 /root/.ssh/id_ed25519
RUN chmod 600 /root/.ssh/id_ed25519

RUN echo -e "[url \"git@gitlab.followme.com:\"]\n\tinsteadOf = https://gitlab.followme.com/" >> /root/.gitconfig
# Skip Host verification for git
RUN echo "StrictHostKeyChecking no " > /root/.ssh/config
WORKDIR /contour
COPY . .
RUN go build -o remote -v viperRemote/viperRemote.go
ENTRYPOINT ["./remote"]

https://medium.com/paperchain/fetching-private-github-repos-from-a-docker-container-273f25ec5a74