containers: work on synchting container
This commit is contained in:
parent
10d015bb63
commit
d36545c419
1 changed files with 36 additions and 35 deletions
|
@ -9,33 +9,9 @@ let
|
||||||
|
|
||||||
in rec {
|
in rec {
|
||||||
|
|
||||||
base = let
|
base = pkgs.dockerTools.buildImage rec {
|
||||||
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 {
|
|
||||||
name = "base";
|
name = "base";
|
||||||
|
|
||||||
# contents = pkgs.symlinkJoin {
|
|
||||||
# name = "${name}-contents";
|
|
||||||
# paths = [
|
|
||||||
# system.build.etc
|
|
||||||
# system.path
|
|
||||||
# ];
|
|
||||||
# };
|
|
||||||
|
|
||||||
# Requires a VM to boot
|
# Requires a VM to boot
|
||||||
runAsRoot = ''
|
runAsRoot = ''
|
||||||
#!${pkgs.stdenv.shell}
|
#!${pkgs.stdenv.shell}
|
||||||
|
@ -50,8 +26,8 @@ in rec {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
interactiveBase = pkgs.dockerTools.buildImage {
|
interactive_base = pkgs.dockerTools.buildImage {
|
||||||
name = "interactiveBase";
|
name = "interactive_base";
|
||||||
fromImage = base;
|
fromImage = base;
|
||||||
contents = with pkgs; [
|
contents = with pkgs; [
|
||||||
procps
|
procps
|
||||||
|
@ -74,24 +50,43 @@ in rec {
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
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 \
|
exec mount.s3ql \
|
||||||
--cachedir "$S3QL_CACHE_DIR" \
|
--cachedir "$S3QL_CACHE_DIR" \
|
||||||
--authfile "$S3QL_AUTHINFO2" \
|
--authfile "$S3QL_AUTHINFO2" \
|
||||||
--cachesize "$S3QL_CACHESIZE" \
|
--cachesize "$S3QL_CACHESIZE" \
|
||||||
--fg \
|
--fg \
|
||||||
|
--compress lzma-6 \
|
||||||
|
--threads 4 \
|
||||||
--log none \
|
--log none \
|
||||||
--allow-root \
|
--allow-root \
|
||||||
s3c://e24files.com/steveej-backup \
|
"$S3QL_STORAGE_URL" \
|
||||||
/buckets/"$S3QL_BUCKET"
|
/bucket
|
||||||
|
|
||||||
# FIXME: touch .isbucket after mount
|
# FIXME: touch .isbucket after mount
|
||||||
'';
|
'';
|
||||||
in pkgs.dockerTools.buildImage {
|
in pkgs.dockerTools.buildImage {
|
||||||
name = "s3ql";
|
name = "s3ql";
|
||||||
fromImage = interactiveBase;
|
fromImage = interactive_base;
|
||||||
contents = [
|
contents = [
|
||||||
pkgs.s3ql
|
pkgs.s3ql
|
||||||
pkgs.fuse
|
pkgs.fuse
|
||||||
|
@ -110,7 +105,6 @@ in rec {
|
||||||
"HOME=/home/s3ql"
|
"HOME=/home/s3ql"
|
||||||
"S3QL_CACHE_DIR=/var/cache/s3ql"
|
"S3QL_CACHE_DIR=/var/cache/s3ql"
|
||||||
"S3QL_AUTHINFO2=/etc/s3ql/authinfo2"
|
"S3QL_AUTHINFO2=/etc/s3ql/authinfo2"
|
||||||
"S3QL_CACHESIZE=0"
|
|
||||||
"CONTAINER_ENTRYPOINT=${entrypoint}"
|
"CONTAINER_ENTRYPOINT=${entrypoint}"
|
||||||
];
|
];
|
||||||
Cmd = [ entrypoint ];
|
Cmd = [ entrypoint ];
|
||||||
|
@ -132,6 +126,15 @@ in rec {
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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 \
|
exec syncthing \
|
||||||
-home $SYNCTHING_HOME \
|
-home $SYNCTHING_HOME \
|
||||||
-gui-address=$SYNCTHING_GUI_ADDRESS \
|
-gui-address=$SYNCTHING_GUI_ADDRESS \
|
||||||
|
@ -139,17 +142,15 @@ in rec {
|
||||||
'';
|
'';
|
||||||
in pkgs.dockerTools.buildImage {
|
in pkgs.dockerTools.buildImage {
|
||||||
name = "syncthing";
|
name = "syncthing";
|
||||||
fromImage = interactiveBase;
|
fromImage = interactive_base;
|
||||||
contents = pkgs.syncthing;
|
contents = pkgs.syncthing;
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
Env = baseEnv ++ [
|
Env = baseEnv ++ [
|
||||||
"SYNCTHING_HOME=/home/syncthing"
|
"SYNCTHING_HOME=/home/syncthing"
|
||||||
"SYNCTHING_GUI_ADDRESS=0.0.0.0:8384"
|
|
||||||
];
|
];
|
||||||
Cmd = [ entrypoint ];
|
Cmd = [ entrypoint ];
|
||||||
Volumes = {
|
Volumes = {
|
||||||
"/home/syncthing" = {};
|
|
||||||
"/data" = {};
|
"/data" = {};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue