Created
February 22, 2018 20:19
-
-
Save asconix/92eb810fba2ae6fbb6e7150b4a27eb45 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs ? import <nixpkgs> {} }: | |
with pkgs; | |
let | |
entrypoint = writeScript "entrypoint.sh" '' | |
#!${stdenv.shell} | |
set -e | |
# allow the container to be started with `--user` | |
if [ "$1" = "redis-server" -a "$(${coreutils}/bin/id -u)" = "0" ]; then | |
chown -R redis . | |
exec ${goPackages.gosu.bin}/bin/gosu redis "$BASH_SOURCE" "$@" | |
fi | |
exec "$@" | |
''; | |
in | |
dockerTools.buildImage { | |
name = "redis"; | |
runAsRoot = '' | |
#!${stdenv.shell} | |
${dockerTools.shadowSetup} | |
groupadd -r redis | |
useradd -r -g redis -d /data -M redis | |
mkdir /data | |
chown redis:redis /data | |
''; | |
contents = [ redis ]; | |
config = { | |
Cmd = [ "redis-server" ]; | |
Entrypoint = [ entrypoint ]; | |
ExposedPorts = { | |
"6379/tcp" = {}; | |
}; | |
WorkingDir = "/data"; | |
Volumes = { | |
"/data" = {}; | |
}; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment