write-ups-challenges-2020-2021/gotta_catch_em_all/nix/frontend.nix

39 lines
814 B
Nix
Raw Normal View History

2022-11-24 17:03:20 +00:00
{ pkgs ? import <nixpkgs> {} }:
let utils = import ../../../deployment/utils.nix ;
nginx_conf = pkgs.writeTextFile {
name = "nginx.conf";
text= ''
user root;
daemon off;
error_log /dev/stdout info;
pid /dev/null;
events {}
http {
access_log /dev/stdout;
server {
listen 80;
index index.html;
root ${../frontend};
}
}
'';
};
in
pkgs.dockerTools.buildImage {
name = "frontend-gotta-catch-them-all";
tag = "latest";
contents = [ pkgs.nginx ] ;
runAsRoot = ''
${pkgs.dockerTools.shadowSetup}
mkdir -p var/log/nginx
mkdir -p var/cache/nginx
'';
config = {
ExposedPorts = {
"80/tcp" = {};
};
Cmd = [ "${pkgs.nginx}/bin/nginx" "-c" "${nginx_conf}" ];
} ;
}