Skip to content

Instantly share code, notes, and snippets.

@pta2002
Created November 9, 2020 20:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pta2002/5f5f4ff56cd0b92511478ef08366152a to your computer and use it in GitHub Desktop.
Save pta2002/5f5f4ff56cd0b92511478ef08366152a to your computer and use it in GitHub Desktop.
{ pkgs, config, ... }:
let
containerInPod = pod: container: container // {
extraOptions = [ "--pod" pod ];
};
in {
# Very very hacky way to ensure that the feedbin pod exists!
systemd.services.init-feedbin-pods = {
description = "Create the pod for feedbin";
after = [ "network.target" ];
serviceConfig.Type = "oneshot";
script = let podmancli = "${config.virtualisation.podman.package}/bin/podman";
in ''
${podmancli} pod rm --force feedbin-pod || true
${podmancli} pod create --name feedbin-pod -p 9292:9292 || true
'';
};
virtualisation.oci-containers = {
backend = "podman";
containers = {
feedbin = (containerInPod "feedbin-pod" {
image = "pta2002/feedbin:latest";
environment = {
RAILS_ENV = "production";
RACK_ENV = "production";
SECRET_KEY_BASE = "very very secret!!";
DATABASE_URL = "postgres://feedbin:feedbin@localhost:5432/feedbin";
REDIS_URL = "redis://localhost:6379";
FEEDBIN_HOST = "feedbin.pta2002.com";
MEMCACHED_HOSTS = "localhost:11211";
ELASTICSEARCH_URL = "http://localhost:9200";
EXTRACT_HOST = "localhost";
EXTRACT_PORT = "3000";
EXTRACT_SECRET = "extract";
EXTRACT_USER = "extract";
};
});
feedbin-extract = (containerInPod "feedbin-pod" {
image = "pta2002/feedbin-extract";
environment = {
EXTRACT_USER = "extract";
EXTRACT_SECRET = "extract";
};
});
feedbin-refresher = (containerInPod "feedbin-pod" {
image = "pta2002/feedbin-refresher:latest";
environment = {
REDIS_URL = "redis://localhost:6379";
};
});
postgres = (containerInPod "feedbin-pod" {
image = "postgres";
environment = {
POSTGRES_PASSWORD = "feedbin";
POSTGRES_USER = "feedbin";
POSTGRES_DB = "feedbin";
};
volumes = [ "postgresql_data:/var/lib/postgresql/data" ];
});
elasticsearch = (containerInPod "feedbin-pod" {
image = "elasticsearch:2.4";
});
memcached = (containerInPod "feedbin-pod" {
image = "memcached";
});
redis = (containerInPod "feedbin-pod" {
image = "redis";
});
};
};
services.nginx.virtualHosts."feedbin.pta2002.com" = {
enableACME = true;
forceSSL = true;
locations."/".proxyPass = "http://localhost:9292";
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment