-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docker: build image with nix instead of Dockerfile
- Loading branch information
1 parent
7727955
commit 3a9b449
Showing
5 changed files
with
123 additions
and
103 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,23 @@ | ||
.PHONY: data | ||
version=`cat VERSION` | ||
|
||
data: | ||
Rscript ./initialise_data.R | ||
|
||
docker-image: | ||
nix run .\#images.x86_64-linux.latest.copyToDockerDaemon | ||
|
||
release: | ||
# Run tests and build + push the 2 docker images tagged `latest` and `X.X.X` | ||
# according to the current version | ||
nix run .\#unit_tests | ||
nix run .\#test_ui | ||
nix run .\#images.x86_64-linux.latest.copyTo -- docker://docker.io/juliendiot/plantbreedgame:latest | ||
skopeo --insecure-policy copy docker://docker.io/juliendiot/plantbreedgame:latest docker://docker.io/juliendiot/plantbreedgame:$(version) | ||
|
||
dev-release: | ||
# Run tests and build + push the a docker images tagged `development` | ||
nix run .\#unit_tests | ||
nix run .\#test_ui | ||
nix run .\#images.x86_64-linux.latest.copyTo -- docker://docker.io/juliendiot/plantbreedgame:development | ||
|
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
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
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,62 @@ | ||
{ | ||
nix2containerPkgs, | ||
pkgs, | ||
}: { | ||
builder = { | ||
imageName ? null, | ||
plantBreedGame ? null, | ||
tag ? "latest", | ||
}: let | ||
setTimezone = pkgs.runCommand "setTimezone" {} '' | ||
mkdir -p $out/etc | ||
ln -s ${pkgs.tzdata}/share/zoneinfo/Asia/Tokyo $out/etc/localtime | ||
''; | ||
in | ||
nix2containerPkgs.nix2container.buildImage { | ||
name = imageName; | ||
tag = tag; | ||
maxLayers = 100; | ||
|
||
# force plantBreedGame and its dependencies to be in different layers | ||
layers = [ | ||
# dependencies layer | ||
(nix2containerPkgs.nix2container.buildLayer { | ||
deps = plantBreedGame.buildInput; | ||
maxLayers = 90; | ||
}) | ||
# plantBreedGame layer | ||
(nix2containerPkgs.nix2container.buildLayer { | ||
deps = plantBreedGame.buildInput; | ||
}) | ||
]; | ||
|
||
copyToRoot = [ | ||
(pkgs.buildEnv { | ||
name = "root"; | ||
paths = with pkgs; | ||
with pkgs.dockerTools; [ | ||
plantBreedGame | ||
setTimezone | ||
|
||
fakeNss | ||
tzdata | ||
|
||
bashInteractive | ||
coreutils | ||
usrBinEnv | ||
binSh | ||
]; | ||
ignoreCollisions = false; | ||
pathsToLink = ["/bin" "/var" "/run" "/tmp" "/etc" "/share"]; | ||
}) | ||
]; | ||
|
||
config = { | ||
WorkingDir = "/"; | ||
Run = ["touch" "/toto.txt"]; | ||
Volume = "/var/lib/plantBreedGame"; | ||
Cmd = ["${plantBreedGame}/bin/plantBreedGame" "--host" "0.0.0.0" "--port" "3838"]; | ||
Expose = 3838; | ||
}; | ||
}; | ||
} |