| 1 | FROM rust:1.83-bookworm AS builder |
| 2 | |
| 3 | RUN apt-get update && apt-get install -y git sqlite3 && rm -rf /var/lib/apt/lists/* |
| 4 | |
| 5 | WORKDIR /build |
| 6 | COPY Cargo.toml ./ |
| 7 | COPY server/ server/ |
| 8 | COPY hook/ hook/ |
| 9 | COPY migrations/ migrations/ |
| 10 | |
| 11 | # Create SQLite DB for sqlx compile-time query checking |
| 12 | RUN sqlite3 /tmp/openhub.db < migrations/0001_init.sql |
| 13 | ENV DATABASE_URL=sqlite:/tmp/openhub.db |
| 14 | |
| 15 | RUN cargo build --release |
| 16 | |
| 17 | # --------------------- |
| 18 | FROM debian:bookworm-slim |
| 19 | |
| 20 | RUN apt-get update && \ |
| 21 | apt-get install -y git sqlite3 && \ |
| 22 | rm -rf /var/lib/apt/lists/* |
| 23 | |
| 24 | # Copy binaries |
| 25 | COPY --from=builder /build/target/release/openhub /usr/local/bin/openhub |
| 26 | COPY --from=builder /build/target/release/git-quota-hook /usr/local/bin/git-quota-hook |
| 27 | |
| 28 | # Copy migration and entrypoint |
| 29 | COPY migrations/ /app/migrations/ |
| 30 | COPY entrypoint.sh /app/entrypoint.sh |
| 31 | RUN chmod +x /app/entrypoint.sh |
| 32 | |
| 33 | # Create data directory |
| 34 | RUN mkdir -p /srv/openhub/repos |
| 35 | |
| 36 | # Environment defaults |
| 37 | ENV OPENHUB_BIND=0.0.0.0:8080 \ |
| 38 | OPENHUB_REPOS_ROOT=/srv/openhub/repos \ |
| 39 | OPENHUB_DB_URL=sqlite:/srv/openhub/openhub.db \ |
| 40 | OPENHUB_HOOK_PATH=/usr/local/bin/git-quota-hook \ |
| 41 | OPENHUB_GIT_HTTP_BACKEND=/usr/lib/git-core/git-http-backend \ |
| 42 | RUST_LOG=info |
| 43 | |
| 44 | EXPOSE 8080 |
| 45 | |
| 46 | ENTRYPOINT ["/app/entrypoint.sh"] |