Skip to content

Commit

Permalink
multi-arch docker
Browse files Browse the repository at this point in the history
  • Loading branch information
icewind1991 committed Mar 17, 2024
1 parent e02a9de commit 21d5d94
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 29 deletions.
57 changes: 45 additions & 12 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,63 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
machine:
- platform: x86_64-linux
- platform: aarch64-linux
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
- 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 .#frontend
- run: nix build --option system .#frontend

build-docker:
runs-on: ubuntu-latest
needs: [build]
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 }} .#docker

docker:
runs-on: ubuntu-latest
needs: build
needs: [build-docker]
steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
uses: actions/checkout@v4
- uses: cachix/install-nix-action@v26
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#docker
- name: Push image
if: github.ref == 'refs/heads/main'
run: |
skopeo copy --dest-creds="${{ secrets.DOCKERHUB_USERNAME }}:${{ secrets.DOCKERHUB_TOKEN }}" "docker-archive:$(nix build .#docker --print-out-paths)" "docker://demostf/frontend"
- run: nix run .#dockerManifest
if: github.ref == 'refs/heads/master'
env:
VERSION: "1.0.0"
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
109 changes: 92 additions & 17 deletions flake.lock

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

20 changes: 20 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
rust-overlay.url = "github:oxalica/rust-overlay";
npmlock2nix.url = "github:nix-community/npmlock2nix";
npmlock2nix.flake = false;
flocken = {
url = "github:mirkolenz/flocken/v2";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = {
Expand All @@ -13,6 +17,7 @@
utils,
rust-overlay,
npmlock2nix,
flocken,
}:
utils.lib.eachDefaultSystem (system: let
overlays = [
Expand All @@ -28,12 +33,27 @@
pkgs = (import nixpkgs) {
inherit system overlays;
};
inherit (flocken.legacyPackages.${system}) mkDockerManifest;
in rec {
packages = rec {
node_modules = pkgs.demostf-frontend-node-modules;
frontend = pkgs.demostf-frontend;
docker = pkgs.demostf-frontend-docker;
default = frontend;

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

0 comments on commit 21d5d94

Please sign in to comment.