add docker files to machine config
This commit is contained in:
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
[submodule "usda-vision"]
|
||||
path = usda-vision
|
||||
url = git@github.com:salirezav/usda-vision.git
|
||||
111
default.nix
111
default.nix
@@ -9,7 +9,7 @@
|
||||
# nix-lxc = {
|
||||
# devices = {
|
||||
# "usda-dash" = builtins.fetchGit {
|
||||
# url = "https://github.com/UGA-Innovation-Factory/usda-dash-config";
|
||||
# url = "https://git.factory.uga.edu/MODEL/usda-dash-config.git";
|
||||
# rev = "commit-hash";
|
||||
# };
|
||||
# };
|
||||
@@ -22,31 +22,120 @@
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
# Create a derivation that packages the usda-vision directory
|
||||
usda-vision-app = pkgs.stdenv.mkDerivation {
|
||||
pname = "usda-vision";
|
||||
version = "1.0.0";
|
||||
|
||||
# Use the directory from this repository
|
||||
src = ./usda-vision;
|
||||
|
||||
nativeBuildInputs = [ pkgs.makeWrapper ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/opt/usda-vision
|
||||
|
||||
# Copy all application files
|
||||
cp -r $src/* $out/opt/usda-vision/
|
||||
|
||||
# Create convenience scripts
|
||||
mkdir -p $out/bin
|
||||
|
||||
cat > $out/bin/usda-vision-start <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
cd $out/opt/usda-vision
|
||||
${pkgs.docker-compose}/bin/docker-compose up -d --build
|
||||
EOF
|
||||
|
||||
cat > $out/bin/usda-vision-stop <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
cd $out/opt/usda-vision
|
||||
${pkgs.docker-compose}/bin/docker-compose down
|
||||
EOF
|
||||
|
||||
cat > $out/bin/usda-vision-logs <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
cd $out/opt/usda-vision
|
||||
${pkgs.docker-compose}/bin/docker-compose logs -f "$@"
|
||||
EOF
|
||||
|
||||
cat > $out/bin/usda-vision-restart <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
cd $out/opt/usda-vision
|
||||
${pkgs.docker-compose}/bin/docker-compose restart "$@"
|
||||
EOF
|
||||
|
||||
chmod +x $out/bin/usda-vision-*
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "USDA Vision camera management system";
|
||||
maintainers = [ "UGA Innovation Factory" ];
|
||||
};
|
||||
};
|
||||
in
|
||||
|
||||
{
|
||||
# ========== Module Configuration ==========
|
||||
config = {
|
||||
# System packages specific to usda-dash
|
||||
environment.systemPackages = with pkgs; [
|
||||
# Add any dashboard-specific tools here
|
||||
# Core tools
|
||||
git
|
||||
vim
|
||||
htop
|
||||
curl
|
||||
wget
|
||||
|
||||
# Docker and Docker Compose for running usda-vision
|
||||
docker
|
||||
docker-compose
|
||||
|
||||
# USDA Vision application package with convenience scripts
|
||||
usda-vision-app
|
||||
];
|
||||
|
||||
# SSH is already configured by the host type module
|
||||
# Only override if you need different settings:
|
||||
# services.openssh.settings.PermitRootLogin = lib.mkForce "no";
|
||||
|
||||
# Configure users (these will be added via inventory.nix extraUsers)
|
||||
# Enable Docker service
|
||||
virtualisation.docker = {
|
||||
enable = true;
|
||||
autoPrune.enable = true;
|
||||
# Configure users
|
||||
athenix.users.sv22900.enable = true;
|
||||
athenix.users.hdh20267.enable = true;
|
||||
|
||||
# Dashboard-specific services could go here
|
||||
# Example:
|
||||
# services.nginx.enable = true;
|
||||
# services.postgresql.enable = true;
|
||||
# Add users to docker group
|
||||
users.users.sv22900.extraGroups = [ "docker" ];
|
||||
users.users.hdh20267.extraGroups = [ "docker" ];
|
||||
|
||||
# Systemd service to manage usda-vision docker compose
|
||||
systemd.services.usda-vision = {
|
||||
description = "USDA Vision Docker Compose Stack";
|
||||
after = [ "docker.service" "network-online.target" ];
|
||||
wants = [ "network-online.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
WorkingDirectory = "${usda-vision-app}/opt/usda-vision";
|
||||
|
||||
# Start: pull latest images and start containers
|
||||
ExecStart = "${pkgs.docker-compose}/bin/docker-compose up -d --build";
|
||||
|
||||
# Stop: gracefully stop containers
|
||||
ExecStop = "${pkgs.docker-compose}/bin/docker-compose down";
|
||||
|
||||
# Reload: restart containers
|
||||
ExecReload = "${pkgs.bash}/bin/bash -c '${pkgs.docker-compose}/bin/docker-compose down && ${pkgs.docker-compose}/bin/docker-compose up -d --build'";
|
||||
|
||||
TimeoutStartSec = 300;
|
||||
TimeoutStopSec = 120;
|
||||
};
|
||||
}; TimeoutStartSec = 300;
|
||||
TimeoutStopSec = 120;
|
||||
};
|
||||
};
|
||||
|
||||
# Firewall configuration
|
||||
# networking.firewall.allowedTCPPorts = [ 80 443 ];
|
||||
|
||||
1
usda-vision
Submodule
1
usda-vision
Submodule
Submodule usda-vision added at 0ef87a9aea
Reference in New Issue
Block a user