1
0
Fork 0
mirror of https://codeberg.org/demostf/api.git synced 2026-06-03 09:54:17 +02:00

try multi-arch docker

This commit is contained in:
Robin Appelman 2024-03-17 16:09:37 +01:00
commit b40c237a56
3 changed files with 127 additions and 7 deletions

View file

@ -166,9 +166,33 @@ jobs:
authToken: '${{ secrets.ATTIC_TOKEN }}' authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build --option system ${{ matrix.machine.platform }} - run: nix build --option system ${{ matrix.machine.platform }}
build-docker:
runs-on: ubuntu-latest
needs: [build, build-parser]
strategy:
matrix:
machine:
- platform: x86_64-linux
- platform: aarch64-linux
steps:
- uses: actions/checkout@v4
- if: matrix.machine.platform != 'x86_64-linux'
uses: docker/setup-qemu-action@v3
- uses: cachix/install-nix-action@v26
with:
extra_nix_config: |
extra-platforms = aarch64-linux
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build --option system ${{ matrix.machine.platform }} .#demostf-api-docker
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [build, build-parser, api, phpunit] needs: [build-docker, api, phpunit]
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
@ -177,9 +201,9 @@ jobs:
with: with:
name: ci name: ci
instance: https://cache.icewind.me instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}' - run: nix run .#dockerManifest
- run: nix build .#docker
- name: Push image
if: github.ref == 'refs/heads/master' if: github.ref == 'refs/heads/master'
run: | env:
skopeo copy --dest-creds="${{ secrets.DOCKERHUB_USERNAME }}:${{ secrets.DOCKERHUB_TOKEN }}" "docker-archive:$(nix build .#docker --print-out-paths)" "docker://demostf/api" VERSION: "1.0.0"
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}

77
flake.lock generated
View file

@ -1,5 +1,46 @@
{ {
"nodes": { "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"
}
},
"flocken": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": [
"nixpkgs"
],
"systems": "systems"
},
"locked": {
"lastModified": 1704105102,
"narHash": "sha256-c4VWO9plhINjQzYPHSKURWgQ2D2q24aI3OIN0MTPjz0=",
"owner": "mirkolenz",
"repo": "flocken",
"rev": "3a846dfca17f989805d9f4177de85c96dc0f8542",
"type": "github"
},
"original": {
"owner": "mirkolenz",
"ref": "v2",
"repo": "flocken",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1710523508, "lastModified": 1710523508,
@ -15,8 +56,27 @@
"type": "indirect" "type": "indirect"
} }
}, },
"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": { "root": {
"inputs": { "inputs": {
"flocken": "flocken",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"utils": "utils" "utils": "utils"
} }
@ -36,9 +96,24 @@
"type": "github" "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"
}
},
"utils": { "utils": {
"inputs": { "inputs": {
"systems": "systems" "systems": "systems_2"
}, },
"locked": { "locked": {
"lastModified": 1710146030, "lastModified": 1710146030,

View file

@ -2,14 +2,20 @@
inputs = { inputs = {
nixpkgs.url = "nixpkgs/release-23.11"; nixpkgs.url = "nixpkgs/release-23.11";
utils.url = "github:numtide/flake-utils"; utils.url = "github:numtide/flake-utils";
flocken = {
url = "github:mirkolenz/flocken/v2";
inputs.nixpkgs.follows = "nixpkgs";
};
}; };
outputs = { outputs = {
self, self,
nixpkgs, nixpkgs,
utils, utils,
flocken,
}: }:
utils.lib.eachDefaultSystem (system: let utils.lib.eachDefaultSystem (system: let
inherit (builtins) getEnv;
overlays = [ overlays = [
(import ./overlay.nix) (import ./overlay.nix)
]; ];
@ -22,11 +28,26 @@
nodeLd = pkgs.writeShellScriptBin "node" '' nodeLd = pkgs.writeShellScriptBin "node" ''
LD=$CC ${pkgs.nodejs_20}/bin/node $@ LD=$CC ${pkgs.nodejs_20}/bin/node $@
''; '';
inherit (flocken.legacyPackages.${system}) mkDockerManifest;
in rec { in rec {
packages = rec { packages = rec {
inherit (pkgs) demostf-api demostf-api-docker demostf-parser; inherit (pkgs) demostf-api demostf-api-docker demostf-parser;
docker = demostf-api-docker; docker = demostf-api-docker;
default = demostf-api; default = demostf-api;
dockerManifest = mkDockerManifest {
tags = ["latest"];
registries = {
"docker.io" = {
enable = true;
repo = "demostf/api";
username = "$DOCKERHUB_USERNAME";
password = "$DOCKERHUB_TOKEN";
};
};
version = "1.0.0";
images = with self.packages; [x86_64-linux.demostf-api-docker aarch64-linux.demostf-api-docker];
};
}; };
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [ nativeBuildInputs = with pkgs; [