v1.0.0 — Hexagonal architecture rewrite
All checks were successful
CI / ci (push) Successful in 7m16s
All checks were successful
CI / ci (push) Successful in 7m16s
Restructure the monolithic 252-line main.rs into a 10-crate workspace with clean hexagonal architecture, swappable adapters, and a production- ready deployment pipeline. Backend architecture: - domain: Canvas, Color/Position/PixelUpdate value objects, port traits (CanvasStore, CanvasPersistence, EventBroadcaster), BroadcastEvent - application: use cases (place_pixel, get_state, save/restore snapshot, connect/disconnect), AppState with Arc snapshot cache - config: AppConfig structs + ConfigSource trait - api-types: shared DTOs, event name constants - adapters: config-env, canvas-file, http-axum (rust-embed), socketio, websocket — all behind port traits, swappable via feature flags - server: composition root with graceful shutdown (SIGTERM/SIGINT) Frontend: - Transport abstraction: Socket.IO and native WebSocket via VITE_TRANSPORT - Canvas zoom/pan with mouse wheel, pinch-to-zoom, and +/- buttons - ImageData rendering (~50x faster than fillRect loop) - Touch support, responsive CSS scaling, mobile-friendly layout - OG/Twitter Card meta tags for rich link previews Production: - Docker: musl static build on scratch — 2.73MB image - CI workflows for Gitea and GitHub Actions (fmt, clippy, test, Docker push) - deploy.sh for private registry - 39 unit tests across domain and application - Zero unwraps, zero unsafe, graceful error handling with tracing - Periodic canvas snapshots with rotation, restored on startup - All config via environment variables with typed defaults
This commit is contained in:
29
Dockerfile
29
Dockerfile
@@ -1,19 +1,24 @@
|
||||
FROM rust:1.76 as builder
|
||||
FROM oven/bun:1 AS frontend
|
||||
WORKDIR /app/painter-js
|
||||
COPY painter-js/package.json painter-js/bun.lock ./
|
||||
RUN bun install --frozen-lockfile
|
||||
COPY painter-js/ .
|
||||
RUN bun run build
|
||||
|
||||
FROM rust:1-alpine AS builder
|
||||
WORKDIR /app
|
||||
RUN apk add --no-cache musl-dev
|
||||
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
COPY crates/ ./crates/
|
||||
|
||||
COPY src ./src
|
||||
RUN mkdir -p painter-js/dist && echo '<html></html>' > painter-js/dist/index.html
|
||||
RUN cargo build --release --bin server 2>&1 || true
|
||||
|
||||
RUN cargo build --release
|
||||
|
||||
FROM rust:1.76
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /app/target/release/painter .
|
||||
COPY painter-js/dist ./dist
|
||||
COPY .env .env
|
||||
COPY --from=frontend /app/painter-js/dist ./painter-js/dist
|
||||
RUN touch crates/adapters/http-axum/src/routes.rs && cargo build --release --bin server
|
||||
|
||||
FROM scratch
|
||||
COPY --from=builder /app/target/release/server /painter
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["./painter"]
|
||||
ENTRYPOINT ["/painter"]
|
||||
|
||||
Reference in New Issue
Block a user