From 2964e34213f23bc9a90409c0a7a9be6c73ae253e Mon Sep 17 00:00:00 2001 From: Pierre-Marie Padiou Date: Wed, 10 Apr 2024 17:43:05 +0200 Subject: [PATCH] Add official Dockerfile (#17) The Dockerfile builds on windows x86, linux x86/arm and mac x86/arm. It uses a JVM build, which is simpler and more portable than native builds. --------- Co-authored-by: Seth For Privacy <40500387+sethforprivacy@users.noreply.github.com> --- .docker/Dockerfile | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .docker/Dockerfile diff --git a/.docker/Dockerfile b/.docker/Dockerfile new file mode 100644 index 0000000..d09f64a --- /dev/null +++ b/.docker/Dockerfile @@ -0,0 +1,46 @@ +# Use Ubuntu image for building for compatibility with macOS arm64 builds +FROM eclipse-temurin:21-jdk-jammy AS BUILD + +# Set necessary args and environment variables for building phoenixd +ARG PHOENIXD_BRANCH=v0.1.4 +ARG PHOENIXD_COMMIT_HASH=04bd430c48b09611ac201d44fe4a25c32aad0a5f + +# Upgrade all packages and install dependencies +RUN apt-get update \ + && apt-get upgrade -y +RUN apt-get install -y --no-install-recommends bash git \ + && apt clean + +# Git pull phoenixd source at specified tag/branch and compile phoenixd +WORKDIR /phoenixd +RUN git clone --recursive --single-branch --branch ${PHOENIXD_BRANCH} -c advice.detachedHead=false \ + https://github.com/ACINQ/phoenixd . \ + && test `git rev-parse HEAD` = ${PHOENIXD_COMMIT_HASH} || exit 1 \ + && ./gradlew distTar + +# Alpine image to minimize final image size +FROM eclipse-temurin:21-jre-alpine as FINAL + +# Upgrade all packages and install dependencies +RUN apk update \ + && apk upgrade --no-interactive +RUN apk add --update --no-cache bash + +# Create a phoenix group and user +RUN addgroup -S phoenix -g 1000 \ + && adduser -S phoenix -G phoenix -u 1000 -h /phoenix +USER phoenix + +# Unpack the release +WORKDIR /phoenix +COPY --chown=phoenix:phoenix --from=BUILD /phoenixd/build/distributions/phoenix-*-jvm.tar . +RUN tar --strip-components=1 -xvf phoenix-*-jvm.tar + +# Indicate that the container listens on port 9740 +EXPOSE 9740 + +# Expose default data directory as VOLUME +VOLUME [ "/phoenix" ] + +# Run the daemon +ENTRYPOINT ["/phoenix/bin/phoenixd", "--agree-to-terms-of-service", "--http-bind-ip", "0.0.0.0"]