If you want to build your go application in a cicd but do not have a connection to the internet on the build-server you need a way to include the depenencies into your git repository.
You can do so by changing your
Go will always download the dependencies into your
To include them into your git you first have to temporarily change your
GOPATH. To keep things organized I use a directory next to my
main.go file named
# Create new directory
[tux@client]$ mkdir dependencies
# Change your go path relative to your working directory
# Download dependencies into your gopath
[tux@client]$ go get .
After that we need to modify our Dockerfile as well.
COPY . .
RUN go build
RUN chmod +x app
Now push all the files to your git and you should be able to build your Docker Image in an offline environment.
Just remember, if you add new dependencies, to download them into the project.