From 7c366b472b62e23df52484014c4cd0906a28bd0c Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 4 Sep 2022 11:29:49 +0200 Subject: [PATCH 1/3] Use prebuild docker image for backend --- .gitlab-ci.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3142c8e..3e25bf8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,18 +1,15 @@ -image: ubuntu:latest - stages: - build - package build_backend: stage: build + image: reg.gitlab.mattv.de/root/docker-images/ubuntu_build_base:latest cache: key: backend paths: - vcpkg_cache script: - - apt-get update - - apt-get install g++ gcc make cmake git curl zip unzip tar python3 pkg-config -y - SRC="$PWD" - TMP=$(mktemp -d) - cd $TMP @@ -45,6 +42,7 @@ test_and_build_frontend: - frontend/dist/ package_server: + image: alpine:latest stage: package before_script: [] needs: From d7841ad48652ef142cbb982604f6b558d551b4ef Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 4 Sep 2022 11:52:32 +0200 Subject: [PATCH 2/3] Added muslc build, release on tag --- .gitlab-ci.yml | 83 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 70 insertions(+), 13 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3e25bf8..18f106a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,14 +1,10 @@ stages: - build - package + - release -build_backend: +.backend_base: stage: build - image: reg.gitlab.mattv.de/root/docker-images/ubuntu_build_base:latest - cache: - key: backend - paths: - - vcpkg_cache script: - SRC="$PWD" - TMP=$(mktemp -d) @@ -24,6 +20,22 @@ build_backend: paths: - server +build_backend_glibc: + extends: .backend_base + image: reg.gitlab.mattv.de/root/docker-images/ubuntu_build_base:latest + cache: + key: backend_glibc + paths: + - vcpkg_cache + +build_backend_muslc: + extends: .backend_base + image: reg.gitlab.mattv.de/root/docker-images/alpine_build_base:latest + cache: + key: backend_muslc + paths: + - vcpkg_cache + test_and_build_frontend: image: node:latest stage: build @@ -41,19 +53,64 @@ test_and_build_frontend: paths: - frontend/dist/ -package_server: +.package_server: image: alpine:latest stage: package - before_script: [] + artifacts: + paths: + - '*.tar' + +package_server_glibc: + extends: .package_server needs: - - job: build_backend + - job: build_backend_glibc artifacts: true - job: test_and_build_frontend artifacts: true script: - mkdir static - mv frontend/dist/* static/ - artifacts: - paths: - - server - - static/ + - tar -cvf linux-x64-glibc.tar server static + +package_server_muslc: + extends: .package_server + needs: + - job: build_backend_muslc + artifacts: true + - job: test_and_build_frontend + artifacts: true + script: + - mkdir static + - mv frontend/dist/* static/ + - tar -cvf linux-x64-muslc.tar server static + +upload_assets: + stage: release + image: curlimages/curl:latest + needs: + - job: package_server_glibc + artifacts: true + - job: package_server_muslc + artifacts: true + rules: + - if: $CI_COMMIT_TAG + script: + - | + curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file "linux-x64-glibc.tar" "${PACKAGE_REGISTRY_URL}/linux-x64-glibc.tar" + - | + curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file "linux-x64-muslc.tar" "${PACKAGE_REGISTRY_URL}/linux-x64-muslc.tar" + + + +create_release: + stage: release + image: registry.gitlab.com/gitlab-org/release-cli:latest + needs: + - upload_assets + rules: + - if: $CI_COMMIT_TAG + script: + - | + release-cli create --name "Release $CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG \ + --assets-link "{\"name\":\"linux-x64-glibc.tar\",\"url\":\"${PACKAGE_REGISTRY_URL}/linux-x64-glibc.tar\"}" \ + --assets-link "{\"name\":\"linux-x64-muslc.tar\",\"url\":\"${PACKAGE_REGISTRY_URL}/linux-x64-muslc.tar\"}" From 006374aef827b046b056f307d4f86c18a3d83037 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 4 Sep 2022 12:04:00 +0200 Subject: [PATCH 3/3] Force system binaries on alpine --- .gitlab-ci.yml | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 18f106a..f357c99 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,8 +3,9 @@ stages: - package - release -.backend_base: +build_backend_glibc: stage: build + image: reg.gitlab.mattv.de/root/docker-images/ubuntu_build_base:latest script: - SRC="$PWD" - TMP=$(mktemp -d) @@ -16,25 +17,35 @@ stages: - VCPKG_DEFAULT_BINARY_CACHE=$SRC/vcpkg_cache cmake -B build -S backend -DCMAKE_TOOLCHAIN_FILE=$TMP/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release - cmake --build build - cp build/backend server - artifacts: - paths: - - server - -build_backend_glibc: - extends: .backend_base - image: reg.gitlab.mattv.de/root/docker-images/ubuntu_build_base:latest cache: key: backend_glibc paths: - vcpkg_cache + artifacts: + paths: + - server build_backend_muslc: - extends: .backend_base + stage: build image: reg.gitlab.mattv.de/root/docker-images/alpine_build_base:latest + script: + - SRC="$PWD" + - TMP=$(mktemp -d) + - cd $TMP + - git clone https://github.com/Microsoft/vcpkg.git . + - ./bootstrap-vcpkg.sh -disableMetrics + - cd $SRC + - mkdir -p vcpkg_cache + - VCPKG_FORCE_SYSTEM_BINARIES=1 VCPKG_DEFAULT_BINARY_CACHE=$SRC/vcpkg_cache cmake -B build -S backend -DCMAKE_TOOLCHAIN_FILE=$TMP/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release + - cmake --build build + - cp build/backend server cache: key: backend_muslc paths: - vcpkg_cache + artifacts: + paths: + - server test_and_build_frontend: image: node:latest