We are starting out the journey of moving our code to Golang. While deploying our first demo service on kubernetes pod we faced a problem with downloading Go dependencies. Kubernetes pod, where the go code is deployed, is behind a corporate proxy so for outbound access we need to whitelist the domains.
In Kubernetes deployment file we add proxy to download dependencies and as soon as the Docker image is built we remove the proxy to eliminate outbound calls.
This is how the Dockerfile looks like :
FROM {Repository-manager}/golang-base:1.16-alpine
WORKDIR /app
COPY go.mod .
COPY go.sum .
RUN go mod download
ADD . .
EXPOSE 5000
RUN go build -o demo cmd/main.go
CMD ["./demo"]
For other languages like node and python there were package managers like npm and pypi which were used to download the dependencies. But most packages for golang are on several domsins like github.com, goland.org etc.
Is there any way to download the dependencies behind the corporate proxies without having to whitelist all the domains in go.sum and go.mod ? What is the preferred and correct way to deploy and run golang code behind proxy?
TIA!