docs: update eclair section of build custom node images - #1029
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1029 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 151 156 +5
Lines 5513 5694 +181
Branches 1110 1095 -15
==========================================
+ Hits 5513 5694 +181 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
b804c34 to
fd0111e
Compare
AdamuAbba
left a comment
There was a problem hiding this comment.
Hey @rorp Great work on this PR! I can see the thought you've put into it.
I encountered an error and a few warnings after following the Eclair custom node setup and running the final command
Caution
+] Building 3.1s (5/5) FINISHED docker:desktop-linux => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 6.75kB 0.0s
=> WARN: StageNameCasing: Stage name 'BUILD' should be lowercase (line 1) 0.0s
=> WARN: FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 1) 0.0s
=> CANCELED [internal] load metadata for docker.io/library/openjdk:11.0.4-jre-slim 3.0s
=> ERROR [internal] load metadata for docker.io/adoptopenjdk/openjdk11:jdk-11.0.37-alpine 3.0s
=> [auth] library/openjdk:pull token for registry-1.docker.io 0.0s
=> [auth] adoptopenjdk/openjdk11:pull token for registry-1.docker.io 0.0s ------ > [internal] load metadata for docker.io/adoptopenjdk/openjdk11:jdk-11.0.3_7-alpine: ------ 2 warnings found (use docker --debug to expand): - StageNameCasing: Stage name 'BUILD' should be lowercase (line 1) - FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 1)
Dockerfile:1 --------------------
1 | >>> FROM adoptopenjdk/openjdk11:jdk-11.0.3_7-alpine as BUILD 2 |
3 | # Setup maven, we don't use https://hub.docker.com//maven/ as it declare .m2 as volume, we loose all mvn cache --------------------
ERROR: failed to solve: adoptopenjdk/openjdk11:jdk-11.0.3_7-alpine: failed to resolve source metadata for docker.io/adoptopenjdk/openjdk11:jdk-11.0.3_7-alpine: no match for platform in manifest: not found
View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/vkgg9f9p8ha0jzmzs7skivj03
I then made a few minor changes based on your work to address the errors above, built the image, and encountered some minor warnings below.
Warning
- 3 warnings found (use docker --debug to expand):
- LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format (line 20)
- LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format (line 21)
- JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals (line 83)
Proposed solution addressing errors and warnings
- Replace
adoptopenjdk/openjdk11:jdk-11.0.3_7-alpinewithadoptopenjdk/openjdk11:jdk-11.0.25_9-slimin Dockerfile - Swap out the
apkpackage manager command withapt-getfor compatibility with adoptopenjdk/openjdk11:jdk-11.0.25_9-slim - Refactor legacy ENV variable declarations
- Fix stage name
BUILDandas,FROMkeyword casing
Proposed Docker file revision
- FROM adoptopenjdk/openjdk11:jdk-11.0.3_7-alpine as BUILD
+ FROM adoptopenjdk/openjdk11:jdk-11.0.25_9-slim AS build
# Setup maven, we don't use https://hub.docker.com/_/maven/ as it declare .m2 as volume, we loose all mvn cache
# We can alternatively do as proposed by https://github.com/carlossg/docker-maven#packaging-a-local-repository-with-the-image
# this was meant to make the image smaller, but we use multi-stage build so we don't care
- RUN apk add --no-cache curl tar bash
+ RUN apt-get update && apt-get install -y curl tar bash
ARG MAVEN_VERSION=3.9.2
ARG USER_HOME_DIR="/root"
ARG SHA=900bdeeeae550d2d2b3920fe0e00e41b0069f32c019d566465015bdd1b3866395cbe016e22d95d25d51d3a5e614af2c83ec9b282d73309f644859bbad08b63db
ARG BASE_URL=https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries
RUN mkdir -p /usr/share/maven /usr/share/maven/ref \
&& curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \ && echo "${SHA} /tmp/apache-maven.tar.gz" | sha512sum -c - \ && tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \ && rm -f /tmp/apache-maven.tar.gz \ && ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
- ENV MAVEN_HOME /usr/share/maven
+ ENV MAVEN_HOME=/usr/share/maven
- ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"
+ ENV MAVEN_CONFIG="$USER_HOME_DIR/.m2"
# Let's fetch eclair dependencies, so that Docker can cache them
# This way we won't have to fetch dependencies again if only the source code changes
# The easiest way to reliably get dependencies is to build the project with no sources
WORKDIR /usr/src
COPY pom.xml pom.xml
COPY eclair-core/pom.xml eclair-core/pom.xml
COPY eclair-front/pom.xml eclair-front/pom.xml
COPY eclair-node/pom.xml eclair-node/pom.xml
COPY eclair-node/modules/assembly.xml eclair-node/modules/assembly.xml
RUN mkdir -p eclair-core/src/main/scala && touch eclair-core/src/main/scala/empty.scala
# Blank build. We only care about eclair-node, and we use install because eclair-node depends on eclair-core
#################### Polar Modification
ENV MAVEN_OPTS=-Xmx256m -XX:MaxPermSize=512m
####################
RUN mvn install -pl eclair-node -am
RUN mvn clean
# Only then do we copy the sources
COPY . .
# And this time we can build in offline mode, specifying 'notag' instead of git commit
RUN mvn package -pl eclair-node -am -DskipTests -Dgit.commit.id=notag -Dgit.commit.id.abbrev=notag -o
# It might be good idea to run the tests here, so that the docker build fail if the code is bugged
# We currently use a debian image for runtime because of some jni-related issue with sqlite
FROM openjdk:11.0.4-jre-slim
WORKDIR /app
# install jq for eclair-cli
RUN apt-get update && apt-get install -y bash jq curl unzip gosu
# copy and install eclair-cli executable
- COPY --from=BUILD /usr/src/eclair-core/eclair-cli .
+ COPY --from=build /usr/src/eclair-core/eclair-cli .
RUN chmod +x eclair-cli && mv eclair-cli /sbin/eclair-cli
# we only need the eclair-node.zip to run
- COPY --from=BUILD /usr/src/eclair-node/target/eclair-node-*.zip ./eclair-node.zip
+ COPY --from=build /usr/src/eclair-node/target/eclair-node-*.zip ./eclair-node.zip
RUN unzip eclair-node.zip && mv eclair-node-* eclair-node && chmod +x eclair-node/bin/eclair-node.sh
#################### Polar Modification
# Original lines:
# ENV ECLAIR_DATADIR=/data
# ENV JAVA_OPTS=
# RUN mkdir -p "$ECLAIR_DATADIR"
# VOLUME [ "/data" ]
# ENTRYPOINT JAVA_OPTS="${JAVA_OPTS}" eclair-node/bin/eclair-node.sh "-Declair.datadir=${ECLAIR_DATADIR}"
ENV ECLAIR_DATADIR=/home/eclair/
RUN chmod -R a+x eclair-node/*
RUN ls -al eclair-node/bin
COPY docker-entrypoint.sh /entrypoint.sh
RUN chmod a+x /entrypoint.sh
VOLUME ["/home/eclair"]
EXPOSE 9735 8080
ENTRYPOINT ["/entrypoint.sh"]
CMD $JAVA_OPTS bash eclair-node/bin/eclair-node.sh -Declair.datadir=$ECLAIR_DATADIR
####################
Note
The only warning I did not address was
JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals (line 83)
because I couldn't come up with a better way to refactor it.
fd0111e to
eacda24
Compare
|
@AdamuAbba It appears that your comments are outside the scope of this pull request, which only includes documentation changes. The |
Description
This PR adds a working version of the custom Dockerfile for Eclair
Steps to Test
Follow the steps https://github.com/rorp/polar/blob/master/docs/custom-nodes.md, but use the updated Dockerfile.