From f346a31cf46231f1c2beaeb5778662827f3b0497 Mon Sep 17 00:00:00 2001 From: sveitser Date: Fri, 11 Mar 2022 14:07:41 +0100 Subject: [PATCH] Use nix based docker base image - Use docker driver to load nix base image --- .dockerignore | 1 + .github/workflows/build.yml | 8 +++++--- Dockerfile | 5 +---- bin/build-docker-base | 3 +++ flake.nix | 10 ++++++++++ 5 files changed, 20 insertions(+), 7 deletions(-) create mode 100755 bin/build-docker-base diff --git a/.dockerignore b/.dockerignore index 5f78f927..704ac4aa 100644 --- a/.dockerignore +++ b/.dockerignore @@ -7,3 +7,4 @@ target/release/build target/release/deps target/release/examples target/release/incremental +target/doc diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index efbb81b0..9eefd149 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -98,11 +98,10 @@ jobs: name: wallet-webserver path: wallet-checkout/target/release/ - - name: Set linker/loader to not be nix - run: patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 wallet-checkout/target/release/web_server - - uses: docker/setup-buildx-action@v1 name: Setup Docker BuildKit (buildx) + with: + driver: docker - uses: docker/login-action@v1 name: Login to Github Container Repo @@ -118,6 +117,9 @@ jobs: with: images: ghcr.io/espressosystems/cape/wallet + - name: Generate base image + run: cd wallet-checkout && bin/build-docker-base + - uses: docker/build-push-action@v2 name: Build and Push Docker with: diff --git a/Dockerfile b/Dockerfile index 426fc4f5..5853559b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,4 @@ -FROM ubuntu:impish -RUN apt-get update \ - && apt-get install -y libcurl4 \ - && rm -rf /var/lib/apt/lists/* +FROM nix-base-docker COPY target/release/web_server /app/web_server COPY wallet/api /app/api COPY wallet/public /app/public diff --git a/bin/build-docker-base b/bin/build-docker-base new file mode 100755 index 00000000..c506edc1 --- /dev/null +++ b/bin/build-docker-base @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +nix --experimental-features "nix-command flakes" build .#docker +docker load --input result diff --git a/flake.nix b/flake.nix index e1603b4b..7e011886 100644 --- a/flake.nix +++ b/flake.nix @@ -57,6 +57,16 @@ }; }; }; + # A nix base image + packages.docker = pkgs.dockerTools.buildImage { + name = "nix-base-docker"; + tag = "latest"; + contents = with pkgs; [ + curl + coreutils + bashInteractive + ]; + }; devShell = let mySolc = pkgs.callPackage ./nix/solc-bin { version = "0.8.10"; };