Skip to content

Commit a2f2730

Browse files
author
Cyril Tovena
committed
remove docker run entrypoints and add local-includes in makefile.
1 parent 4c155f5 commit a2f2730

File tree

4 files changed

+47
-30
lines changed

4 files changed

+47
-30
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@
1717
*.iml
1818
bin
1919
*.o
20-
tmp
20+
tmp
21+
build/local-includes/*
22+
!build/local-includes/README.md

build/Makefile

+25-25
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ endif
8181

8282
include ./includes/$(osinclude)
8383

84+
# personal includes, excluded from the git repository
85+
-include ./local-includes/*.mk
86+
8487
# _____ _
8588
# |_ _|_ _ _ __ __ _ ___| |_ ___
8689
# | |/ _` | '__/ _` |/ _ \ __/ __|
@@ -99,7 +102,7 @@ build-sdks: build-sdk-cpp
99102

100103
# Run all tests
101104
test: ensure-build-image
102-
docker run --rm $(common_mounts) --entrypoint=go $(build_tag) test -race $(agones_package)/...
105+
docker run --rm $(common_mounts) $(build_tag) go test -race $(agones_package)/...
103106

104107
# Push all the images up to $(REGISTRY)
105108
push: push-controller-image push-agones-sdk-image
@@ -112,7 +115,7 @@ install: ensure-build-image
112115
sed -i -e 's!$${REGISTRY}!$(REGISTRY)!g' -e 's!$${VERSION}!$(VERSION)!g' \
113116
-e 's!$${IMAGE_PULL_POLICY}!$(IMAGE_PULL_POLICY)!g' -e 's!$${ALWAYS_PULL_SIDECAR}!$(ALWAYS_PULL_SIDECAR)!g' \
114117
$(build_path)/.install.yaml
115-
docker run --rm $(common_mounts) $(ARGS) $(build_tag) kubectl apply -f $(mount_path)/build/.install.yaml
118+
docker run --rm $(common_mounts) $(DOCKER_RUN_ARGS) $(build_tag) kubectl apply -f $(mount_path)/build/.install.yaml
116119

117120
# Build a static binary for the gameserver controller
118121
build-controller-binary: ensure-build-image
@@ -121,7 +124,7 @@ build-controller-binary: ensure-build-image
121124

122125
# Build the image for the gameserver controller
123126
build-controller-image: ensure-build-image build-controller-binary
124-
docker build $(agones_path)/cmd/controller/ --tag=$(controller_tag)
127+
docker build $(agones_path)/cmd/controller/ --tag=$(controller_tag) $(DOCKER_BUILD_ARGS)
125128

126129
# push the gameservers controller image
127130
push-controller-image: ensure-build-image
@@ -138,48 +141,48 @@ build-agones-sdk-binary: ensure-build-image
138141

139142
# Build the image for the gameserver sidecar
140143
build-agones-sdk-image: ensure-build-image build-agones-sdk-binary
141-
docker build $(agones_path)/cmd/sdk-server/ --tag=$(sidecar_tag)
144+
docker build $(agones_path)/cmd/sdk-server/ --tag=$(sidecar_tag) $(DOCKER_BUILD_ARGS)
142145

143146
# Build the cpp sdk linux archive
144147
build-sdk-cpp: ensure-build-image
145-
docker run --rm $(common_mounts) -w $(mount_path)/sdks/cpp --entrypoint make $(build_tag) build install archive VERSION=$(VERSION)
148+
docker run --rm $(common_mounts) -w $(mount_path)/sdks/cpp $(build_tag) make build install archive VERSION=$(VERSION)
146149

147150
# push the gameservers sidecar image
148151
push-agones-sdk-image: ensure-build-image
149152
docker push $(sidecar_tag)
150153

151154
# Generate the SDK gRPC server and client code
152155
gen-gameservers-sdk-grpc: ensure-build-image
153-
docker run --rm $(common_mounts) --entrypoint="/root/gen-grpc-go.sh" $(build_tag)
154-
docker run --rm $(common_mounts) --entrypoint="/root/gen-grpc-cpp.sh" $(build_tag)
156+
docker run --rm $(common_mounts) -w $(mount_path) $(build_tag) /root/gen-grpc-go.sh
157+
docker run --rm $(common_mounts) -w $(mount_path) $(build_tag) /root/gen-grpc-cpp.sh
155158

156159
# Generate the client for our CustomResourceDefinition
157160
gen-crd-client: ensure-build-image
158-
docker run --rm $(common_mounts) --entrypoint="/root/gen-crd-client.sh" $(build_tag)
159-
docker run --rm $(common_mounts) --entrypoint=goimports $(build_tag) -w $(mount_path)/pkg
161+
docker run --rm $(common_mounts) -w $(mount_path) $(build_tag) /root/gen-crd-client.sh
162+
docker run --rm $(common_mounts) -w $(mount_path)/pkg $(build_tag) goimports
160163

161164
# Run a bash shell with the developer tools in it. (Creates the image if it doesn't exist)
162-
# Can use ARGS for extra arguments.
165+
# Can use DOCKER_RUN_ARGS for extra arguments.
163166
shell: ensure-build-image
164167
docker run -it --rm \
165168
$(common_mounts) \
166169
-w $(mount_path) \
167-
$(ARGS) \
168-
--entrypoint=bash $(build_tag) -l
170+
$(DOCKER_RUN_ARGS) \
171+
$(build_tag) bash -l
169172

170173
# run a container with godoc
171174
godoc:
172175
if [ ! -f $(build_path)/.index ]; then \
173176
touch $(build_path)/.index && \
174177
docker run -p 8888:8888 --rm $(common_mounts) -v $(build_path)/.index:/root/.index \
175-
--entrypoint=godoc $(build_tag) -http=":8888" -index=true -write_index=true -index_files=/root/.index;\
178+
$(build_tag) godoc -http=":8888" -index=true -write_index=true -index_files=/root/.index;\
176179
fi
177180
docker run -p 8888:8888 --rm $(common_mounts) -v $(build_path)/.index:/root/.index \
178-
--entrypoint=godoc $(build_tag) -http=":8888" -index=true -index_files=/root/.index
181+
$(build_tag) godoc -http=":8888" -index=true -index_files=/root/.index
179182

180183
# Creates the build docker image
181184
build-build-image:
182-
docker build --tag=$(build_tag) $(build_path)/build-image
185+
docker build --tag=$(build_tag) $(build_path)/build-image $(DOCKER_BUILD_ARGS)
183186

184187
# Deletes the local build docker image
185188
clean-build-image:
@@ -215,24 +218,21 @@ push-build-image:
215218

216219
# Initialise the gcloud login and project configuration, if you are working with GCP
217220
gcloud-init: ensure-build-config
218-
docker run --rm -it \
219-
$(common_mounts) \
220-
--entrypoint="gcloud" $(build_tag) init
221+
docker run --rm -it $(common_mounts) $(build_tag) gcloud init
221222

222223
# Creates and authenticates a small, 3 node GKE cluster to work against
223224
gcloud-test-cluster: ensure-build-image
224-
docker run --rm -it $(common_mounts) \
225-
--entrypoint="gcloud" $(build_tag) \
225+
docker run --rm -it $(common_mounts) $(build_tag) gcloud \
226226
deployment-manager deployments create test-cluster --config=$(mount_path)/build/gke-test-cluster/deployment.yml
227227
$(MAKE) gcloud-auth-cluster
228228

229229
# Pulls down authentication information for kubectl against a cluster, name can be specified through CLUSTER_NAME
230230
# (defaults to 'test-cluster')
231231
gcloud-auth-cluster: ensure-build-image
232-
docker run --rm $(common_mounts) --entrypoint="gcloud" $(build_tag) config set container/cluster $(CLUSTER_NAME)
233-
docker run --rm $(common_mounts) --entrypoint="gcloud" $(build_tag) config set compute/zone \
232+
docker run --rm $(common_mounts) $(build_tag) gcloud config set container/cluster $(CLUSTER_NAME)
233+
docker run --rm $(common_mounts) $(build_tag) gcloud config set compute/zone \
234234
`grep zone: $(build_path)/gke-test-cluster/deployment.yml | sed 's/zone: //'`
235-
docker run --rm $(common_mounts) --entrypoint="gcloud" $(build_tag) container clusters get-credentials $(CLUSTER_NAME)
235+
docker run --rm $(common_mounts) $(build_tag) gcloud container clusters get-credentials $(CLUSTER_NAME)
236236

237237
# authenticate our docker configuration so that you can do a docker push directly
238238
# to the gcr.io repository
@@ -271,7 +271,7 @@ minikube-agones-profile:
271271
# Connecting to minikube requires so enhanced permissions, so use this target
272272
# instead of `make shell` to start an interactive shell for development on minikube.
273273
minikube-shell: ensure-build-image minikube-agones-profile
274-
$(MAKE) shell ARGS="--network=host -v $(minikube_cert_mount) $(ARGS)"
274+
$(MAKE) shell DOCKER_RUN_ARGS="--network=host -v $(minikube_cert_mount) $(DOCKER_RUN_ARGS)"
275275

276276
# Push the local Agones Docker images that have already been built
277277
# via `make build` or `make build-images` into the "agones" minikube instance.
@@ -282,7 +282,7 @@ minikube-push: minikube-agones-profile
282282
# Installs the current development version of Agones into the Kubernetes cluster.
283283
# Use this instead of `make install`, as it disables PullAlways on the install.yaml
284284
minikube-install: minikube-agones-profile
285-
$(MAKE) install ARGS="--network=host -v $(minikube_cert_mount)" ALWAYS_PULL_SIDECAR=false IMAGE_PULL_POLICY=IfNotPresent
285+
$(MAKE) install DOCKER_RUN_ARGS="--network=host -v $(minikube_cert_mount)" ALWAYS_PULL_SIDECAR=false IMAGE_PULL_POLICY=IfNotPresent
286286

287287
# Convenience target for transferring images into minikube.
288288
# Use TAG to specify the image to transfer into minikube

build/includes/windows.mk

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ cert_path = $(realpath $(shell $(MINIKUBE) docker-env --shell bash | grep DOCKER
5151
minikube-post-start:
5252
echo "Creating minikube credentials"
5353
export CERT_PATH=$(cert_path) && \
54-
docker run --rm $(common_mounts) $(ARGS) $(build_tag) kubectl config set-cluster $(MINIKUBE_PROFILE) \
54+
docker run --rm $(common_mounts) $(DOCKER_RUN_ARGS) $(build_tag) kubectl config set-cluster $(MINIKUBE_PROFILE) \
5555
--certificate-authority=$$CERT_PATH/ca.crt --server=https://$$($(MINIKUBE) ip):8443 && \
56-
docker run --rm $(common_mounts) $(ARGS) $(build_tag) kubectl config set-credentials $(MINIKUBE_PROFILE) \
56+
docker run --rm $(common_mounts) $(DOCKER_RUN_ARGS) $(build_tag) kubectl config set-credentials $(MINIKUBE_PROFILE) \
5757
--client-certificate=$$CERT_PATH/client.crt --client-key=$$CERT_PATH/client.key
58-
docker run --rm $(common_mounts) $(ARGS) $(build_tag) kubectl config set-context $(MINIKUBE_PROFILE) \
58+
docker run --rm $(common_mounts) $(DOCKER_RUN_ARGS) $(build_tag) kubectl config set-context $(MINIKUBE_PROFILE) \
5959
--cluster=$(MINIKUBE_PROFILE) --user=$(MINIKUBE_PROFILE)
60-
docker run --rm $(common_mounts) $(ARGS) $(build_tag) kubectl config use-context $(MINIKUBE_PROFILE)
60+
docker run --rm $(common_mounts) $(DOCKER_RUN_ARGS) $(build_tag) kubectl config use-context $(MINIKUBE_PROFILE)

build/local-includes/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Local includes
2+
3+
You can drop files in this folder to override default build variables.
4+
5+
For instance if you're behind a corporate proxy you could do this :
6+
7+
```
8+
cat << 'EOF' > docker-build-args.mk
9+
DOCKER_BUILD_ARGS = --build-arg HTTP_PROXY=$(HTTP_PROXY) --build-arg HTTPS_PROXY=$(HTTPS_PROXY) \
10+
--build-arg NO_PROXY=$(NO_PROXY) --build-arg http_proxy=$(HTTP_PROXY) \
11+
--build-arg https_proxy=$(HTTPS_PROXY) --build-arg no_proxy=$(NO_PROXY)
12+
EOF
13+
```
14+
15+
And all `docker build` commands in the makefile will use your proxy.

0 commit comments

Comments
 (0)