Skip to content

Commit fbe11a9

Browse files
authored
feat: add Dockerfile (#49)
1 parent 28e7428 commit fbe11a9

3 files changed

Lines changed: 60 additions & 0 deletions

File tree

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.git
2+
.target
3+
target
4+
**/.DS_Store
5+
**/*.log

Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# syntax=docker/dockerfile:1
2+
3+
FROM rust:1.82-slim AS builder
4+
WORKDIR /app
5+
6+
# Install build dependencies for OpenSSL / libpq bindings
7+
RUN apt-get update && \
8+
apt-get install -y --no-install-recommends pkg-config libssl-dev libpq-dev && \
9+
rm -rf /var/lib/apt/lists/*
10+
11+
# Cache dependencies
12+
COPY Cargo.toml Cargo.lock ./
13+
COPY src ./src
14+
COPY README.md .
15+
RUN cargo build --release --bin database-replicator
16+
17+
FROM debian:bookworm-slim
18+
LABEL org.opencontainers.image.title="database-replicator" \
19+
org.opencontainers.image.description="Seren database replicator CLI" \
20+
org.opencontainers.image.source="https://github.com/serenorg/database-replicator"
21+
22+
RUN apt-get update && \
23+
apt-get install -y --no-install-recommends ca-certificates libssl3 libpq5 && \
24+
rm -rf /var/lib/apt/lists/* && \
25+
useradd -m replicator
26+
27+
COPY --from=builder /app/target/release/database-replicator /usr/local/bin/database-replicator
28+
USER replicator
29+
ENTRYPOINT ["database-replicator"]
30+
CMD ["--help"]

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,31 @@ cargo build --release
231231

232232
The binary will be available at `target/release/database-replicator`.
233233

234+
### Docker Image
235+
236+
Build a container image with the latest source:
237+
238+
```bash
239+
docker build -t serenorg/database-replicator:latest .
240+
```
241+
242+
Run the CLI inside the container (pass connection strings via arguments or environment variables):
243+
244+
```bash
245+
docker run --rm -it \
246+
serenorg/database-replicator:latest \
247+
validate --source "postgresql://user:pass@source/db" --target "postgresql://user:pass@target/db"
248+
```
249+
250+
Mount local config files if needed:
251+
252+
```bash
253+
docker run --rm -it \
254+
-v "$PWD:/work" \
255+
serenorg/database-replicator:latest \
256+
init --source @/work/source.txt --target @/work/target.txt
257+
```
258+
234259
### Prerequisites
235260

236261
- **PostgreSQL client tools** (pg_dump, pg_dumpall, psql) - Required for all database types

0 commit comments

Comments
 (0)