67 lines
1.1 KiB
Nix
67 lines
1.1 KiB
Nix
{ pkgs, ... }:
|
|
let
|
|
nginxConfig = pkgs.writeTextDir "/etc/nginx/nginx.conf" ''
|
|
user root;
|
|
daemon off;
|
|
pid /var/run/nginx.pid;
|
|
|
|
events { }
|
|
|
|
http {
|
|
include ${pkgs.nginx}/conf/mime.types;
|
|
default_type application/octet-stream;
|
|
|
|
charset utf-8;
|
|
|
|
access_log off;
|
|
error_log /dev/stderr;
|
|
|
|
server {
|
|
listen 80 default_server;
|
|
|
|
root /var/www/nginx;
|
|
index index.html;
|
|
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
}
|
|
}
|
|
'';
|
|
in
|
|
pkgs.dockerTools.buildImage {
|
|
name = "nginx";
|
|
fromImage = import ../base { inherit pkgs; };
|
|
|
|
copyToRoot = pkgs.buildEnv {
|
|
name = "root";
|
|
paths = with pkgs; [
|
|
nginxConfig
|
|
nginx
|
|
];
|
|
pathsToLink = [
|
|
"/bin"
|
|
"/etc"
|
|
];
|
|
};
|
|
|
|
runAsRoot = ''
|
|
mkdir -p /var/run /var/log/nginx
|
|
'';
|
|
|
|
config = {
|
|
Entrypoint = [ "nginx" ];
|
|
Cmd = [
|
|
"-c"
|
|
"/etc/nginx/nginx.conf"
|
|
];
|
|
WorkingDir = "/var/www/nginx";
|
|
Volumes = {
|
|
"/var/www/nginx" = { };
|
|
};
|
|
ExposedPorts = {
|
|
"80/tcp" = { };
|
|
};
|
|
};
|
|
}
|