Skip to content

Instantly share code, notes, and snippets.

@xavierzwirtz
Created January 26, 2020 05:57
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 xavierzwirtz/74157f70771cdbc1db465dffbe188852 to your computer and use it in GitHub Desktop.
Save xavierzwirtz/74157f70771cdbc1db465dffbe188852 to your computer and use it in GitHub Desktop.
{ pkgs ? import <nixpkgs> { } }:
with pkgs;
pkgs.dockerTools.buildLayeredImage {
name = "hgweb";
tag = "latest";
contents = [
pkgs.nginx
pkgs.bash
pkgs.coreutils
pkgs.mercurial
(pkgs.python2.withPackages (ps : [ps.numpy]))
pkgs.vim
pkgs.curl
pkgs.apacheHttpd
pkgs.apacheHttpdPackages.mod_wsgi
(writeTextFile {
name = "passwd";
text = builtins.concatStringsSep "\n" [
"daemon:x:1:1:daemon:/:/bin/sh"
"www-data:x:2:2:www-data:/:/bin/sh"
];
destination = "/etc/passwd"; })
(writeTextFile {
name = "group";
text = builtins.concatStringsSep "\n" [
"daemon:x:1:daemon"
"www-data:x:1:www-data"
];
destination = "/etc/group"; })
];
extraCommands = ''
#!${pkgs.stdenv.shell}
# create dummy hgrc to keep debuginstall happy
#[ui]
#username = Dummy User <nobody@example.com>
#cp ${./dummyhgrc} ~/hgrc
${mercurial}/bin/hg debuginstall
httpd_conf=$(cat ${apacheHttpd}/conf/httpd.conf)
module_load_conf="LoadModule wsgi_module ${pkgs.apacheHttpdPackages.mod_wsgi}/modules/mod_wsgi.so"
hg_conf=$(cat ${./hg.conf})
echo "$httpd_conf" >> httpd.conf
echo "$module_load_conf" >> httpd.conf
echo "$hg_conf" >> httpd.conf
cp -r ${./htdocs} hg-htdocs
cp ${./entrypoint.sh} entrypoint.sh
cp ${./make_repo.sh} make_repo.sh
chmod +x entrypoint.sh
chmod +x make_repo.sh
'';
config = {
Cmd = ["/entrypoint.sh"];
ExposedPorts = {
"80/tcp" = {};
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment