stuebinm
3f5369da14
This adds an instance of wink for the hacc-voc to hainich. Unfortunately, neither the actual package nor the container itself look very nixy, and e.g. cannot be configured declaratively. On the other hand, it does not appear the wink *has* any kind of config, so I guess there's that. Wink itself runs in a nixos container, but I've exposed its database to /var/lib/wink-db on the host, just to make it easier to access. After deployment, we still need to migrate our current database to this instance by hand (i.e. take the current database, rename it "development.sqlite3", and move it into the wink-db directory). Any improvements to this mess are welcome.
52 lines
1.4 KiB
Nix
52 lines
1.4 KiB
Nix
# for documentation on how this container works, have a look at
|
|
# https://wiki.infra4future.de/books/voc-infra/page/wink-65b
|
|
|
|
{ pkgs, config, ...}:
|
|
|
|
{
|
|
containers.wink = {
|
|
autoStart = true;
|
|
privateNetwork = true;
|
|
hostAddress = "192.168.100.10";
|
|
localAddress = "192.168.100.11";
|
|
|
|
# expose the wink database for easier backups / migrations
|
|
bindMounts."/var/lib/wink/db" = {
|
|
hostPath = "/var/lib/wink-db";
|
|
isReadOnly = false;
|
|
};
|
|
|
|
config = {pkgs, config, ...}: {
|
|
networking.firewall.allowedTCPPorts = [ 3000 ];
|
|
environment.systemPackages = [ pkgs.wink pkgs.v8 ];
|
|
|
|
systemd.services.wink = {
|
|
enable = true;
|
|
description = "Wo ist meine Winkekatze?";
|
|
wantedBy = [ "multi-user.target" ];
|
|
serviceConfig.type = "simple";
|
|
environment.HOME = "/var/lib/wink/home";
|
|
path = [ pkgs.wink pkgs.v8 ];
|
|
script = ''
|
|
mkdir -p /var/lib/wink/home
|
|
cd /var/lib/wink
|
|
cp -r ${pkgs.wink.outPath}/* .
|
|
if [ ! -f database.exists ]
|
|
then
|
|
rails-wrapped db:migrate db:seed RAILS_ENV=development
|
|
touch database.exists
|
|
fi
|
|
rails-wrapped server -b [::] -p 3000
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
|
|
services.nginx.virtualHosts."wink.hacc.space" = {
|
|
locations."/".proxyPass = "http://${config.containers.wink.localAddress}:3000";
|
|
forceSSL = true;
|
|
enableACME = true;
|
|
};
|
|
|
|
}
|