From 395d0a45df869e3576c9b884b20d0a8e7fb9c678 Mon Sep 17 00:00:00 2001 From: Ryan McGuire Date: Wed, 1 May 2019 12:09:13 -0400 Subject: [PATCH] lbrynet refactorings * Production: Multi-stage Dockerfile. * Production: Adds VERSION ARG to specify the lbrynet version to download. * Compiler: Adds REPO ARG to specify alternate git repository to build from. * Fixes checkmount arg passing. * Adds correct binding IP address to start.sh * Adds mountable config to start.sh * Does not yet add any Layered Config like #70 (it's harder 'cause yaml) --- lbrynet/Dockerfile-linux-multiarch-compiler | 5 ++-- lbrynet/Dockerfile-linux-x86_64-production | 29 +++++++++------------ lbrynet/stuff/checkmount.sh | 2 +- lbrynet/stuff/start.sh | 8 +++++- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/lbrynet/Dockerfile-linux-multiarch-compiler b/lbrynet/Dockerfile-linux-multiarch-compiler index d4baeaa..ce902ae 100644 --- a/lbrynet/Dockerfile-linux-multiarch-compiler +++ b/lbrynet/Dockerfile-linux-multiarch-compiler @@ -39,10 +39,11 @@ RUN apt-get update && \ FROM dependencies as compile +ARG REPO=https://github.com/lbryio/lbry.git ARG VERSION=master RUN python3.7 -m pip install -U pyinstaller && \ - git clone https://github.com/lbryio/lbry.git /lbry && \ - git -C /lbry checkout ${VERSION} + git clone ${REPO} /lbry && \ + git -C /lbry checkout ${VERSION} WORKDIR /lbry RUN git clone https://github.com/lbryio/torba.git --depth 1 /lbry/torba WORKDIR /lbry/torba diff --git a/lbrynet/Dockerfile-linux-x86_64-production b/lbrynet/Dockerfile-linux-x86_64-production index 7130965..eb41f89 100644 --- a/lbrynet/Dockerfile-linux-x86_64-production +++ b/lbrynet/Dockerfile-linux-x86_64-production @@ -1,30 +1,27 @@ ## This base image is for running the latest lbrynet-daemon release. -FROM ubuntu:18.04 +FROM ubuntu:18.04 as prep LABEL MAINTAINER="leopere [at] nixc [dot] us" +RUN apt-get update && apt-get -y install unzip curl ## Add lbrynet -ADD https://lbry.io/get/lbrynet.linux.zip /lbrynet/lbrynet.linux.zip +ARG VERSION=latest +RUN URL=$(curl -s https://api.github.com/repos/lbryio/lbry/releases/$(if [ "${VERSION}" = 'latest' ]; then echo "latest"; else echo "tags/${VERSION}"; fi) | grep browser_download_url | grep lbrynet-linux.zip | cut -d'"' -f4) && echo $URL && curl -L -o /lbrynet.linux.zip $URL -RUN apt-get update && apt-get -y install unzip && \ - adduser lbrynet --gecos GECOS --shell /bin/bash --disabled-password --home /home/lbrynet && \ - unzip /lbrynet/lbrynet.linux.zip -d /lbrynet/ && \ - rm /lbrynet/lbrynet.linux.zip && \ - chown -Rv lbrynet:lbrynet /lbrynet && \ - mv /lbrynet/lbrynet /bin/ - -COPY stuff/start.sh /usr/local/bin/start -COPY stuff/checkmount.sh /usr/local/bin/checkmount +COPY stuff/start.sh /usr/bin/start +COPY stuff/checkmount.sh /usr/bin/checkmount +RUN unzip /lbrynet.linux.zip -d /lbrynet/ && \ + mv /lbrynet/lbrynet /usr/bin && \ + chmod a+x /usr/bin/checkmount /usr/bin/start /usr/bin/lbrynet +FROM ubuntu:18.04 as app +COPY --from=prep /usr/bin/start /usr/bin/checkmount /usr/bin/lbrynet /usr/bin/ +RUN adduser lbrynet --gecos GECOS --shell /bin/bash --disabled-password --home /home/lbrynet ## Daemon port [Intended for internal use] ## LBRYNET talks to peers on port 3333 [Intended for external use] this port is used to discover other lbrynet daemons with blobs. ## Expose 5566 Reflector port to listen on ## Expose 5279 Port the daemon API will listen on ## the lbryumx aka Wallet port [Intended for internal use] EXPOSE 4444 3333 5566 5279 50001 - -## Example daemon_settings.yml is at https://github.com/lbryio/lbry/blob/master/example_daemon_settings.yml -ADD https://raw.githubusercontent.com/lbryio/lbry/master/example_daemon_settings.yml /etc/lbrynet/example_daemon_settings.yml -EXPOSE 5279 USER lbrynet -ENTRYPOINT ["/usr/local/bin/checkmount"] +ENTRYPOINT ["/usr/bin/checkmount"] CMD ["start"] diff --git a/lbrynet/stuff/checkmount.sh b/lbrynet/stuff/checkmount.sh index 637e037..4f77c11 100644 --- a/lbrynet/stuff/checkmount.sh +++ b/lbrynet/stuff/checkmount.sh @@ -8,5 +8,5 @@ if ! grep -qs ".* $mountpoint " /proc/mounts; then ## TODO: We should have documentation that this error references directly with a URL as to why it won't run without a volume. exit 1 else - `$@` + bash -c "$*" fi diff --git a/lbrynet/stuff/start.sh b/lbrynet/stuff/start.sh index 43ae4ba..c8ab4fc 100755 --- a/lbrynet/stuff/start.sh +++ b/lbrynet/stuff/start.sh @@ -1,2 +1,8 @@ #!/bin/bash -lbrynet start +CONFIG_PATH=/etc/lbry/daemon_settings.yml + +echo "Config: " +cat $CONFIG_PATH + +lbrynet start --api 0.0.0.0:5279 --config $CONFIG_PATH +