containers: work on synchting container

This commit is contained in:
steveej 2018-05-04 08:53:25 +02:00
parent 10d015bb63
commit d36545c419

View file

@ -9,33 +9,9 @@ let
in rec {
base = let
minimalDocker =
{
imports = [ <nixpkgs/nixos/modules/profiles/minimal.nix> ];
boot.isContainer = true;
environment.etc.machine-id.text = "00000000000000000000000000000000";
};
eval =
import <nixpkgs/nixos/lib/eval-config.nix> {
modules = [
minimalDocker
];
};
system =
eval.config.system;
in pkgs.dockerTools.buildImage rec {
base = pkgs.dockerTools.buildImage rec {
name = "base";
# contents = pkgs.symlinkJoin {
# name = "${name}-contents";
# paths = [
# system.build.etc
# system.path
# ];
# };
# Requires a VM to boot
runAsRoot = ''
#!${pkgs.stdenv.shell}
@ -50,8 +26,8 @@ in rec {
};
};
interactiveBase = pkgs.dockerTools.buildImage {
name = "interactiveBase";
interactive_base = pkgs.dockerTools.buildImage {
name = "interactive_base";
fromImage = base;
contents = with pkgs; [
procps
@ -74,24 +50,43 @@ in rec {
exit 1
fi
mkdir -p /buckets/"$S3QL_BUCKET"
if [ -z "$S3QL_STORAGE_URL" ]; then
echo S3QL_STORAGE_URL not set
exit 1
fi
if [ -z "$S3QL_CACHESIZE" ]; then
echo S3QL_CACHESIZE not set
exit 1
fi
set -x
if [ "$S3QL_SKIP_FSCK" != "1" ]; then
fsck.s3ql \
--authfile $S3QL_AUTHINFO2 \
--log none \
--cachedir $S3QL_CACHE_DIR \
$S3QL_STORAGE_URL
fi
exec mount.s3ql \
--cachedir "$S3QL_CACHE_DIR" \
--authfile "$S3QL_AUTHINFO2" \
--cachesize "$S3QL_CACHESIZE" \
--fg \
--compress lzma-6 \
--threads 4 \
--log none \
--allow-root \
s3c://e24files.com/steveej-backup \
/buckets/"$S3QL_BUCKET"
"$S3QL_STORAGE_URL" \
/bucket
# FIXME: touch .isbucket after mount
'';
in pkgs.dockerTools.buildImage {
name = "s3ql";
fromImage = interactiveBase;
fromImage = interactive_base;
contents = [
pkgs.s3ql
pkgs.fuse
@ -110,7 +105,6 @@ in rec {
"HOME=/home/s3ql"
"S3QL_CACHE_DIR=/var/cache/s3ql"
"S3QL_AUTHINFO2=/etc/s3ql/authinfo2"
"S3QL_CACHESIZE=0"
"CONTAINER_ENTRYPOINT=${entrypoint}"
];
Cmd = [ entrypoint ];
@ -132,6 +126,15 @@ in rec {
exit 1
fi
if [ -z "$SYNCTHING_GUI_ADDRESS" ]; then
echo ERROR: SYNCTHING_GUI_ADDRESS is not set
exit 1
fi
if [ ! -w "$SYNCTHING_HOME" ]; then
echo ERROR : SYNCTHING_HOME is not writable
fi
exec syncthing \
-home $SYNCTHING_HOME \
-gui-address=$SYNCTHING_GUI_ADDRESS \
@ -139,17 +142,15 @@ in rec {
'';
in pkgs.dockerTools.buildImage {
name = "syncthing";
fromImage = interactiveBase;
fromImage = interactive_base;
contents = pkgs.syncthing;
config = {
Env = baseEnv ++ [
"SYNCTHING_HOME=/home/syncthing"
"SYNCTHING_GUI_ADDRESS=0.0.0.0:8384"
];
Cmd = [ entrypoint ];
Volumes = {
"/home/syncthing" = {};
"/data" = {};
};
};