diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000000000000000000000000000000000..45e1bbd02150732c802bcd7d9e4122a0761fc851 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +Dockerfile +docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 5e6ad3cb8977de5a992e583ae94ad8f99dbfabd1..0000000000000000000000000000000000000000 --- a/docker-compose.yml +++ /dev/null @@ -1,17 +0,0 @@ -version: "3.2" - -services: - dev: - container_name: duniter-v2s - image: paritytech/ci-linux:974ba3ac-20201006 - working_dir: /var/www/node-template - ports: - - "9944:9944" - environment: - - CARGO_HOME=/var/www/node-template/.cargo - volumes: - - .:/var/www/node-template - - type: bind - source: ./.local - target: /root/.local - command: bash -c "cargo build && ./target/debug/node-template --dev --ws-external" diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..cc930872f8edecbb09da27e6e457c53dacbe4df6 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,46 @@ +# ------------------------------------------------------------------------------ +# Build Stage +# ------------------------------------------------------------------------------ + +# Building for Debian buster because we need the binary to be compatible +# with the image paritytech/ci-linux:production (currently based on +# debian:buster-slim) used by the gitlab CI +FROM rust:1-buster as build +WORKDIR /root + +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y \ + clang + +# Copy source tree +COPY . . + +# build duniter +ARG threads=1 +RUN test -x build/duniter || \ + ( \ + CARGO_PROFILE_RELEASE_LTO="true" \ + cargo build --release -j $threads && \ + mkdir -p build && \ + mv target/release/duniter build/ \ + ) + +# ------------------------------------------------------------------------------ +# Final Stage +# ------------------------------------------------------------------------------ + +FROM debian:buster-slim + +LABEL maintainer="Gilles Filippini <gilles.filippini@pini.fr>" +LABEL version="0.0.0" +LABEL description="Crypto-currency software (based on Substrate framework) to operate Äž1 libre currency" + +# Intall +COPY --from=build /root/build/duniter /usr/local/bin/duniter +COPY docker/docker-entrypoint /usr/local/bin/ + +# Configuration +# rpc, rpc-ws, p2p, telemetry +EXPOSE 9933 9944 30333 9615 +VOLUME /var/lib/duniter +ENTRYPOINT ["docker-entrypoint"] diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000000000000000000000000000000000000..72e303d483e48c0b12c79e9bb41ec87708672878 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,24 @@ +version: "3.5" + +services: + duniter-v2s: + container_name: duniter-v2s + image: duniter-v2s + ports: + # telemetry + - "127.0.0.1:9615:9615" + # rpc + - "127.0.0.1:9933:9933" + # rpc-ws + - "127.0.0.1:9944:9944" + # p2p + - "30333:30333" + environment: + DUNITER_INSTANCE_NAME: "my_instance" + DUNITER_CHAIN_NAME: "dev" + #DUNITER_DISABLE_PROMETHEUS: "false" + volumes: + - data:/var/lib/lc-core + +volumes: + data: diff --git a/docker/docker-entrypoint b/docker/docker-entrypoint new file mode 100755 index 0000000000000000000000000000000000000000..4be5f28fa49267469c86dd42979e22267dbc483e --- /dev/null +++ b/docker/docker-entrypoint @@ -0,0 +1,37 @@ +#!/bin/bash + +function boolean () { + echo "$1" | sed -E 's/^(true|yes|1)$/true/i' +} + +function ternary () { + if [ $(boolean "$1") = true ]; then + echo "$2" + else + echo "$3" + fi +} + +if [ -n "$DUNITER_INSTANCE_NAME" ]; then + set -- "$@" --name "$DUNITER_INSTANCE_NAME" +fi + +DUNITER_DISABLE_PROMETHEUS=$(boolean "${DUNITER_DISABLE_PROMETHEUS:-false}") + +DUNITER_CHAIN_NAME="${DUNITER_CHAIN_NAME:-dev}" +case "$DUNITER_CHAIN_NAME" in + dev) + chain=(--dev) + ;; + *) + chain=(--chain "$DUNITER_CHAIN_NAME") + ;; +esac + +set -- "$@" \ + "${chain[@]}" \ + $(ternary "$DUNITER_DISABLE_PROMETHEUS" --no-prometheus) \ + --unsafe-ws-external -d /var/lib/duniter + +echo "Starting duniter with parameters:" "$@" +exec duniter "$@"