diff --git a/.github/workflows/push-image.yaml b/.github/workflows/push-image.yaml index a9f90c7..73d83ce 100644 --- a/.github/workflows/push-image.yaml +++ b/.github/workflows/push-image.yaml @@ -3,6 +3,8 @@ name: Push Image on: push: # Sequence of patterns matched against refs/tags + branches: + - 'fix-multiarch-build' tags: - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 @@ -10,7 +12,7 @@ on: workflow_dispatch: jobs: - x86_64: + multiarch: runs-on: ubuntu-latest permissions: contents: read @@ -18,28 +20,15 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - uses: cachix/install-nix-action@v21 - - name: Build - run: | - nix build .#container - skopeo login --username "${{ github.actor }}" --password "${{ secrets.GITHUB_TOKEN }}" ghcr.io - skopeo copy docker-archive://$(readlink -f ./result) docker://ghcr.io/chrisrx/quake-kube:latest - - aarch64: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - name: Checkout - uses: actions/checkout@v3 - - run: sudo apt-get install -y qemu-user-static - - uses: cachix/install-nix-action@v21 + - uses: docker/setup-qemu-action@v3 + with: + platforms: arm64 + - uses: DeterminateSystems/nix-installer-action@v9 with: - extra_nix_config: | - system = aarch64-linux - - name: Build - run: | - nix build .#container - skopeo login --username "${{ github.actor }}" --password "${{ secrets.GITHUB_TOKEN }}" ghcr.io - skopeo copy docker-archive://$(readlink -f ./result) docker://ghcr.io/chrisrx/quake-kube:latest + extra-conf: | + extra-platforms = aarch64-linux + - uses: DeterminateSystems/magic-nix-cache-action@v2 + - run: nix run --impure .#dockerManifest + env: + VERSION: "latest" + GITHUB_TOKEN: ${{ github.token }} diff --git a/flake.lock b/flake.lock index 5f3a970..c75e43b 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,23 @@ { "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1701473968, + "narHash": "sha256-YcVE5emp1qQ8ieHUnxt1wCZCC3ZfAS+SRRWZ2TMda7E=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "34fed993f1674c8d06d58b37ce1e0fe5eebcb9f5", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -18,6 +36,29 @@ "type": "github" } }, + "flocken": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": [ + "nixpkgs" + ], + "systems": "systems_2" + }, + "locked": { + "lastModified": 1704105102, + "narHash": "sha256-c4VWO9plhINjQzYPHSKURWgQ2D2q24aI3OIN0MTPjz0=", + "owner": "mirkolenz", + "repo": "flocken", + "rev": "3a846dfca17f989805d9f4177de85c96dc0f8542", + "type": "github" + }, + "original": { + "owner": "mirkolenz", + "ref": "v2", + "repo": "flocken", + "type": "github" + } + }, "gomod2nix": { "inputs": { "flake-utils": [ @@ -57,9 +98,28 @@ "type": "github" } }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1701253981, + "narHash": "sha256-ztaDIyZ7HrTAfEEUt9AtTDNoCYxUdSd6NrRHaYOIxtk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e92039b55bcd58469325ded85d4f58dd5a4eaf58", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { "flake-utils": "flake-utils", + "flocken": "flocken", "gomod2nix": "gomod2nix", "nixpkgs": "nixpkgs" } @@ -78,6 +138,21 @@ "repo": "default", "type": "github" } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index ebb6ada..a18e0e7 100644 --- a/flake.nix +++ b/flake.nix @@ -6,8 +6,10 @@ inputs.gomod2nix.url = "github:nix-community/gomod2nix"; inputs.gomod2nix.inputs.nixpkgs.follows = "nixpkgs"; inputs.gomod2nix.inputs.flake-utils.follows = "flake-utils"; + inputs.flocken.url = "github:mirkolenz/flocken/v2"; + inputs.flocken.inputs.nixpkgs.follows = "nixpkgs"; - outputs = { self, nixpkgs, flake-utils, gomod2nix }: + outputs = { self, nixpkgs, flake-utils, gomod2nix, flocken }: (flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (system: let @@ -98,6 +100,15 @@ ]; config.Cmd = [ "${packages.default}/bin/q3" ]; }; + legacyPackages.dockerManifest = flocken.legacyPackages.${system}.mkDockerManifest { + github = { + enable = true; + repo = "chrisrx/quake-kube"; + token = builtins.getEnv "GITHUB_TOKEN"; + }; + version = builtins.getEnv "VERSION"; + images = with self.packages; [ x86_64-linux.container aarch64-linux.container ]; + }; devShells.default = pkgs.mkShell { diff --git a/internal/quake/server/gamefiles.go b/internal/quake/server/gamefiles.go index 8d09b90..312c3a3 100644 --- a/internal/quake/server/gamefiles.go +++ b/internal/quake/server/gamefiles.go @@ -8,6 +8,9 @@ import ( "log" "os" "path/filepath" + "strings" + + contentutil "github.com/ChrisRx/quake-kube/internal/quake/content/util" ) //go:embed EULA.txt @@ -44,6 +47,11 @@ func ExtractGameFiles(dir string) error { if err := os.WriteFile(path, data, 0644); err != nil { return err } + if strings.HasPrefix(hdr.Name, "linuxq3ademo") || strings.HasPrefix(hdr.Name, "linuxq3apoint") { + if err := contentutil.ExtractGzip(path, dir); err != nil { + return err + } + } } } return nil diff --git a/internal/quake/server/gamefiles.tar b/internal/quake/server/gamefiles.tar index 58b13c5..a702db8 100644 Binary files a/internal/quake/server/gamefiles.tar and b/internal/quake/server/gamefiles.tar differ