Skip to content

Commit

Permalink
try multi-arch docker
Browse files Browse the repository at this point in the history
  • Loading branch information
icewind1991 committed Mar 17, 2024
1 parent 20397c9 commit 5d6fb8e
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 7 deletions.
36 changes: 30 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,33 @@ jobs:
authToken: '${{ secrets.ATTIC_TOKEN }}'
- 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:
runs-on: ubuntu-latest
needs: [build, build-parser, api, phpunit]
needs: [build-docker, api, phpunit]
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -177,9 +201,9 @@ jobs:
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#docker
- name: Push image
- run: nix run --impure .#dockerManifest
if: github.ref == 'refs/heads/master'
run: |
skopeo copy --dest-creds="${{ secrets.DOCKERHUB_USERNAME }}:${{ secrets.DOCKERHUB_TOKEN }}" "docker-archive:$(nix build .#docker --print-out-paths)" "docker://demostf/api"
env:
VERSION: "1.0.0"
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
77 changes: 76 additions & 1 deletion flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@
inputs = {
nixpkgs.url = "nixpkgs/release-23.11";
utils.url = "github:numtide/flake-utils";
flocken = {
url = "github:mirkolenz/flocken/v2";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = {
self,
nixpkgs,
utils,
flocken,
}:
utils.lib.eachDefaultSystem (system: let
inherit (builtins) getEnv;
overlays = [
(import ./overlay.nix)
];
Expand All @@ -22,11 +28,26 @@
nodeLd = pkgs.writeShellScriptBin "node" ''
LD=$CC ${pkgs.nodejs_20}/bin/node $@
'';
inherit (flocken.legacyPackages.${system}) mkDockerManifest;
in rec {
packages = rec {
inherit (pkgs) demostf-api demostf-api-docker demostf-parser;
docker = demostf-api-docker;
default = demostf-api;

dockerManifest = mkDockerManifest {
tags = ["latest"];
registries = {
"docker" = {
enable = true;
repo = "demostf/api";
username = "$DOCKERHUB_USERNAME";
password = "$DOCKERHUB_TOKEN";
};
};
version = getEnv "VERSION";
images = with self.packages; [x86_64-linux.demostf-api-docker aarch64-linux.demostf-api-docker];
};
};
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
Expand Down

0 comments on commit 5d6fb8e

Please sign in to comment.