gitlab.com/jfprevost/gitlab-runner-notlscheck@v11.11.4+incompatible/Makefile.runner_helper.mk (about)

     1  # -------------------------------------------------------------------------------
     2  # The following make file does two things:
     3  #   1. Create binaries for the gitlab-runner-helper app which can be found in
     4  #   `./apps/gitlab-runner-helper` for all the platforms we want to support.
     5  #   2. Create Linux containers and extract their file system to be used later to
     6  #   build/publish.
     7  #
     8  # If you want to add a new arch or OS you would need to add a new
     9  # file path to the $BINARIES variables and a new GO_ARCH_{{arch}}-{{OS}}
    10  # variable. Note that Linux is implied by default.
    11  # ---------------------------------------------------------------------------
    12  
    13  
    14  # Tar files that we want to generate from the Docker file system, this is
    15  # genarlly used for linux based Dockerfiles.
    16  BASE_TAR_PATH := out/helper-images/prebuilt
    17  TAR += ${BASE_TAR_PATH}-x86_64.tar.xz
    18  TAR += ${BASE_TAR_PATH}-arm.tar.xz
    19  
    20  # Binaries that we support for the helper image. We are using the following
    21  # pattern match:
    22  # dockerfiles/build/binaries/gitlab-runner-helper.{{arch}}-{{os}}, these should
    23  # match up with GO_ARCH_* variables names. Note that Linux is implied by
    24  # default.
    25  BASE_BINARY_PATH := dockerfiles/build/binaries/gitlab-runner-helper
    26  BINARIES := ${BASE_BINARY_PATH}.x86_64-windows
    27  BINARIES += ${BASE_BINARY_PATH}.x86_64
    28  BINARIES += ${BASE_BINARY_PATH}.arm
    29  
    30  # Define variables with the archiecture for each matching binary. We are using
    31  # the following pattern match GO_ARCH_{{arch}}-{{os}}, these should match up
    32  # with BINARIES variables. The value of the varible is the dist name from `go tool dist list`
    33  GO_ARCH_x86_64 = linux/amd64
    34  GO_ARCH_arm = linux/arm
    35  GO_ARCH_x86_64-windows = windows/amd64
    36  
    37  # Go files that are used to create the helper binary.
    38  HELPER_GO_FILES ?= $(shell find common network vendor -name '*.go')
    39  
    40  .PHONY: helper-build helper-docker
    41  
    42  # PHONY command to help build the binaries.
    43  helper-build: $(BINARIES)
    44  
    45  dockerfiles/build/binaries/gitlab-runner-helper.%: $(HELPER_GO_FILES) $(GOX)
    46  	gox -osarch=$(GO_ARCH_$*) -ldflags "$(GO_LDFLAGS)" -output=$@ $(PKG)/apps/gitlab-runner-helper
    47  
    48  # PHONY command to help build the tar files for linux.
    49  helper-docker: $(TAR)
    50  
    51  out/helper-images/prebuilt-%.tar.xz: out/helper-images/prebuilt-%.tar
    52  	xz -f -9 $<
    53  
    54  out/helper-images/prebuilt-%.tar: dockerfiles/build/binaries/gitlab-runner-helper.%
    55  	@mkdir -p $$(dirname $@_)
    56  	docker build -t gitlab/gitlab-runner-helper:$*-$(REVISION) -f dockerfiles/build/Dockerfile.$* dockerfiles/build
    57  	-docker rm -f gitlab-runner-prebuilt-$*-$(REVISION)
    58  	docker create --name=gitlab-runner-prebuilt-$*-$(REVISION) gitlab/gitlab-runner-helper:$*-$(REVISION) /bin/sh
    59  	docker export -o $@ gitlab-runner-prebuilt-$*-$(REVISION)
    60  	docker rm -f gitlab-runner-prebuilt-$*-$(REVISION)