From 3d30108db2343efc2ef2c3aa9220a283d9b25209 Mon Sep 17 00:00:00 2001 From: Gilles Filippini <pini@debian.org> Date: Mon, 19 Jul 2021 23:16:59 +0200 Subject: [PATCH] build: docker image and compose file --- .dockerignore | 2 ++ Dockerfile | 55 ++++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 18 +++++++-------- docker-entrypoint | 7 ++++++ 4 files changed, 72 insertions(+), 10 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100755 docker-entrypoint diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..45e1bbd02 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +Dockerfile +docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..96dcafd82 --- /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 5e6ad3cb8..2ab8209a0 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 000000000..3d50f3abf --- /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 "$@" -- GitLab