From 5b5063e8a6b29aa42fcb7d9eb9f7d15303fc9cc3 Mon Sep 17 00:00:00 2001 From: Bruno Figueiredo Date: Fri, 1 Mar 2019 15:41:49 -0800 Subject: [PATCH] Tarballing source into the images for dependencies that are required by their licenses. --- build/Makefile | 10 +++++++--- build/build-required-src-dist.sh | 33 ++++++++++++++++++++++++++++++++ cmd/controller/Dockerfile | 2 +- cmd/ping/Dockerfile | 2 +- cmd/sdk-server/Dockerfile | 2 +- 5 files changed, 43 insertions(+), 6 deletions(-) create mode 100755 build/build-required-src-dist.sh diff --git a/build/Makefile b/build/Makefile index 8696544103..af2253c481 100644 --- a/build/Makefile +++ b/build/Makefile @@ -281,8 +281,12 @@ lint: $(ensure-build-image) build-licenses: docker run --rm $(common_mounts) $(build_tag) $(mount_path)/build/extract-licenses.sh +# Tarball source for dependencies that are required to be distributed with the image (MPL) +build-required-src-dist: + docker run --rm $(common_mounts) $(build_tag) $(mount_path)/build/build-required-src-dist.sh + # Build the image for the gameserver controller -build-controller-image: $(ensure-build-image) build-controller-binary build-licenses +build-controller-image: $(ensure-build-image) build-controller-binary build-licenses build-required-src-dist docker build $(agones_path)/cmd/controller/ --tag=$(controller_tag) $(DOCKER_BUILD_ARGS) # push the gameservers controller image @@ -310,7 +314,7 @@ build-agones-sdk-binary-windows: $(ensure-build-image) -o $(go_build_base_path)/cmd/sdk-server/bin/sdk-server.windows.amd64.exe $(go_rebuild_flags) $(go_version_flags) $(agones_package)/cmd/sdk-server # Build the image for the gameserver sidecar -build-agones-sdk-image: $(ensure-build-image) build-agones-sdk-binary build-licenses +build-agones-sdk-image: $(ensure-build-image) build-agones-sdk-binary build-licenses build-required-src-dist docker build $(agones_path)/cmd/sdk-server/ --tag=$(sidecar_tag) $(DOCKER_BUILD_ARGS) # Build a static binary for the ping service @@ -324,7 +328,7 @@ push-ping-image: $(ensure-build-image) docker push $(ping_tag) # Build the image for the ping service -build-ping-image: $(ensure-build-image) build-ping-binary build-licenses +build-ping-image: $(ensure-build-image) build-ping-binary build-licenses build-required-src-dist docker build $(agones_path)/cmd/ping/ --tag=$(ping_tag) $(DOCKER_BUILD_ARGS) # Build the cpp sdk linux archive diff --git a/build/build-required-src-dist.sh b/build/build-required-src-dist.sh new file mode 100755 index 0000000000..a022412663 --- /dev/null +++ b/build/build-required-src-dist.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# Copyright 2017 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -o errexit +set -o nounset +set -o pipefail + +SRC_ROOT=$(dirname "${BASH_SOURCE}")/.. + +TMP_DEPS_SRC=/tmp/dependencies-src.tgz + +# Pack the source code of dependencies that are MPL +tar -zcf ${TMP_DEPS_SRC} -C ${SRC_ROOT}/vendor/ \ + github.com/hashicorp/golang-lru \ + github.com/hashicorp/hcl + +for ddir in ${SRC_ROOT}/cmd/controller/bin/ ${SRC_ROOT}/cmd/ping/bin/ ${SRC_ROOT}/cmd/sdk-server/bin/ ; do + mkdir -p ${ddir} + cp ${TMP_DEPS_SRC} ${ddir} +done + diff --git a/cmd/controller/Dockerfile b/cmd/controller/Dockerfile index dd51ffbf73..324eb29583 100644 --- a/cmd/controller/Dockerfile +++ b/cmd/controller/Dockerfile @@ -18,7 +18,7 @@ RUN apk --update add ca-certificates && \ adduser -D agones COPY --chown=agones:root ./bin/controller /home/agones/controller -COPY --chown=agones:root ./bin/LICENSES /home/agones/LICENSES +COPY --chown=agones:root ./bin/LICENSES ./bin/dependencies-src.tgz /home/agones/ USER agones ENTRYPOINT ["/home/agones/controller"] \ No newline at end of file diff --git a/cmd/ping/Dockerfile b/cmd/ping/Dockerfile index 8c895720bd..305db75ec0 100644 --- a/cmd/ping/Dockerfile +++ b/cmd/ping/Dockerfile @@ -18,7 +18,7 @@ RUN apk --update add ca-certificates && \ adduser -D agones COPY --chown=agones:root ./bin/ping /home/agones/ping -COPY --chown=agones:root ./bin/LICENSES /home/agones/LICENSES +COPY --chown=agones:root ./bin/LICENSES ./bin/dependencies-src.tgz /home/agones/ USER agones ENTRYPOINT ["/home/agones/ping"] \ No newline at end of file diff --git a/cmd/sdk-server/Dockerfile b/cmd/sdk-server/Dockerfile index 17d1dcdf61..7bd4f82e26 100644 --- a/cmd/sdk-server/Dockerfile +++ b/cmd/sdk-server/Dockerfile @@ -18,7 +18,7 @@ RUN apk --update add ca-certificates && \ adduser -D agones COPY --chown=agones:root ./bin/sdk-server.linux.amd64 /home/agones/sdk-server -COPY --chown=agones:root ./bin/LICENSES /home/agones/LICENSES +COPY --chown=agones:root ./bin/LICENSES ./bin/dependencies-src.tgz /home/agones/ USER agones ENTRYPOINT ["/home/agones/sdk-server"] \ No newline at end of file