Closed sethforprivacy closed 8 months ago
Additionally, any specifics on expected dependencies would be helpful! It seems that gradlew tries to grab all dependencies directly asides from Java from what I could tell, but again, this is all quite outside of my wheelhouse :)
Phoenix depends on https://github.com/ACINQ/lightning-kmp (the core lightning implementation), specifically a version that we have not yet published to public repos. You need to compile it yourself but it's easy:
git clone https://github.com/ACINQ/lightning-kmp
git checkout v1.6.2-FEECREDIT-4
./gradlew publishToMavenLocal -x dokkaHtml
Phoenix depends on https://github.com/ACINQ/lightning-kmp (the core lightning implementation), specifically a version that we have not yet published to public repos. You need to compile it yourself but it's easy:
git clone https://github.com/ACINQ/lightning-kmp git checkout v1.6.2-FEECREDIT-4 ./gradlew publishToMavenLocal -x dokkaHtml
Ah, thank you so much, that should be trivial to add in those commands!
@pm47 thank you for that, was able to get further after adding that in! I have hit another issue now, though. I found that there were two unmentioned dependencies for phoenixd
, libcurl4-openssl-dev
and libsqlite3-dev
. I was able to chase both down and add them in, but now get a strange error related to glibc and libsqlite.
ROM gradle:8-jammy as build
ARG PHOENIXD_BRANCH=v0.1.1
ARG PHOENIXD_COMMIT_HASH=4e42a462e6cc7d0a09fb224820071991ac1a0eca
ARG LIGHTNING_KMP_BRANCH=v1.6.2-FEECREDIT-4
ARG LIGHTNING_KMP_COMMIT_HASH=eba5a5bf7d7d77bd59cb8e38ecd20ec72d288672
# Upgrade all packages and install dependencies
RUN apt-get update \
&& apt-get upgrade -y
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ca-certificates \
libcurl4-openssl-dev \
libsqlite3-dev \
git \
&& apt clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Set necessary args and environment variables for building phoenixd
ARG PHOENIXD_BRANCH
ARG PHOENIXD_COMMIT_HASH
ARG LIGHTNING_KMP_BRANCH
ARG LIGHTNING_KMP_COMMIT_HASH
# Build dependencies
WORKDIR /lightning-kmp
RUN git clone --recursive --branch ${LIGHTNING_KMP_BRANCH} \
https://github.com/ACINQ/lightning-kmp . \
&& test `git rev-parse HEAD` = ${LIGHTNING_KMP_COMMIT_HASH} || exit 1 \
&& ./gradlew publishToMavenLocal -x dokkaHtml
# Git pull phoenixd source at specified tag/branch and compile phoenixd binary
WORKDIR /phoenixd
RUN git clone --recursive --branch ${PHOENIXD_BRANCH} \
https://github.com/ACINQ/phoenixd . \
&& test `git rev-parse HEAD` = ${PHOENIXD_COMMIT_HASH} || exit 1 \
&& ./gradlew packageLinuxX64
1.527 Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
48.93 > Task :buildSrc:pluginDescriptors
48.93 > Task :buildSrc:processResources NO-SOURCE
51.33 > Task :buildSrc:compileKotlin
51.33 > Task :buildSrc:compileJava NO-SOURCE
51.33 > Task :buildSrc:compileGroovy NO-SOURCE
51.33 > Task :buildSrc:classes UP-TO-DATE
51.33
51.33 > Task :buildSrc:jar
51.33 :jar: No valid plugin descriptors were found in META-INF/gradle-plugins
66.33
66.33 > Task :buildVersionsTask
66.33 > Task :checkKotlinGradlePluginConfigurationErrors
72.13 > Task :xcodeVersion SKIPPED
72.83 > Task :generateCommonMainPhoenixDatabaseInterface
92.73 > Task :compileKotlinLinuxX64
122.6 > Task :linkPhoenix-cliDebugExecutableLinuxX64
151.9 e: /root/.konan/dependencies/x86_64-unknown-linux-gnu-gcc-8.3.0-glibc-2.19-kernel-4.9-2/x86_64-unknown-linux-gnu/bin/ld.gold invocation reported errors
151.9 Please try to disable compiler caches and rerun the build. To disable compiler caches, add the following line to the gradle.properties file in the project's root directory:
151.9
151.9 kotlin.native.cacheKind.linuxX64=none
151.9
151.9 Also, consider filing an issue with full Gradle log here: https://kotl.in/issue
151.9 The /root/.konan/dependencies/x86_64-unknown-linux-gnu-gcc-8.3.0-glibc-2.19-kernel-4.9-2/x86_64-unknown-linux-gnu/bin/ld.gold command returned non-zero exit code: 1.
151.9 output:
151.9 /usr/lib/x86_64-linux-gnu/libsqlite3.so: error: undefined reference to 'stat64', version 'GLIBC_2.33'
151.9 /usr/lib/x86_64-linux-gnu/libsqlite3.so: error: undefined reference to 'fstat64', version 'GLIBC_2.33'
151.9 /usr/lib/x86_64-linux-gnu/libsqlite3.so: error: undefined reference to 'lstat64', version 'GLIBC_2.33'
151.9 /usr/lib/x86_64-linux-gnu/libsqlite3.so: error: undefined reference to 'fcntl64', version 'GLIBC_2.28'
151.9 /usr/lib/x86_64-linux-gnu/libsqlite3.so: error: undefined reference to 'log', version 'GLIBC_2.29'
151.9 /usr/lib/x86_64-linux-gnu/libsqlite3.so: error: undefined reference to 'dlclose', version 'GLIBC_2.34'
151.9 /usr/lib/x86_64-linux-gnu/libsqlite3.so: error: undefined reference to 'dlerror', version 'GLIBC_2.34'
151.9 /usr/lib/x86_64-linux-gnu/libsqlite3.so: error: undefined reference to 'dlopen', version 'GLIBC_2.34'
151.9 /usr/lib/x86_64-linux-gnu/libsqlite3.so: error: undefined reference to 'dlsym', version 'GLIBC_2.34'
151.9 /usr/lib/x86_64-linux-gnu/libsqlite3.so: error: undefined reference to 'exp', version 'GLIBC_2.29'
151.9 /usr/lib/x86_64-linux-gnu/libsqlite3.so: error: undefined reference to 'pow', version 'GLIBC_2.29'
151.9 /usr/lib/x86_64-linux-gnu/libsqlite3.so: error: undefined reference to 'pthread_mutex_trylock', version 'GLIBC_2.34'
151.9 /usr/lib/x86_64-linux-gnu/libsqlite3.so: error: undefined reference to 'pthread_mutexattr_destroy', version 'GLIBC_2.34'
151.9 /usr/lib/x86_64-linux-gnu/libsqlite3.so: error: undefined reference to 'pthread_create', version 'GLIBC_2.34'
151.9 /usr/lib/x86_64-linux-gnu/libsqlite3.so: error: undefined reference to 'pthread_join', version 'GLIBC_2.34'
151.9 /usr/lib/x86_64-linux-gnu/libsqlite3.so: error: undefined reference to 'pthread_mutexattr_init', version 'GLIBC_2.34'
151.9 /usr/lib/x86_64-linux-gnu/libsqlite3.so: error: undefined reference to 'pthread_mutexattr_settype', version 'GLIBC_2.34'
151.9
151.9 > Task :linkPhoenix-cliDebugExecutableLinuxX64 FAILED
151.9
151.9 FAILURE: Build failed with an exception.
151.9
151.9 * What went wrong:
151.9 Execution failed for task ':linkPhoenix-cliDebugExecutableLinuxX64'.
151.9 > Compilation finished with errors
151.9
151.9 * Try:
151.9 > Run with --stacktrace option to get the stack trace.
151.9 > Run with --info or --debug option to get more log output.
151.9 > Run with --scan to get full insights.
151.9 > Get more help at https://help.gradle.org.
151.9
151.9 BUILD FAILED in 2m 30s
151.9 8 actionable tasks: 8 executed
Edit: after a bunch of searching the only related issue I could find across the interwebz was this one: https://github.com/ctripcorp/SQLlin/issues/48
@sethforprivacy probably relate to https://stackoverflow.com/a/73481501/10854225
@sethforprivacy probably relate to https://stackoverflow.com/a/73481501/10854225
Yikes, if so I'll probably just give up on building from source in the container and pivot to downloading binaries + checking hashes + sigs.
Didn't expect it would be so cumbersome to build compared to everything else I do this for. Thanks for the details, I'll close this for now and change up the approach.
Yikes, if so I'll probably just give up on building from source in the container and pivot to downloading binaries + checking hashes + sigs.
It is what I did
Is it possible to leave this issue open, please?
Yikes, if so I'll probably just give up on building from source in the container and pivot to downloading binaries + checking hashes + sigs.
It is what I did
Is it possible to leave this issue open, please?
For some reason I can't reopen on mobile but will do so ASAP.
Does that mean you have a workable solution for building in Docker you could share?
No I do not have any solution, I use the pre-compiled binaries
I got it working with the pre-compiled binaries as well
If anyone is wondering, here is the docker image
# Use a minimal Debian base image
FROM --platform=linux/amd64 debian:bullseye-slim
# Install necessary packages, including libcurl
RUN apt-get update && \
apt-get install -y wget unzip gnupg libcurl4 libcurl4-openssl-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Download and import the GPG key from ACINQ's website
RUN wget -qO- https://acinq.co/pgp/drouinf.asc | gpg --import
# Download the Phoenix binary and its signatures
WORKDIR /opt/phoenix
RUN wget https://github.com/ACINQ/phoenixd/releases/download/v0.1.1/phoenix-0.1.1-linux-x64.zip && \
wget https://github.com/ACINQ/phoenixd/releases/download/v0.1.1/SHA256SUMS.asc
# Verify the release file checksums and signatures
RUN gpg -d SHA256SUMS.asc > SHA256SUMS.stripped && \
grep 'phoenix-0.1.1-linux-x64.zip' SHA256SUMS.stripped > SHA256SUMS.filtered && \
sha256sum -c SHA256SUMS.filtered
# Unzip the downloaded file
RUN unzip -j phoenix-0.1.1-linux-x64.zip && \
chmod +x phoenixd
# Clean up unnecessary files
RUN rm phoenix-0.1.1-linux-x64.zip SHA256SUMS.asc SHA256SUMS.stripped
# Indicate that the container listens on port 9740
EXPOSE 9740
# Run the daemon
ENTRYPOINT ["./phoenixd", "--http-bind-ip", "0.0.0.0"]
Indeed the build instructions are lacking some dependencies.
The dockerfile below should do what you want. However I think building native binaries on docker is not the right approach. It would be better to run on the jvm: easier build, faster runtime and compatible with linux arm64, which we don't support otherwise. We'll add a jvm build for the next version.
FROM ubuntu:18.04 as build
ARG PHOENIXD_BRANCH=v0.1.1
ARG PHOENIXD_COMMIT_HASH=4e42a462e6cc7d0a09fb224820071991ac1a0eca
ARG LIGHTNING_KMP_BRANCH=v1.6.2-FEECREDIT-4
ARG LIGHTNING_KMP_COMMIT_HASH=eba5a5bf7d7d77bd59cb8e38ecd20ec72d288672
ARG CURL_VERSION=7.88.1
# Upgrade all packages and install dependencies
RUN apt-get update \
&& apt-get upgrade -y
RUN apt-get install -y --no-install-recommends \
ca-certificates \
openjdk-17-jdk \
openssh-client \
libgnutls28-dev \
libsqlite3-dev \
build-essential \
git \
wget \
&& apt clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Set necessary args and environment variables for building phoenixd
ARG PHOENIXD_BRANCH
ARG PHOENIXD_COMMIT_HASH
ARG LIGHTNING_KMP_BRANCH
ARG LIGHTNING_KMP_COMMIT_HASH
# Build dependencies
WORKDIR /lightning-kmp
RUN git clone --recursive --branch ${LIGHTNING_KMP_BRANCH} \
https://github.com/ACINQ/lightning-kmp . \
&& test `git rev-parse HEAD` = ${LIGHTNING_KMP_COMMIT_HASH} || exit 1 \
&& ./gradlew publishToMavenLocal -x dokkaHtml
WORKDIR /curl
RUN wget https://curl.se/download/curl-${CURL_VERSION}.tar.bz2 \
&& tar -xjvf curl-${CURL_VERSION}.tar.bz2 \
&& cd curl-${CURL_VERSION} \
&& ./configure --with-gnutls=/lib/x86_64-linux-gnu/ \
&& make \
&& make install \
&& ldconfig
# Git pull phoenixd source at specified tag/branch and compile phoenixd binary
WORKDIR /phoenixd
RUN git clone --recursive --branch ${PHOENIXD_BRANCH} \
https://github.com/ACINQ/phoenixd . \
&& test `git rev-parse HEAD` = ${PHOENIXD_COMMIT_HASH} || exit 1 \
&& ./gradlew packageLinuxX64
# Indicate that the container listens on port 9740
EXPOSE 9740
# Run the daemon
ENTRYPOINT ["/phoenixd/build/bin/linuxX64/phoenixdReleaseExecutable/phoenixd.kexe", "--http-bind-ip", "0.0.0.0"]
Thanks for the source Dockerfile. I am using this docker-compose.yaml
alongside to map the seed and channels volumes ~/.phoenix
outside the container on to the host machine. Thanks.
version: "3"
services:
phoenixd:
build: .
image: phoenixd:latest
container_name: phoenixd
volumes:
- ./dotphoenix:/root/.phoenix
expose:
- 9740
ports:
- 9740:9740
The problem is not just with docker but also with arch linux
@pm47 Do you think that using the library that you use inside your docker example can fix this problem? or a different libc is a problem also there?
Thanks so much for the help with this, @pm47! I was able to use your Dockerfile as a base to build out precisely what I wanted, including a separate builder/final stage to reduce final image size greatly.
For anyone interested you can find my working Dockerfile here:
https://github.com/sethforprivacy/phoenixd-docker/blob/main/Dockerfile
@pm47 Do you think that using the library that you use inside your docker example can fix this problem? or a different libc is a problem also there?
@vincenzopalazzo Both: it needs a recent libcurl (the exact version doesn't really matter) compiled against an old glibc 🙃 . Prebuilt binaries typically have old/old or new/new.
You can use linkerOpts("--allow-shlib-undefined")
to work around this but we don't recommend it as it could in theory cause crashes at runtime.
I think I can use nix to solve this problem @pm47 thanks :)
Hi there, first off thanks for this amazing tool! I can see this slotting into the toolkit of many merchants and organizations, and wanted to do what I could to simplify it's usage there.
I was working on Dockerizing it but hit a snag that is beyond my Gradle/Java knowledge. If you have any guidance on where to go next, AFAICT this should be a good base but errors out for me here:
Dockerfile:
Error: