diff --git a/.dockerignore b/.dockerignore index 1d085ca..3e7c0ed 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,6 @@ ** +!src +!Cargo.toml +!Cargo.lock +!flake.nix +!flake.lock diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 94032d0..6e9eccd 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -17,14 +17,7 @@ jobs: - uses: actions/checkout@v4 - uses: hustcer/setup-nu@v3 - - name: Build Docker image - run: | - version=$(nu -c "cargo metadata --format-version=1 --no-deps | from json | get packages | first | get version") - echo $version - - name: Run tests - run: cargo test --verbose - - name: Publish to crates.io - env: - CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} - run: | - cargo publish --verbose + - name: Get Cargo version + run: version=$(nu -c "cargo metadata --format-version=1 --no-deps | from json | get packages | first | get version") + - name: Build docker image + run: docker build -t docki:$version . diff --git a/Dockerfile b/Dockerfile index d506f3d..925c0e0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,11 @@ -FROM rust:slim +FROM nixos/nix AS build -WORKDIR /opt/rust +WORKDIR /app + +COPY . /app + +RUN nix --extra-experimental-features nix-command --extra-experimental-features flakes build \ + && nix --extra-experimental-features nix-command --extra-experimental-features flakes store gc + +RUN mkdir /out && cp result/bin/docki . -RUN apt update \ - && apt-get -y upgrade \ - && apt-get -y install libssl-dev pkg-config