Last active
July 19, 2022 10:53
-
-
Save miguelmota/b1537520a66a7ec7ea552c0473d28652 to your computer and use it in GitHub Desktop.
Dockefile golang go get private repo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM golang:latest | |
# ... | |
RUN mkdir -p $GOROOT/src/github.com/MY_ORG | |
# fetch private repo example | |
RUN git clone -b go https://MY_AUTH_TOKEN:[email protected]/MY_ORG/MY_REPO.git $GOPATH/src/github.com/MY_ORG/MY_REPO | |
# go get public repo example | |
RUN go get github.com/lib/pq | |
# ... | |
RUN go build -o main . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM golang:latest | |
# expose default port | |
EXPOSE 8000 | |
# set environment path | |
ENV PATH /go/bin:$PATH | |
# cd into the api code directory | |
WORKDIR /go/src/github.com/myorg/myapp | |
# create ssh directory | |
RUN mkdir ~/.ssh | |
RUN touch ~/.ssh/known_hosts | |
RUN ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts | |
# allow private repo pull | |
RUN git config --global url."https://MY_AUTH_TOKEN:[email protected]/".insteadOf "https://github.com/" | |
# copy the local package files to the container's workspace | |
ADD . /go/src/github.com/myorg/myapp | |
# install the program | |
RUN go install github.com/myorg/myapp | |
# start application | |
CMD ["myapp"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment