Skip to content

Commit 7765a2f

Browse files
authored
Use native releases in the Docker image (#180)
This a follow-up to #161, specifically: > The goal of using the JVM on docker was for compatibility with ARM. Once we support native ARM on Linux (#157), we could potentially move back to Alpine with native phoenixd, an even smaller footprint than before. I didn't go with Alpine because it isn't glibc based and we could run into compat issues. Nevertheless, with Debian slim the image size has been reduced from 230MB to 40MB (-80%). Cross-platform build: ```shell docker buildx build --platform linux/amd64,linux/arm64 -t acinq/phoenixd:0.6.0 --push .docker ``` From now on the image will be published on docker hub: https://hub.docker.com/repository/docker/acinq/phoenixd/general.
1 parent 0a46bbc commit 7765a2f

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

.docker/Dockerfile

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Use Ubuntu image for building for compatibility with macOS arm64 builds
2-
FROM eclipse-temurin:21-jdk-jammy AS build
2+
FROM --platform=$BUILDPLATFORM eclipse-temurin:21-jdk-jammy AS build
33

44
# Set necessary args and environment variables for building phoenixd
5-
ARG PHOENIXD_BRANCH=v0.5.1
6-
ARG PHOENIXD_COMMIT_HASH=ab9a026432a61d986d83c72df5619014414557be
5+
ARG TARGETPLATFORM
6+
ARG PHOENIXD_BRANCH=v0.6.0
7+
ARG PHOENIXD_COMMIT_HASH=fa318d9cd600aff45df132b7c01cbb959e66caa4
78

89
# Upgrade all packages and install dependencies
910
RUN apt-get update \
@@ -15,16 +16,22 @@ RUN apt-get install -y --no-install-recommends bash git \
1516
WORKDIR /phoenixd
1617
RUN git clone --recursive --single-branch --branch ${PHOENIXD_BRANCH} -c advice.detachedHead=false \
1718
https://github.com/ACINQ/phoenixd . \
18-
&& test `git rev-parse HEAD` = ${PHOENIXD_COMMIT_HASH} || exit 1 \
19-
&& ./gradlew jvmDistTar
19+
&& test `git rev-parse HEAD` = ${PHOENIXD_COMMIT_HASH} || exit 1
2020

21-
# JRE image to minimize final image size
22-
FROM eclipse-temurin:21-jre-jammy AS final
21+
RUN case "${TARGETPLATFORM}" in \
22+
"linux/amd64") ./gradlew linkPhoenixdReleaseExecutableLinuxX64 linkPhoenix-cliReleaseExecutableLinuxX64 ;; \
23+
"linux/arm64") ./gradlew linkPhoenixdReleaseExecutableLinuxArm64 linkPhoenix-cliReleaseExecutableLinuxArm64 ;; \
24+
*) echo "Unsupported TARGETPLATFORM: ${TARGETPLATFORM}" && exit 1 ;; \
25+
esac
26+
27+
# Slim image to minimize final image size (Alpine is smaller but not glibc-based)
28+
FROM debian:bookworm-slim AS final
2329

2430
# Upgrade all packages and install dependencies
2531
RUN apt-get update \
26-
&& apt-get upgrade -y
27-
RUN apt-get install -y --no-install-recommends bash
32+
&& apt-get upgrade -y \
33+
&& apt-get install -y --no-install-recommends bash \
34+
&& apt clean
2835

2936
# Create a phoenix group and user
3037
RUN addgroup --system phoenix --gid 1000 \
@@ -33,14 +40,16 @@ USER phoenix
3340

3441
# Unpack the release
3542
WORKDIR /phoenix
36-
COPY --chown=phoenix:phoenix --from=build /phoenixd/build/distributions/phoenixd-*-jvm.tar .
37-
RUN tar --strip-components=1 -xvf phoenixd-*-jvm.tar
43+
COPY --chown=phoenix:phoenix --from=build /phoenixd/build/bin/*/phoenixdReleaseExecutable/phoenixd.kexe phoenixd
44+
COPY --chown=phoenix:phoenix --from=build /phoenixd/build/bin/*/phoenix-cliReleaseExecutable/phoenix-cli.kexe phoenix-cli
3845

3946
# Indicate that the container listens on port 9740
4047
EXPOSE 9740
4148

49+
# Create the data directory so permissions are preserved when mounted as a volume (otherwise would be mounted as root)
50+
RUN mkdir -p /phoenix/.phoenix
4251
# Expose default data directory as VOLUME
43-
VOLUME [ "/phoenix" ]
52+
VOLUME [ "/phoenix/.phoenix" ]
4453

4554
# Run the daemon
46-
ENTRYPOINT ["/phoenix/bin/phoenixd", "--agree-to-terms-of-service", "--http-bind-ip", "0.0.0.0"]
55+
ENTRYPOINT ["/phoenix/phoenixd", "--agree-to-terms-of-service", "--http-bind-ip", "0.0.0.0"]

0 commit comments

Comments
 (0)