From b29a0819b623e35dcdb5d01eb23c9098f000719a Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Mon, 1 Apr 2024 03:00:35 +0300 Subject: [PATCH 1/5] Add mods --- .github/workflows/CI.yml | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ed5074e..a03bb04 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -21,12 +21,16 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - branch: [steam_legacy, latest] + branch: [steam_legacy, public] + mod: [ + valve, + cstrike + ] include: - - branch: steam_legacy - build-args: APPBRANCH=steam_legacy - - branch: latest - build-args: APPBRANCH= + - mod: valve + depots: "1 4 1006" + - mod: cstrike + depots: "1 4 1006 11" steps: - uses: actions/checkout@v4.1.1 @@ -38,9 +42,8 @@ jobs: uses: actions/cache@v4.0.2 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }}-${{ matrix.branch }} - restore-keys: | - ${{ runner.os }}-buildx-${{ matrix.branch }} + key: ${{ runner.os }}-buildx-${{ github.sha }}-${{ matrix.branch }}-${{ matrix.mod }} + restore-keys: ${{ runner.os }}-buildx-${{ matrix.branch }}-${{ matrix.mod }} - name: Log in to Docker Hub if: github.ref == 'refs/heads/master' @@ -57,6 +60,9 @@ jobs: platforms: ${{ env.DOCKER_PLATFORMS }} push: ${{ github.ref == 'refs/heads/master' }} tags: ${{ env.DOCKER_IMAGE }}:${{ matrix.branch }} - build-args: ${{ matrix.build-args }} + build-args: | + APPBRANCH=${{ matrix.branch }} + DEPOTS=${{ matrix.depots }} + MOD=${{ matrix.mod }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache \ No newline at end of file From d0bd2fcbdc036389c4f4dda2eee0aeba0fb9fa0a Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Mon, 1 Apr 2024 05:27:15 +0300 Subject: [PATCH 2/5] refactor: getDepotsByMod --- .github/workflows/CI.yml | 17 ++++++----------- .vscode/tasks.json | 18 +++++++++++++++--- Dockerfile | 8 +++++--- utils/getDepotsByMod.sh | 17 +++++++++++++++++ 4 files changed, 43 insertions(+), 17 deletions(-) create mode 100755 utils/getDepotsByMod.sh diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index a03bb04..7112d1c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -21,16 +21,12 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - branch: [steam_legacy, public] - mod: [ - valve, - cstrike - ] - include: - - mod: valve - depots: "1 4 1006" - - mod: cstrike - depots: "1 4 1006 11" + branch: + - steam_legacy + - public + mod: + - valve + - cstrike steps: - uses: actions/checkout@v4.1.1 @@ -62,7 +58,6 @@ jobs: tags: ${{ env.DOCKER_IMAGE }}:${{ matrix.branch }} build-args: | APPBRANCH=${{ matrix.branch }} - DEPOTS=${{ matrix.depots }} MOD=${{ matrix.mod }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 7e5353f..e936206 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -7,7 +7,8 @@ "dockerBuild": { "context": "${workspaceFolder}", "buildArgs": { - "APPBRANCH": "${input:betaBranch}" + "APPBRANCH": "${input:betaBranch}", + "MOD": "${input:mod}", }, "tag": "hlds_image" }, @@ -29,12 +30,23 @@ { "type": "pickString", "id": "betaBranch", - "default": "true", + "default": "public", "description": "Select DepotsDownloader branch.", "options": [ "public", "steam_legacy" ] - } + }, + { + "type": "pickString", + "id": "mod", + "default": "valve", + "description": "Select mod.", + "options": [ + "valve", + "cstrike", + "czero" + ] + }, ] } \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 3fa24b9..9d7c9f5 100755 --- a/Dockerfile +++ b/Dockerfile @@ -25,9 +25,11 @@ ARG DepotDownloader_URL="https://github.com/SteamRE/DepotDownloader/releases/dow RUN curl -L# ${DepotDownloader_URL} | bsdtar -xvf - -C /usr/local/bin/ \ && chmod +x /usr/local/bin/DepotDownloader -# Download required depots -ARG DEPOTS="1 4 1006" -RUN for depot in ${DEPOTS}; do \ +COPY --chmod=755 utils/* utils/ + +# Download mod depots +RUN DEPOTS=$(utils/getDepotsByMod.sh ${MOD}) \ + && for depot in ${DEPOTS}; do \ DepotDownloader -dir ${APPDIR} -app ${APPID} -depot ${depot} -beta ${APPBRANCH}; \ done \ && rm -rf ${APPDIR}/.DepotDownloader diff --git a/utils/getDepotsByMod.sh b/utils/getDepotsByMod.sh new file mode 100755 index 0000000..4401f6f --- /dev/null +++ b/utils/getDepotsByMod.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +case "$1" in + "valve") + echo "1 4 1006" + ;; + "cstrike") + echo "1 4 1006 11" + ;; + "czero") + echo "1 4 1006 11 81" + ;; + *) + echo "Invalid argument \"$1\"" + exit 1 + ;; +esac \ No newline at end of file From c65005066bba13d0568b1c58b9a1584b27d49c48 Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Tue, 2 Apr 2024 02:23:30 +0300 Subject: [PATCH 3/5] update base image to `trixie-slim` --- Dockerfile | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9d7c9f5..eca962f 100755 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ ARG APPDIR="/root/hlds" ARG APPID="90" ARG MOD="valve" -FROM debian:bookworm-slim AS build_stage +FROM debian:trixie-slim AS build_stage ARG APPDIR ARG APPID @@ -13,11 +13,11 @@ LABEL creator="Sergey Shorokhov " # Install required packages RUN set -x \ - && apt-get update \ - && apt-get install -y --no-install-recommends --no-install-suggests \ - ca-certificates=20230311 \ - curl=7.88.1-10+deb12u5 \ - libarchive-tools=3.6.2-1 \ + && apt update \ + && apt install -y --no-install-recommends --no-install-suggests \ + ca-certificates=20240203 \ + curl=8.5.0-2 \ + libarchive-tools=3.7.2-1 \ && rm -rf /var/lib/apt/lists/* # Download and install DepotDownloader @@ -45,15 +45,15 @@ RUN rm -rf ${APPDIR}/linux64 \ -name '*.dylib' \ \) -exec rm -rf {} \; -FROM debian:bookworm-slim AS run_stage +FROM debian:trixie-slim AS run_stage # Install required packages RUN set -x \ - && apt-get update \ - && apt-get install -y --no-install-recommends --no-install-suggests \ - ca-certificates=20230311 \ - gdb-minimal=13.1-3 \ - lib32stdc++6=12.2.0-14 \ + && apt update \ + && apt install -y --no-install-recommends --no-install-suggests \ + ca-certificates=20240203 \ + gdb-minimal=13.2-1 \ + lib32stdc++6=14-20240201-3 \ && rm -rf /var/lib/apt/lists/* ARG APPDIR From fd828dcd1ad1fdcd8464adba9a48180db8ac3303 Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Tue, 2 Apr 2024 02:36:12 +0300 Subject: [PATCH 4/5] cache key to env --- .github/workflows/CI.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 7112d1c..bfc5c92 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -36,10 +36,12 @@ jobs: - name: Cache Docker layers uses: actions/cache@v4.0.2 + env: + KEY: ${{ matrix.mod }}-${{ matrix.branch }} with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }}-${{ matrix.branch }}-${{ matrix.mod }} - restore-keys: ${{ runner.os }}-buildx-${{ matrix.branch }}-${{ matrix.mod }} + key: ${{ runner.os }}-buildx-${{ github.sha }}-${{ env.KEY }} + restore-keys: ${{ runner.os }}-buildx-${{ env.KEY }} - name: Log in to Docker Hub if: github.ref == 'refs/heads/master' From 50d7de44d7abe2c3e72e3d74aa49b589eccef0bc Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Tue, 2 Apr 2024 02:36:52 +0300 Subject: [PATCH 5/5] push every mod to each docker repo --- .github/workflows/CI.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index bfc5c92..b1780e7 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -12,7 +12,7 @@ on: - cron: '0 0 * * 0' env: - DOCKER_IMAGE: ${{ secrets.DOCKER_USERNAME }}/hlds + DOCKER_IMAGE: ${{ secrets.DOCKER_USERNAME }} DOCKER_PLATFORMS: linux/amd64 jobs: @@ -57,7 +57,7 @@ jobs: file: ./Dockerfile platforms: ${{ env.DOCKER_PLATFORMS }} push: ${{ github.ref == 'refs/heads/master' }} - tags: ${{ env.DOCKER_IMAGE }}:${{ matrix.branch }} + tags: ${{ secrets.DOCKER_USERNAME }}/${{ matrix.mod }}:${{ matrix.branch }} build-args: | APPBRANCH=${{ matrix.branch }} MOD=${{ matrix.mod }}