From 4891f3375575d00b6001fbabdda46771514594cb Mon Sep 17 00:00:00 2001 From: Taariq Lewis <701864+taariq@users.noreply.github.com> Date: Fri, 5 Dec 2025 12:41:25 -0800 Subject: [PATCH 1/3] feat: add Dockerfile --- .dockerignore | 5 +++++ Dockerfile | 30 ++++++++++++++++++++++++++++++ README.md | 25 +++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6c5973e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +.git +.target +target +**/.DS_Store +**/*.log diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..aeadc75 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +# syntax=docker/dockerfile:1 + +FROM rust:1.82-slim AS builder +WORKDIR /app + +# Install build dependencies for OpenSSL / libpq bindings +RUN apt-get update && \ + apt-get install -y --no-install-recommends pkg-config libssl-dev libpq-dev && \ + rm -rf /var/lib/apt/lists/* + +# Cache dependencies +COPY Cargo.toml Cargo.lock ./ +COPY src ./src +COPY README.md . +RUN cargo build --release --bin database-replicator + +FROM debian:bookworm-slim +LABEL org.opencontainers.image.title="database-replicator" \ + org.opencontainers.image.description="Seren database replicator CLI" \ + org.opencontainers.image.source="https://github.com/serenorg/database-replicator" + +RUN apt-get update && \ + apt-get install -y --no-install-recommends ca-certificates libssl3 libpq5 && \ + rm -rf /var/lib/apt/lists/* && \ + useradd -m replicator + +COPY --from=builder /app/target/release/database-replicator /usr/local/bin/database-replicator +USER replicator +ENTRYPOINT ["database-replicator"] +CMD ["--help"] diff --git a/README.md b/README.md index f791441..e45a753 100644 --- a/README.md +++ b/README.md @@ -231,6 +231,31 @@ cargo build --release The binary will be available at `target/release/database-replicator`. +### Docker Image + +Build a container image with the latest source: + +```bash +docker build -t serenorg/database-replicator:latest . +``` + +Run the CLI inside the container (pass connection strings via arguments or environment variables): + +```bash +docker run --rm -it \ + serenorg/database-replicator:latest \ + validate --source "postgresql://user:pass@source/db" --target "postgresql://user:pass@target/db" +``` + +Mount local config files if needed: + +```bash +docker run --rm -it \ + -v "$PWD:/work" \ + serenorg/database-replicator:latest \ + init --source @/work/source.txt --target @/work/target.txt +``` + ### Prerequisites - **PostgreSQL client tools** (pg_dump, pg_dumpall, psql) - Required for all database types From 7bcbf2de452af7335d3fb96da7231f529e4b6e71 Mon Sep 17 00:00:00 2001 From: Taariq Lewis <701864+taariq@users.noreply.github.com> Date: Fri, 5 Dec 2025 12:46:03 -0800 Subject: [PATCH 2/3] feat: add Docker release workflow docs --- Dockerfile | 26 ++++++++++++++------------ README.md | 14 +++++++++----- docs/publishing.md | 28 ++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 17 deletions(-) create mode 100644 docs/publishing.md diff --git a/Dockerfile b/Dockerfile index aeadc75..42242de 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,20 @@ # syntax=docker/dockerfile:1 -FROM rust:1.82-slim AS builder -WORKDIR /app +FROM debian:bookworm-slim AS downloader +ARG VERSION=latest +ENV BINARY_NAME=database-replicator-linux-x64-binary +ENV RELEASE_ROOT=https://github.com/serenorg/database-replicator/releases -# Install build dependencies for OpenSSL / libpq bindings -RUN apt-get update && \ - apt-get install -y --no-install-recommends pkg-config libssl-dev libpq-dev && \ - rm -rf /var/lib/apt/lists/* +RUN apt-get update && apt-get install -y --no-install-recommends curl ca-certificates && rm -rf /var/lib/apt/lists/* -# Cache dependencies -COPY Cargo.toml Cargo.lock ./ -COPY src ./src -COPY README.md . -RUN cargo build --release --bin database-replicator +RUN set -eux; \ + if [ "$VERSION" = "latest" ]; then \ + URL="$RELEASE_ROOT/latest/download/$BINARY_NAME"; \ + else \ + URL="$RELEASE_ROOT/download/$VERSION/$BINARY_NAME"; \ + fi; \ + curl -fL "$URL" -o /tmp/database-replicator && \ + chmod +x /tmp/database-replicator FROM debian:bookworm-slim LABEL org.opencontainers.image.title="database-replicator" \ @@ -24,7 +26,7 @@ RUN apt-get update && \ rm -rf /var/lib/apt/lists/* && \ useradd -m replicator -COPY --from=builder /app/target/release/database-replicator /usr/local/bin/database-replicator +COPY --from=downloader /tmp/database-replicator /usr/local/bin/database-replicator USER replicator ENTRYPOINT ["database-replicator"] CMD ["--help"] diff --git a/README.md b/README.md index e45a753..4412de4 100644 --- a/README.md +++ b/README.md @@ -233,18 +233,22 @@ The binary will be available at `target/release/database-replicator`. ### Docker Image -Build a container image with the latest source: +Build an image from the latest GitHub release (default) or a specific tag: ```bash +# latest release asset docker build -t serenorg/database-replicator:latest . + +# specific version +docker build --build-arg VERSION=v5.3.20 -t serenorg/database-replicator:v5.3.20 . ``` Run the CLI inside the container (pass connection strings via arguments or environment variables): ```bash -docker run --rm -it \ - serenorg/database-replicator:latest \ - validate --source "postgresql://user:pass@source/db" --target "postgresql://user:pass@target/db" +docker run --rm -it serenorg/database-replicator:latest \ + validate --source "postgresql://user:pass@source/db" \ + --target "postgresql://user:pass@target/db" ``` Mount local config files if needed: @@ -253,7 +257,7 @@ Mount local config files if needed: docker run --rm -it \ -v "$PWD:/work" \ serenorg/database-replicator:latest \ - init --source @/work/source.txt --target @/work/target.txt + init --source "$(cat /work/source.txt)" --target "$(cat /work/target.txt)" ``` ### Prerequisites diff --git a/docs/publishing.md b/docs/publishing.md new file mode 100644 index 0000000..bae2d51 --- /dev/null +++ b/docs/publishing.md @@ -0,0 +1,28 @@ +# Publishing to crates.io + +1. **Prepare a clean release checkout** + ```bash + git fetch origin --tags + git checkout vX.Y.Z # replace with the release tag + cargo clean + ``` + +2. **Verify metadata and package contents** + ```bash + cargo package + ``` + Inspect the generated tarball under `target/package/` to confirm the right files are included. + +3. **Authenticate with crates.io** + ```bash + cargo login $CARGO_REGISTRY_TOKEN + ``` + +4. **Publish** + ```bash + cargo publish + ``` + Publishing may take a few minutes before the crate appears in search results. + +5. **Tag/Release** + Ensure the git tag matches the published version and update release notes. From 9e2d054658e27475a2262d67c866bb807ab9589f Mon Sep 17 00:00:00 2001 From: Taariq Lewis <701864+taariq@users.noreply.github.com> Date: Fri, 5 Dec 2025 14:56:35 -0800 Subject: [PATCH 3/3] fix: pin home crate to <0.5.12 to avoid edition2024 requirement The home v0.5.12 crate was published requiring Rust edition 2024, which is not stabilized in stable Rust. Pin to v0.5.11 to maintain compatibility with stable Rust toolchains. --- Cargo.lock | 7 ++++--- Cargo.toml | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bee0918..7338303 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -687,6 +687,7 @@ dependencies = [ "dialoguer", "dirs", "futures", + "home", "indicatif", "inquire", "mongodb", @@ -1294,11 +1295,11 @@ dependencies = [ [[package]] name = "home" -version = "0.5.12" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc627f471c528ff0c4a49e1d5e60450c8f6461dd6d10ba9dcd3a61d3dff7728d" +checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index d0047f2..8f1e8e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,6 +26,7 @@ inquire = "0.7" futures = "0.3" indicatif = "0.18" which = "6.0" +home = ">=0.5.4, <0.5.12" # Pin to avoid v0.5.12 which requires unstable edition2024 rand = "0.8" reqwest = { version = "0.11", features = ["json"] } serde = { version = "1.0", features = ["derive"] }