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/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..96dcafd823d1b8a355843b5431107c6527136c41 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,55 @@ +# ------------------------------------------------------------------------------ +# Build Stage +# ------------------------------------------------------------------------------ + +FROM alpine as build + +RUN apk update && \ + apk add ca-certificates curl && \ + update-ca-certificates && \ + apk add --update \ + cmake \ + make \ + pkgconfig \ + gcc \ + g++ \ + musl-dev \ + linux-headers \ + protoc \ + openssl-dev \ + clang-dev + +# install latest stable rust +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y + +# Copy source tree +COPY . . + +# build duniter +ARG threads=1 +RUN source ~/.cargo/env && \ + RUSTFLAGS="-C target-feature=-crt-static" \ + cargo build --release -j $threads + +# ------------------------------------------------------------------------------ +# Final Stage +# ------------------------------------------------------------------------------ + +FROM alpine + +LABEL maintainer="Gilles Filippini <gilles.filippini@pini.fr>" +LABEL version="0.0.0" +LABEL description="POC for a Substrate based Libre Currency implementation (https://libre-currency.org/)" + +# Dependancies +RUN apk update && \ + apk add libstdc++ + +# Intall +COPY --from=build /target/release/lc-core /usr/local/bin/lc-core +COPY docker-entrypoint /usr/local/bin/ + +# Configuration +EXPOSE 9944 +VOLUME /var/lib/lc-core +ENTRYPOINT ["docker-entrypoint"] diff --git a/docker-compose.yml b/docker-compose.yml index 5e6ad3cb8977de5a992e583ae94ad8f99dbfabd1..2ab8209a036f9f4c94bfc0f0d11684b75dd2abd0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,17 +1,15 @@ version: "3.2" services: - dev: + dunter-v2s: container_name: duniter-v2s - image: paritytech/ci-linux:974ba3ac-20201006 - working_dir: /var/www/node-template + image: duniter-v2s ports: - - "9944:9944" + - "127.0.0.1:9944:9944" environment: - - CARGO_HOME=/var/www/node-template/.cargo + DUNITER_INSTANCE_NAME: "my_instance" volumes: - - .:/var/www/node-template - - type: bind - source: ./.local - target: /root/.local - command: bash -c "cargo build && ./target/debug/node-template --dev --ws-external" + - data:/var/lib/lc-core + +volumes: + data: diff --git a/docker-entrypoint b/docker-entrypoint new file mode 100755 index 0000000000000000000000000000000000000000..3d50f3abf2238925cb51086205112d538478d266 --- /dev/null +++ b/docker-entrypoint @@ -0,0 +1,7 @@ +#!/bin/sh + +if [ -n "$DUNITER_INSTANCE_NAME" ]; then + set -- "$@" --name "$DUNITER_INSTANCE_NAME" +fi + +exec lc-core --dev --no-prometheus --ws-external -d /var/lib/lc-core "$@"