From 1efbe1cb239ebf8ed98f908a2144bf3d11c99919 Mon Sep 17 00:00:00 2001 From: James Browning Date: Thu, 13 Feb 2025 15:46:21 +0000 Subject: [PATCH 1/2] fix: Dockerfile build pubky-testnet --- Dockerfile | 5 +++-- pubky-testnet/README.md | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index df766cb..3f930ae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -45,11 +45,11 @@ COPY Cargo.toml Cargo.lock ./ COPY . . # Build the project in release mode for the MUSL target -RUN cargo build --release --bin pubky-homeserver --target $TARGETARCH-unknown-linux-musl +RUN cargo build --release --bin pubky-homeserver --bin pubky-testnet --target $TARGETARCH-unknown-linux-musl # Strip the binary to reduce size RUN strip target/$TARGETARCH-unknown-linux-musl/release/pubky-homeserver - +RUN strip target/$TARGETARCH-unknown-linux-musl/release/pubky-testnet # ======================== # Runtime Stage # ======================== @@ -62,6 +62,7 @@ RUN apk add --no-cache ca-certificates # Copy the compiled binary from the builder stage COPY --from=builder /usr/src/app/target/$TARGETARCH-unknown-linux-musl/release/pubky-homeserver /usr/local/bin/homeserver +COPY --from=builder /usr/src/app/target/$TARGETARCH-unknown-linux-musl/release/pubky-testnet /usr/local/bin/testnet # Set the working directory WORKDIR /usr/local/bin diff --git a/pubky-testnet/README.md b/pubky-testnet/README.md index 7f17efe..44eb00f 100644 --- a/pubky-testnet/README.md +++ b/pubky-testnet/README.md @@ -2,7 +2,7 @@ A local test network for developing Pubky Core or applications depending on it. -All resources are ephemeral, databases are in the operating system's temporaray directories, and all servers are closed as the testnet dropped. +All resources are ephemeral, databases are in the operating system's temporary directories, and all servers are closed as the testnet dropped. ## Usage From 98e51b43895f89b5293ca1ddbb29aab85d1091f8 Mon Sep 17 00:00:00 2001 From: James Browning Date: Thu, 13 Feb 2025 17:13:21 +0000 Subject: [PATCH 2/2] fix: dockerfile builds either pubky-homeserver or pubky-testnet --- Dockerfile | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3f930ae..8dbedb0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,25 +44,28 @@ COPY Cargo.toml Cargo.lock ./ # Copy over all the source code COPY . . +# Add build argument for binary selection (homeserver or testnet) +ARG BUILD_TARGET=testnet + # Build the project in release mode for the MUSL target -RUN cargo build --release --bin pubky-homeserver --bin pubky-testnet --target $TARGETARCH-unknown-linux-musl +RUN cargo build --release --bin pubky-$BUILD_TARGET --target $TARGETARCH-unknown-linux-musl # Strip the binary to reduce size -RUN strip target/$TARGETARCH-unknown-linux-musl/release/pubky-homeserver -RUN strip target/$TARGETARCH-unknown-linux-musl/release/pubky-testnet +RUN strip target/$TARGETARCH-unknown-linux-musl/release/pubky-$BUILD_TARGET + # ======================== # Runtime Stage # ======================== FROM alpine:3.20 ARG TARGETARCH=x86_64 +ARG BUILD_TARGET=testnet # Install runtime dependencies (only ca-certificates) RUN apk add --no-cache ca-certificates # Copy the compiled binary from the builder stage -COPY --from=builder /usr/src/app/target/$TARGETARCH-unknown-linux-musl/release/pubky-homeserver /usr/local/bin/homeserver -COPY --from=builder /usr/src/app/target/$TARGETARCH-unknown-linux-musl/release/pubky-testnet /usr/local/bin/testnet +COPY --from=builder /usr/src/app/target/$TARGETARCH-unknown-linux-musl/release/pubky-$BUILD_TARGET /usr/local/bin/homeserver # Set the working directory WORKDIR /usr/local/bin @@ -70,5 +73,5 @@ WORKDIR /usr/local/bin # Expose the port the homeserver listens on (should match that of config.toml) EXPOSE 6287 -# Set the default command to run the homeserver binary +# Set the default command to run the binary CMD ["homeserver"]