build docker via nix
This commit is contained in:
parent
21e9e89de2
commit
ac3f245a1c
3 changed files with 35 additions and 49 deletions
|
@ -1,4 +0,0 @@
|
|||
/target
|
||||
|
||||
.env*
|
||||
!.envrc
|
22
Dockerfile
22
Dockerfile
|
@ -1,22 +0,0 @@
|
|||
FROM rust:1.62.0-slim-buster
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN cargo init .
|
||||
|
||||
COPY Cargo.* ./
|
||||
|
||||
RUN cargo build --release \
|
||||
&& rm -rf src
|
||||
|
||||
COPY ./src ./src
|
||||
|
||||
RUN cargo install --bin vnetod --path . \
|
||||
&& rm -rf ./src Cargo.*
|
||||
|
||||
VOLUME ["/data"]
|
||||
|
||||
WORKDIR /data
|
||||
|
||||
ENTRYPOINT ["/usr/local/cargo/bin/vnetod"]
|
||||
|
18
flake.nix
18
flake.nix
|
@ -10,8 +10,7 @@
|
|||
|
||||
version = "${cargoToml.package.version}_${builtins.substring 0 8 self.lastModifiedDate}_${self.shortRev or "dirty"}";
|
||||
in
|
||||
utils.lib.eachDefaultSystem
|
||||
(system:
|
||||
utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
inherit (nixpkgs) lib;
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
|
@ -24,6 +23,16 @@
|
|||
|
||||
doCheck = true;
|
||||
};
|
||||
|
||||
docker = pkgs.dockerTools.buildLayeredImage {
|
||||
name = "pleshevskiy/vnetod";
|
||||
tag = cargoToml.package.version;
|
||||
config = {
|
||||
Volumes."/data" = { };
|
||||
WorkingDir = "/data";
|
||||
Entrypoint = [ "${vnetod}/bin/vnetod" ];
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
apps.default = {
|
||||
|
@ -31,7 +40,10 @@
|
|||
program = "${vnetod}/bin/vnetod";
|
||||
};
|
||||
|
||||
packages.default = vnetod;
|
||||
packages = {
|
||||
inherit docker;
|
||||
default = vnetod;
|
||||
};
|
||||
|
||||
devShell = pkgs.mkShell {
|
||||
packages = with pkgs; [ cargo rustc rustfmt clippy rust-analyzer ];
|
||||
|
|
Loading…
Reference in a new issue