-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
216 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
.DS_Store | ||
/target | ||
/output | ||
result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Building the Dockerfile without having nix installed (inside docker) | ||
|
||
1. Starting the Docker container | ||
|
||
``` | ||
docker run -it --rm -v "$(pwd):/app" nixos/nix | ||
``` | ||
|
||
2. Enable flakes | ||
|
||
``` | ||
echo 'experimental-features = nix-command flakes' >> /etc/nix/nix.conf | ||
``` | ||
|
||
3. Switch to app directory | ||
|
||
``` | ||
cd /app | ||
``` | ||
|
||
4. Build the binary | ||
|
||
``` | ||
nix build .#bin | ||
``` | ||
|
||
5. Copy the binary to the output folder | ||
|
||
``` | ||
cp -r $(readlink -f result) output | ||
``` | ||
|
||
6. Build the Docker image | ||
|
||
``` | ||
nix build .#dockerImage | ||
``` | ||
|
||
7. Copy the Docker image to the output folder | ||
|
||
``` | ||
cp $(readlink -f result) output/docker-image.tar.gz | ||
``` | ||
|
||
# Importing the nix-built image into docker | ||
|
||
``` | ||
docker load -i output/docker-image.tar.gz | ||
``` |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
|
||
rust-overlay = { | ||
url = "github:oxalica/rust-overlay"; | ||
inputs = { | ||
nixpkgs.follows = "nixpkgs"; | ||
flake-utils.follows = "flake-utils"; | ||
}; | ||
}; | ||
|
||
crane = { | ||
url = "github:ipetkov/crane"; | ||
inputs = { nixpkgs.follows = "nixpkgs"; }; | ||
}; | ||
}; | ||
outputs = { self, nixpkgs, flake-utils, rust-overlay, crane }: | ||
flake-utils.lib.eachDefaultSystem (system: | ||
let | ||
overlays = [ (import rust-overlay) ]; | ||
pkgs = import nixpkgs { inherit system overlays; }; | ||
rustToolchain = pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile | ||
./rust-toolchain.toml; | ||
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain; | ||
src = craneLib.cleanCargoSource ./.; | ||
nativeBuildInputs = with pkgs; [ rustToolchain pkg-config ]; | ||
buildInputs = with pkgs; [ openssl libpcap ]; | ||
commonArgs = { inherit src buildInputs nativeBuildInputs; }; | ||
cargoArtifacts = craneLib.buildDepsOnly commonArgs; | ||
|
||
bin = craneLib.buildPackage (commonArgs // { | ||
inherit cargoArtifacts; | ||
|
||
# Compile but don't run the tests | ||
cargoTestExtraArgs = "--no-run"; | ||
}); | ||
|
||
dockerImage = pkgs.dockerTools.buildImage { | ||
name = "principal"; | ||
tag = "latest"; | ||
copyToRoot = [ bin ]; | ||
config = { Entrypoint = [ "${bin}/bin/principal" ]; }; | ||
}; | ||
in | ||
with pkgs; { | ||
packages = { | ||
inherit bin dockerImage; | ||
default = bin; | ||
}; | ||
devShells.default = mkShell { inputsFrom = [ bin ]; }; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[toolchain] | ||
channel = "stable" | ||
components = ["rustfmt", "rustc-dev", "clippy"] |