write-ups-challenges-2020-2021/deployment/containers.nix

62 lines
1.8 KiB
Nix
Raw Permalink Normal View History

2022-11-24 17:03:20 +00:00
{ pkgs, ... }:
let
run = ({name, image, ports, environment ? {}, ... }@attrs:
let rest = builtins.removeAttrs attrs [ "name" "image" "ports" "environment" ]; in
{
image = name;
inherit ports;
imageFile = image;
inherit environment;
autoStart = true;
} // rest) ; in
{
options = {};
config = {
networking.firewall.allowedTCPPorts = [ 5000 8080 8081 9001 9002 9003 ];
virtualisation.oci-containers.containers = {
"schemingschemer1" = run {
name = "ss/1";
image = import ../scheming-schemer/first/nix/image.nix {};
ports = [ "9001:20000" ];
};
"schemingschemer2" = run {
name = "ss/2";
image = import ../scheming-schemer/second/nix/image.nix {};
ports = [ "9002:20000" ];
};
"schemingschemer3" = run {
name = "ss/3";
image = import ../scheming-schemer/third/nix/image.nix {};
ports = [ "9003:20000" ];
};
"fancy-text" = run {
name = "fancy-text";
image = import ../fancy_text/image.nix {};
ports = [ "9004:20000" ];
};
"gottacatchthemallfront" = run {
name = "frontend-gotta-catch-them-all";
image = import ../gotta_catch_em_all/nix/frontend.nix {};
ports = [ "8080:80" ];
};
"gottacatchthemallback" = run {
name = "gotta-catch-them-all-backend";
image = import ../gotta_catch_em_all/nix/backend.nix {};
ports = [ "5000:5000" ];
};
"lost-keys" = run {
name = "lost-keys";
image = import ../lost-keys/image.nix {};
ports = [ "2222:2222" ];
};
"ruby-challenge" = run {
name = "ruby-challenge";
image = import ../ruby_challenge/image.nix {};
ports = [ "8081:3000" ];
user = "joske:joske";
};
};
};
}