diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000000000000000000000000000000000..ab8aaa028d882cb28dfcb4cef143664bd2264e3c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +.cargo +.git* +doc +gui +test diff --git a/doc/dev/git-conventions.md b/doc/dev/git-conventions.md index d9dffd0ef8c40869986330b7283d3a3023047159..e24449d055b9cca52f1b6c00bcd72652d20c9a90 100644 --- a/doc/dev/git-conventions.md +++ b/doc/dev/git-conventions.md @@ -28,7 +28,7 @@ The **action** must be a verb in imperative form, the **subject** a noun. For example, we rename the trait `Foo` to `Fii` in the `toto` module: - [ref] toto: rename Foo -> Fii + ref(toto): rename Foo -> Fii Commits must be lowercase. diff --git a/release/docker/Dockerfile b/release/docker/Dockerfile index af4de2ec14ee859b2aa1c679ceca41a6fda4c4b3..10e3a137fab3898b28278c66dc4728aeebcd33a7 100644 --- a/release/docker/Dockerfile +++ b/release/docker/Dockerfile @@ -27,7 +27,6 @@ RUN curl https://sh.rustup.rs -sSf | sh -s -- -y RUN PATH=${HOME}/.cargo/bin:${PATH} \ RUSTFLAGS="-C target-feature=-crt-static" \ make -C release ADD_DEBUG=N server-gui clean \ - && cp release/docker/duniter.sh work/docker.sh \ && rm -rf work/extra # ------------------------------------------------------------------------------ @@ -45,12 +44,10 @@ RUN addgroup -S -g 1111 duniter && \ RUN mkdir -p /var/lib/duniter /etc/duniter && chown duniter:duniter /var/lib/duniter /etc/duniter # copy the build artifact from the build stage -COPY --from=build --chown=duniter:duniter /duniter/work /duniter/duniter +COPY --from=build --chown=duniter:duniter /duniter/work /duniter -# copy bootstrap script -RUN cp /duniter/duniter/docker.sh /usr/bin/duniter && \ - chmod +x /usr/bin/duniter && \ - chown duniter:duniter /usr/bin/duniter +# install duniter executable symlink +RUN ln -s /duniter/bin/duniter /usr/bin/duniter # copy entrypoint COPY release/docker/docker-entrypoint.sh / diff --git a/release/docker/docker-entrypoint.sh b/release/docker/docker-entrypoint.sh index 4bf845b0bb9a75e5e9bf3bc07f880a62c60101dd..33fea165aafd5f6a9fbd0ed9feae7f0478c5e61a 100755 --- a/release/docker/docker-entrypoint.sh +++ b/release/docker/docker-entrypoint.sh @@ -12,64 +12,43 @@ if [ "$DEBUG_ENTRYPOINT" = true ]; then fi home=/var/lib/duniter -config=/etc/duniter home_default=$home/duniter_default manual_config="$(boolean "${DUNITER_MANUAL_CONFIG:-false}")" auto_sync="$(boolean "${DUNITER_AUTO_SYNC:-false}")" -# Use new path /etc/duniter/conf.json -if ! [ -f "$config/conf.json" ]; then - if [ "$(readlink "$home_default/conf.json")" = "$config/conf.json" ]; then - # The configuration file was moved already but the link is dangling - # It is likely that '/etc/duniter' is an anonymous volume - echo -e "$big_fat_warning Your configuration file didn't survive the restart!" - echo -e "$big_fat_warning Make sure that '/etc/duniter' is explicitely mounted as a persistent volume or you'll lose it again." - if [ -f "$home_default/conf.json.backup" ]; then - echo -e "$big_fat_warning Found backup file '$home_default/conf.json.backup'; using it..." - mv "$home_default/conf.json.backup" "$home_default/conf.json" - fi - fi - if [ -f "$home_default/conf.json" ]; then - echo "Moving existing configuration file '$home_default/conf.json' to its new location: '$config/conf.json'" - echo "A backup is kept at '$home_default/conf.json.backup'" - cp "$home_default/conf.json" "$home_default/conf.json.backup" - mv "$home_default/conf.json" "$config/conf.json" - fi -fi mkdir -p "$home/duniter_default" -ln -fs "$config/conf.json" "$home_default/conf.json" # Manual config when enabled if [ "$manual_config" = true ]; then # Do not start until a configuration file was initialized - while ! [ -f "$config/conf.json.orig" ]; do - echo "Waiting for initial configuration file... Please copy your configuration file to '$config/conf.json.orig'" + while ! [ -f "$home_default/conf.json.orig" ]; do + echo "Waiting for initial configuration file... Please copy your configuration file to '$home_default/conf.json.orig'" sleep 10 done echo "Configuration file found. Continuing..." # Use new conf.json.orig when changed - md5_file="$config/conf.json.orig.md5" + md5_file="$home_default/conf.json.orig.md5" if ! md5sum -c "$md5_file"; then - if [ -f "$config/conf.json" ]; then - echo "Backing up old configuration file to '$config/conf.json.old'..." - mv $config/conf.json $config/conf.json.old + if [ -f "$home_default/conf.json" ]; then + echo "Backing up old configuration file to '$home_default/conf.json.old'..." + mv $home_default/conf.json $home_default/conf.json.old fi echo "Installing new configuration file..." - cp "$config/conf.json.orig" "$config/conf.json" - md5sum "$config/conf.json.orig" >"$md5_file" + cp "$home_default/conf.json.orig" "$home_default/conf.json" + md5sum "$home_default/conf.json.orig" >"$md5_file" fi # Log differences between initial, old and current conf file - jq --sort-keys -r . "$config/conf.json.orig" >"$config/conf.json.orig.sorted" - jq --sort-keys -r . "$config/conf.json" >"$config/conf.json.sorted" - if [ -f "$config/conf.json.old" ]; then - jq --sort-keys -r . "$config/conf.json.old" >"$config/conf.json.old.sorted" - if ! diff -q "$config/conf.json.old.sorted" "$config/conf.json.orig.sorted"; then - diff -u "$config/conf.json.old.sorted" "$config/conf.json.orig.sorted" + jq --sort-keys -r . "$home_default/conf.json.orig" >"$home_default/conf.json.orig.sorted" + jq --sort-keys -r . "$home_default/conf.json" >"$home_default/conf.json.sorted" + if [ -f "$home_default/conf.json.old" ]; then + jq --sort-keys -r . "$home_default/conf.json.old" >"$home_default/conf.json.old.sorted" + if ! diff -q "$home_default/conf.json.old.sorted" "$home_default/conf.json.orig.sorted"; then + diff -u "$home_default/conf.json.old.sorted" "$home_default/conf.json.orig.sorted" fi fi - if ! diff -q "$config/conf.json.orig.sorted" "$config/conf.json.sorted"; then - diff -u "$config/conf.json.orig.sorted" "$config/conf.json.sorted" + if ! diff -q "$home_default/conf.json.orig.sorted" "$home_default/conf.json.sorted"; then + diff -u "$home_default/conf.json.orig.sorted" "$home_default/conf.json.sorted" fi fi @@ -86,7 +65,23 @@ if [ "$auto_sync" = true ]; then fi fi +# Network interface to listen to +export DUNITER_WEB_UI_HOST="0.0.0.0" + +# Key file found +if [ -f /etc/duniter/key.yml ]; then + export DUNITER_KEYFILE="/etc/duniter/keys.yml" +fi + +# Without parameters, start with web interface +if [ $# = 0 ]; then + set -- direct_webstart +fi + +# Set --home option +set -- --home "$home" "$@" + # Start duniter echo Starting duniter with: echo /usr/bin/duniter "$@" -/usr/bin/duniter "$@" +exec /usr/bin/duniter "$@" diff --git a/release/docker/duniter.sh b/release/docker/duniter.sh deleted file mode 100644 index f98ce59336076d27dca115d0e81292ff737145bb..0000000000000000000000000000000000000000 --- a/release/docker/duniter.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh - -# Without parameters, start with web interface -if [[ -z ${1} ]]; then - set -- direct_webstart -fi - -# Define DUNITER_WEB_UI_HOST -DUNITER_WEB_UI_HOST="0.0.0.0" -export DUNITER_WEB_UI_HOST - -# Define DUNITER_CONF_HOME -DUNITER_CONF_HOME="/etc/duniter" -export DUNITER_CONF_HOME - -# Key file found -if [[ -f /etc/duniter/key.yml ]]; then - DUNITER_KEYFILE="/etc/duniter/keys.yml" - export DUNITER_KEYFILE -fi - -# Start duniter -cd /duniter/duniter/ -bin/duniter --home /var/lib/duniter "$@"