diff --git a/.dockerignore b/.dockerignore index 1d272428f2..71caab04d9 100644 --- a/.dockerignore +++ b/.dockerignore @@ -34,19 +34,12 @@ /sdks /src /tests -target/debug -target/release -target/**.d -target/*/*/build -target/*/*/deps -target/*/*/incremental -target/criterion -target/doc -target/tmp +/target # windows files *.exe *.rlib +!target/build-image/x86_64-unknown-linux-gnu/release/quilkin !dependencies-src.zip !image/quilkin.yaml \ No newline at end of file diff --git a/build/Makefile b/build/Makefile index 2a90401ddd..08842095cf 100644 --- a/build/Makefile +++ b/build/Makefile @@ -41,7 +41,8 @@ IMAGE_TAG ?= ${REPOSITORY}quilkin:$(package_version) MINIKUBE_PROFILE ?= quilkin common_rust_args := -v $(project_path):/workspace -w /workspace \ - -v $(CARGO_HOME)/registry:/usr/local/cargo/registry + -v $(CARGO_HOME)/registry:/usr/local/cargo/registry \ + -e "CARGO_TARGET_DIR=/workspace/target/build-image" KUBECONFIG ?= ~/.kube/config kubeconfig_path := $(dir $(KUBECONFIG)) @@ -101,37 +102,34 @@ test-docs: ensure-build-image # Build all binaries, images and related artifacts build: binary-archive build-image -# Build all debug and release binaries -build-all-binaries: ensure-build-image build-linux-binary build-macos-binary +# Build all binaries +build-all-binaries: ensure-build-image build-linux-binary build-macos-binary build-windows-binary -# Build an archive all debug and release binaries +# Build an archive all binaries binary-archive: ensure-build-image build-all-binaries - docker run --rm $(common_rust_args) \ - --entrypoint=bash $(BUILD_IMAGE_TAG) -c 'zip quilkin-$(package_version).zip ./target/*/*/quilkin ./target/*/*/quilkin.exe' + docker run --rm $(common_rust_args) -w /workspace/target/build-image \ + --entrypoint=bash $(BUILD_IMAGE_TAG) -c 'zip ../../quilkin-$(package_version).zip ./*/*/quilkin ./*/*/quilkin.exe' -# Build release and debug binaries for x86_64-unknown-linux-gnu +# Build binary for x86_64-unknown-linux-gnu build-linux-binary: ensure-build-image - docker run --rm $(common_rust_args) \ - --entrypoint=cargo $(BUILD_IMAGE_TAG) build --target x86_64-unknown-linux-gnu docker run --rm $(common_rust_args) \ --entrypoint=cargo $(BUILD_IMAGE_TAG) build --target x86_64-unknown-linux-gnu --release -# Build release and debug binaries for x86_64-pc-windows-gnu +# Build binary for x86_64-pc-windows-gnu build-windows-binary: ensure-build-image - docker run --rm $(common_rust_args) \ - --entrypoint=cargo $(BUILD_IMAGE_TAG) build --target x86_64-pc-windows-gnu docker run --rm $(common_rust_args) \ --entrypoint=cargo $(BUILD_IMAGE_TAG) build --target x86_64-pc-windows-gnu --release -# Build release and debug binaries for x86_64-apple-darwin +# Build binary for x86_64-apple-darwin build-macos-binary: docker run --rm -v $(project_path):/workspace -w /workspace \ -v $(CARGO_HOME)/registry:/root/.cargo/registry \ + -e "CARGO_TARGET_DIR=/workspace/target/build-image" \ -e "CC=o64-clang" -e "CXX=o64-clang++" \ joseluisq/rust-linux-darwin-builder:$(rust_toolchain) \ - sh -c "rustup target add x86_64-apple-darwin && cargo build --target x86_64-apple-darwin && cargo build --release --target x86_64-apple-darwin" + sh -c "rustup target add x86_64-apple-darwin && cargo build --release --target x86_64-apple-darwin" -# Build release and debug container images. +# Build container image. # Use either `REPOSITORY` to specify a container repository (defaults to blank/none), or use `IMAGE_TAG` argument to specify # the entire image name and tag. Defaults to `quilkin:${version}-${git-sha}`. build-image: ensure-build-image build-linux-binary @@ -140,8 +138,7 @@ build-image: --entrypoint=bash $(BUILD_IMAGE_TAG) -c 'cargo about generate license.html.hbs > license.html' docker run --rm $(common_rust_args) \ --entrypoint=bash $(BUILD_IMAGE_TAG) -c './image/archive_dependencies.sh' - docker build -t $(IMAGE_TAG)-debug --build-arg PROFILE=debug -f $(project_path)/image/Dockerfile $(project_path) - docker build -t $(IMAGE_TAG) --build-arg PROFILE=release -f $(project_path)/image/Dockerfile $(project_path) + docker build -t $(IMAGE_TAG) -f $(project_path)/image/Dockerfile $(project_path) # Builds Quilkin, pushes it to a repository (use REPOSITORY arg to set value) # and then runs the Agones integration tests. See targets `build-images` and `push` for more options and details. @@ -172,7 +169,6 @@ push: ifndef SKIP_BUILD_IMAGE push: build-image endif - docker push $(IMAGE_TAG)-debug docker push $(IMAGE_TAG) # Convenience target to build and push quilkin images into a minikube instance diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 22beab29b2..74df7e8494 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -53,16 +53,7 @@ steps: args: - '-c' - 'timeout --signal=INT --preserve-status 5s docker run --rm ${_REPOSITORY}quilkin:$(make version)' - id: test-quilkin-debug - waitFor: - - build - - name: gcr.io/cloud-builders/docker - dir: ./build - entrypoint: bash - args: - - '-c' - - 'timeout --signal=INT --preserve-status 5s docker run --rm ${_REPOSITORY}quilkin:$(make version)-debug' - id: test-quilkin-release + id: test-quilkin-image waitFor: - build - name: us-docker.pkg.dev/$PROJECT_ID/ci/make-docker diff --git a/image/Dockerfile b/image/Dockerfile index 2815d34470..3b9805c145 100644 --- a/image/Dockerfile +++ b/image/Dockerfile @@ -12,20 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -ARG PROFILE - FROM gcr.io/distroless/cc:nonroot as base WORKDIR / COPY ./license.html . COPY ./dependencies-src.zip . COPY --chown=nonroot:nonroot ./image/quilkin.yaml /etc/quilkin/quilkin.yaml +COPY ./target/build-image/x86_64-unknown-linux-gnu/release/quilkin . -FROM base as release -COPY ./target/x86_64-unknown-linux-gnu/release/quilkin . - -FROM base as debug -COPY ./target/x86_64-unknown-linux-gnu/debug/quilkin . - -FROM $PROFILE USER nonroot:nonroot ENTRYPOINT ["/quilkin", "--config", "/etc/quilkin/quilkin.yaml", "run"]