From c22384420dfb84b7a62b8f6abd369986767848f6 Mon Sep 17 00:00:00 2001 From: pingu Date: Mon, 21 Oct 2024 15:03:58 +0200 Subject: [PATCH 1/3] build via nix >:3 --- .dockerignore | 5 ----- .gitignore | 1 + Dockerfile | 18 ------------------ docker-compose.yml | 2 +- flake.nix | 13 +++++++++++++ 5 files changed, 15 insertions(+), 24 deletions(-) delete mode 100644 .dockerignore delete mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 5619214..0000000 --- a/.dockerignore +++ /dev/null @@ -1,5 +0,0 @@ -dist-newstyle -Dockerfile -docker-compose.yml -flake.nix -flake.lock diff --git a/.gitignore b/.gitignore index 214f149..febc1f0 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ cabal.sandbox.config dist-newstyle/ result/ logs/ +result diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 60552cd..0000000 --- a/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM haskell:9.6.6 as BIN -WORKDIR /app/user -COPY *.cabal ./ - -RUN cabal v2-update && \ - cabal v2-build --dependencies-only - -COPY . . -RUN cabal v2-install --install-method copy --installdir . --overwrite-policy=always - -FROM debian:12.5-slim -RUN apt-get update && apt-get install --no-install-recommends -y ca-certificates \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* -COPY --from=BIN /app/user/mat-chalmers /bin/mat-chalmers -ENV LANG C.UTF-8 -CMD /bin/mat-chalmers -EXPOSE 5007 diff --git a/docker-compose.yml b/docker-compose.yml index ba79122..1c85b43 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,6 @@ services: mat: - build: . + image: mat-chalmers:latest restart: unless-stopped ports: - "5007:5007" diff --git a/flake.nix b/flake.nix index 0ccdf67..5d87515 100644 --- a/flake.nix +++ b/flake.nix @@ -36,6 +36,15 @@ packages = rec { default = mat; mat = pkgs.haskell.packages.${ghcVer}.mat; + docker = pkgs.dockerTools.buildLayeredImage { + name = "mat-chalmers"; + tag = "latest"; + contents = with pkgs; [ cacert glibcLocalesUtf8 ]; + config = { + Cmd = "${mat}/bin/mat-chalmers"; + Env = [ "LANG=C.UTF-8" ]; + }; + }; }; checks = { @@ -78,7 +87,11 @@ # # don't check version bounds # friendly = hlib.doJailbreak hprev.friendly; + # }); + }; }; + + } From 30268e8f35b71f0fb4eac7df94681c62d8dd704d Mon Sep 17 00:00:00 2001 From: pingu Date: Mon, 21 Oct 2024 18:40:21 +0200 Subject: [PATCH 2/3] Github action time --- .github/workflows/publish-docker-image.yml | 27 ++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/publish-docker-image.yml b/.github/workflows/publish-docker-image.yml index 8c30a18..6fbc13c 100644 --- a/.github/workflows/publish-docker-image.yml +++ b/.github/workflows/publish-docker-image.yml @@ -29,19 +29,22 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract Docker metadata - id: meta - uses: docker/metadata-action@v5 + - name: Install nix + uses: cachix/install-nix-action@v27 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + extra_nix_config: | + trusted-public-keys = pingu.cachix.org-1:42+JuilNrMORsv7pUKCrpzAB5ykq1Y7XVEf+Wl8TVFg= + substituters-extra = https://pingu.cachix.org - - name: Build and push Docker image - id: build-and-push - uses: docker/build-push-action@v5 + - run: nix build .\#docker + - run: docker load < ./result + + - name: Push To quay.io + id: push-to-quay + uses: redhat-actions/push-to-registry@v2 with: - context: . - push: true + image: mat-chalmers tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max + registry: ${{ env.REGISTRY }} + username: ${{ secrets.GITHUB_TOKEN }} + password: ${{ secrets.GITHUB_TOKEN }} From 73079d1a43176f4b05f5c651e5ece5b7a6f3160f Mon Sep 17 00:00:00 2001 From: pingu Date: Mon, 21 Oct 2024 20:14:00 +0200 Subject: [PATCH 3/3] Ooopsie --- flake.nix | 4 ---- 1 file changed, 4 deletions(-) diff --git a/flake.nix b/flake.nix index 5d87515..16b4dc5 100644 --- a/flake.nix +++ b/flake.nix @@ -87,11 +87,7 @@ # # don't check version bounds # friendly = hlib.doJailbreak hprev.friendly; - # }); - }; }; - - }