From 1d3e5b7a39f15623c92cbe287d357804479300cd Mon Sep 17 00:00:00 2001 From: Ryan McGuire Date: Tue, 23 Apr 2019 16:33:24 -0400 Subject: [PATCH] Three stage Dockerfile for lbrynet ARM and X86_64 --- lbrynet/linux-armhf-compiler/Dockerfile | 101 +++++++++++------------ lbrynet/linux-armhf-compiler/start.sh | 3 +- lbrynet/linux-x86_64-compiler/Dockerfile | 100 +++++++++++----------- lbrynet/linux-x86_64-compiler/start.sh | 3 +- 4 files changed, 100 insertions(+), 107 deletions(-) mode change 100755 => 100644 lbrynet/linux-armhf-compiler/start.sh mode change 100755 => 100644 lbrynet/linux-x86_64-compiler/start.sh diff --git a/lbrynet/linux-armhf-compiler/Dockerfile b/lbrynet/linux-armhf-compiler/Dockerfile index b3f19a9..ad8e7ff 100644 --- a/lbrynet/linux-armhf-compiler/Dockerfile +++ b/lbrynet/linux-armhf-compiler/Dockerfile @@ -1,55 +1,52 @@ -FROM multiarch/ubuntu-core:armhf-bionic +FROM multiarch/ubuntu-core:armhf-bionic as dependencies +RUN apt-get update && \ + apt-get install -y \ + python3-pip \ + python3.7 \ + python3.7-dev \ + build-essential \ + libssl-dev \ + libacl1-dev \ + liblz4-dev \ + libfuse-dev \ + fuse \ + pkg-config \ + fakeroot \ + git \ + zlib1g-dev \ + libbz2-dev \ + libncurses5-dev \ + libreadline-dev \ + liblzma-dev \ + libsqlite3-dev \ + zip \ + libffi-dev \ + libleveldb-dev && \ + update-alternatives --install /usr/bin/python python /usr/bin/python3.7 1 && \ + update-alternatives --install /usr/bin/python python /usr/bin/python3.7 10 && \ + update-alternatives --config python && \ + python --version && \ + pip3 --version -RUN apt update && \ - apt install -y \ - python3-pip \ - python3.7 \ - python3.7-dev \ - build-essential \ - libssl-dev \ - libacl1-dev \ - liblz4-dev \ - libfuse-dev \ - fuse \ - pkg-config \ - fakeroot \ - git \ - zlib1g-dev \ - libbz2-dev \ - libncurses5-dev \ - libreadline-dev \ - liblzma-dev \ - libsqlite3-dev \ - zip \ - libffi-dev +FROM dependencies as compile -RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.7 1 && \ - update-alternatives --install /usr/bin/python python /usr/bin/python3.7 10 && \ - update-alternatives --config python && \ - python --version && \ - pip3 --version +RUN python3.7 -m pip install -U pyinstaller && \ + git clone https://github.com/lbryio/lbry.git --depth 1 /lbry && \ + cd /lbry && \ + git clone https://github.com/lbryio/torba.git --depth 1 /lbry/torba && \ + cd /lbry/torba && python3.7 -m pip install -e . && \ + cd /lbry/ && python3.7 scripts/set_build.py && \ + python3.7 -m pip install -e . && \ + pyinstaller -F -n lbrynet lbrynet/extras/cli.py && \ + chmod +x /lbry/dist/lbrynet && \ + zip -j /lbry/dist/lbrynet-armhf.zip /lbry/dist/lbrynet && \ + mkdir /target && \ + /lbry/dist/lbrynet --version - -RUN python3.7 -m pip install -U pyinstaller cryptography aiohttp coincurve pbkdf2 cryptography attrs pylru - -## SPLIT CONTAINER HERE. -RUN git clone https://github.com/lbryio/lbry.git --depth 1 /lbry && \ - cd /lbry && \ - git clone https://github.com/lbryio/torba.git --depth 1 /lbry/torba - -RUN sed -i -e "s/'plyvel',//" /lbry/torba/setup.py && \ - cd /lbry/torba && python3.7 -m pip install -e . && cd /lbry/ && \ - python3.7 scripts/set_build.py && \ - python3.7 -m pip install -e . && \ - pyinstaller -F -n lbrynet lbrynet/extras/cli.py - -RUN echo "checking contents of /lbry/dist/" && ls -lAh /lbry/dist/ && \ - echo "checking contents of /" && ls -lAh / && \ - echo "redundantly setting executable bit for good measure" && chmod +x /lbry/dist/lbrynet && \ - echo "compressing lbrynet armhf binary" && zip -j /lbry/dist/lbrynet-armhf.zip /lbry/dist/lbrynet && \ - echo "creating /target/" && mkdir /target -COPY ./start.sh /usr/local/bin/start - -RUN /lbry/dist/lbrynet --version - -CMD start +FROM multiarch/ubuntu-core:armhf-bionic as app +RUN adduser lbrynet --gecos GECOS --shell /bin/bash --disabled-password --home /home/lbrynet +COPY start.sh /usr/local/bin/start +COPY --from=compile /lbry/dist/lbrynet /usr/local/bin/ +EXPOSE 5279 +USER lbrynet +CMD ["start"] diff --git a/lbrynet/linux-armhf-compiler/start.sh b/lbrynet/linux-armhf-compiler/start.sh old mode 100755 new mode 100644 index 13da549..7aa0dcc --- a/lbrynet/linux-armhf-compiler/start.sh +++ b/lbrynet/linux-armhf-compiler/start.sh @@ -1,3 +1,2 @@ #!/bin/bash -sleep 2 -cp /lbry/dist/lbrynet-armhf.zip /target/ +echo "TODO" diff --git a/lbrynet/linux-x86_64-compiler/Dockerfile b/lbrynet/linux-x86_64-compiler/Dockerfile index 6a8d6fd..ad1b3df 100644 --- a/lbrynet/linux-x86_64-compiler/Dockerfile +++ b/lbrynet/linux-x86_64-compiler/Dockerfile @@ -1,54 +1,52 @@ -FROM ubuntu:18.04 +FROM ubuntu:18.04 as dependencies +RUN apt-get update && \ + apt-get install -y \ + python3-pip \ + python3.7 \ + python3.7-dev \ + build-essential \ + libssl-dev \ + libacl1-dev \ + liblz4-dev \ + libfuse-dev \ + fuse \ + pkg-config \ + fakeroot \ + git \ + zlib1g-dev \ + libbz2-dev \ + libncurses5-dev \ + libreadline-dev \ + liblzma-dev \ + libsqlite3-dev \ + zip \ + libffi-dev \ + libleveldb-dev && \ + update-alternatives --install /usr/bin/python python /usr/bin/python3.7 1 && \ + update-alternatives --install /usr/bin/python python /usr/bin/python3.7 10 && \ + update-alternatives --config python && \ + python --version && \ + pip3 --version -RUN apt update && \ - apt install -y \ - python3-pip \ - python3.7 \ - python3.7-dev \ - build-essential \ - libssl-dev \ - libacl1-dev \ - liblz4-dev \ - libfuse-dev \ - fuse \ - pkg-config \ - fakeroot \ - git \ - zlib1g-dev \ - libbz2-dev \ - libncurses5-dev \ - libreadline-dev \ - liblzma-dev \ - libsqlite3-dev \ - zip \ - libffi-dev +FROM dependencies as compile -RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.7 1 && \ - update-alternatives --install /usr/bin/python python /usr/bin/python3.7 10 && \ - update-alternatives --config python && \ - python --version && \ - pip3 --version +RUN python3.7 -m pip install -U pyinstaller && \ + git clone https://github.com/lbryio/lbry.git --depth 1 /lbry && \ + cd /lbry && \ + git clone https://github.com/lbryio/torba.git --depth 1 /lbry/torba && \ + cd /lbry/torba && python3.7 -m pip install -e . && \ + cd /lbry/ && python3.7 scripts/set_build.py && \ + python3.7 -m pip install -e . && \ + pyinstaller -F -n lbrynet lbrynet/extras/cli.py && \ + chmod +x /lbry/dist/lbrynet && \ + zip -j /lbry/dist/lbrynet-armhf.zip /lbry/dist/lbrynet && \ + mkdir /target && \ + /lbry/dist/lbrynet --version - -RUN python3.7 -m pip install -U pyinstaller cryptography aiohttp coincurve pbkdf2 cryptography attrs pylru - -## Split container here. -RUN git clone https://github.com/lbryio/lbry.git --depth 1 /lbry && \ - cd /lbry && \ - git clone https://github.com/lbryio/torba.git --depth 1 /lbry/torba - -RUN cd /lbry/torba && python3.7 -m pip install -e . && cd /lbry/ && \ - python3.7 scripts/set_build.py && \ - python3.7 -m pip install -e . && \ - pyinstaller -F -n lbrynet lbrynet/extras/cli.py - -RUN echo "checking contents of /lbry/dist/" && ls -lAh /lbry/dist/ && \ - echo "checking contents of /" && ls -lAh / && \ - echo "redundantly setting executable bit for good measure" && chmod +x /lbry/dist/lbrynet && \ - echo "compressing lbrynet x86_64 binary" && zip -j /lbry/dist/lbrynet-x86_64.zip /lbry/dist/lbrynet && \ - echo "creating /target/" && mkdir /target -COPY ./start.sh /usr/local/bin/start - -RUN /lbry/dist/lbrynet --version - -CMD start +FROM ubuntu:18.04 as app +RUN adduser lbrynet --gecos GECOS --shell /bin/bash --disabled-password --home /home/lbrynet +COPY start.sh /usr/local/bin/start +COPY --from=compile /lbry/dist/lbrynet /usr/local/bin/ +EXPOSE 5279 +USER lbrynet +CMD ["start"] diff --git a/lbrynet/linux-x86_64-compiler/start.sh b/lbrynet/linux-x86_64-compiler/start.sh old mode 100755 new mode 100644 index 519c9a3..7aa0dcc --- a/lbrynet/linux-x86_64-compiler/start.sh +++ b/lbrynet/linux-x86_64-compiler/start.sh @@ -1,3 +1,2 @@ #!/bin/bash -sleep 2 -cp /lbry/dist/lbrynet-x86_64.zip /target/ +echo "TODO"