From db510c863272208625f94a76d772156ba556336a Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Wed, 16 Dec 2020 12:15:50 +0100 Subject: [PATCH] Dockerfile improvements --- Cargo.lock | 4 ++-- Cargo.toml | 4 ++-- Dockerfile | 49 ++++++++++++++++++++++++++++------------------ src/bin/gossipd.rs | 2 +- 4 files changed, 35 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1882497..96f9d06 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -43,9 +43,9 @@ dependencies = [ [[package]] name = "amplify_derive" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "992c9ba9e4201debd030782f04d6315a037f4df0c517d336d0eeaa4586b2afd0" +checksum = "3ba06653cdfce8bfa4faf2c7e5cee3f21adf1bcc1e80ee2e1dec8be764014b0d" dependencies = [ "quote 1.0.7", "syn 1.0.48", diff --git a/Cargo.toml b/Cargo.toml index ea9ca3a..5541e17 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,8 +40,8 @@ required-features = ["cli"] [dependencies] # LNP/BP crates amplify = "~2.3.1" -amplify_derive = "~2.3.0" -lnpbp = { version = "=0.2.0-beta.2", features = ["lnp", "url", "websockets"] } +amplify_derive = "~2.3.1" +lnpbp = { version = "=0.2.0-beta.2", features = ["lnp", "websockets"] } lnpbp_derive = "=0.2.0-beta.2" lnpbp_services = "=0.2.0-beta.2" rgb_node = { version = "~0.2.0-beta.2", features = ["client", "fungibles"] } diff --git a/Dockerfile b/Dockerfile index ad901e8..41aee16 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,11 @@ +ARG BUILDER_DIR=/srv/lnp + + FROM rust:1.47.0-slim-buster as builder +ARG SRC_DIR=/usr/local/src/lnp +ARG BUILDER_DIR + RUN apt-get update -y \ && apt-get install -y \ libsqlite3-dev \ @@ -7,42 +13,47 @@ RUN apt-get update -y \ libzmq3-dev \ pkg-config -ENV SRC=/usr/local/src/lnpnode +WORKDIR "$SRC_DIR" + +COPY doc ${SRC_DIR}/doc +COPY shell ${SRC_DIR}/shell +COPY src ${SRC_DIR}/src +COPY build.rs Cargo.lock Cargo.toml codecov.yml config_spec.toml \ + LICENSE license_header.txt README.md ${SRC_DIR}/ -COPY doc ${SRC}/doc -COPY shell ${SRC}/shell -COPY src ${SRC}/src -COPY build.rs Cargo.lock Cargo.toml codecov.yml config_spec.toml LICENSE license_header.txt README.md ${SRC}/ +WORKDIR ${SRC_DIR} -WORKDIR ${SRC} +RUN mkdir "${BUILDER_DIR}" -RUN cargo install --path . --bins --all-features +RUN cargo install --path . --root "${BUILDER_DIR}" --bins --all-features FROM debian:buster-slim +ARG BUILDER_DIR +ARG BIN_DIR=/usr/local/bin +ARG DATA_DIR=/var/lib/lnp +ARG USER=lnpd + RUN apt-get update -y \ && apt-get install -y \ libzmq3-dev \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -COPY --from=builder /usr/local/cargo/bin/lnp-cli /usr/local/bin/ -COPY --from=builder /usr/local/cargo/bin/connectiond /usr/local/bin/ - -ENV APP_DIR=/srv/app USER=lnpnode -ENV CONF=${APP_DIR}/config.toml - -RUN adduser --home ${APP_DIR} --shell /bin/bash --disabled-login \ +RUN adduser --home "${DATA_DIR}" --shell /bin/bash --disabled-login \ --gecos "${USER} user" ${USER} +COPY --from=builder --chown=${USER}:${USER} \ + "${BUILDER_DIR}/bin/" "${BIN_DIR}" + +WORKDIR "${BIN_DIR}" USER ${USER} -RUN touch ${CONF} \ - && mkdir ${APP_DIR}/.lnp_node +VOLUME "$DATA_DIR" -WORKDIR ${APP_DIR} +EXPOSE 9735 -EXPOSE 9666 9735 +ENTRYPOINT ["lnpd"] -ENTRYPOINT ["connectiond", "-vvvv", "--listen", "--config=/srv/app/config.toml"] +CMD ["-vvv", "--data-dir", "/var/lib/lnp"] diff --git a/src/bin/gossipd.rs b/src/bin/gossipd.rs index 045e51a..b9ed93a 100644 --- a/src/bin/gossipd.rs +++ b/src/bin/gossipd.rs @@ -36,7 +36,7 @@ use lnp::gossipd::{self, Opts}; use lnp::Config; fn main() { - println!("gossipd: lightning peer network gossip microservice"); + println!("gossipd: lightning peer network gossip daemon"); let mut opts = Opts::parse(); trace!("Command-line arguments: {:?}", &opts);