File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Build and Publish Docker Image to GHCR
2+
3+ on :
4+ push :
5+ branches : [ "main" ]
6+ workflow_dispatch :
7+
8+ env :
9+ REGISTRY : ghcr.io
10+ IMAGE_NAME : ${{ github.repository }}
11+
12+ jobs :
13+ build-and-push :
14+ runs-on : ubuntu-latest
15+ permissions :
16+ contents : read
17+ packages : write
18+
19+ steps :
20+ - name : Checkout repository
21+ uses : actions/checkout@v4
22+
23+ - name : Log in to the Container registry
24+ uses : docker/login-action@v3
25+ with :
26+ registry : ${{ env.REGISTRY }}
27+ username : ${{ github.actor }}
28+ password : ${{ secrets.GITHUB_TOKEN }}
29+
30+ - name : Extract metadata (tags, labels) for Docker
31+ id : meta
32+ uses : docker/metadata-action@v5
33+ with :
34+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
35+ tags : |
36+ type=raw,value=latest
37+ type=ref,event=branch
38+
39+ - name : Set up Docker Buildx
40+ uses : docker/setup-buildx-action@v3
41+
42+ - name : Build and push Docker image
43+ uses : docker/build-push-action@v5
44+ with :
45+ context : .
46+ file : ./Dockerfile
47+ push : true
48+ tags : ${{ steps.meta.outputs.tags }}
49+ labels : ${{ steps.meta.outputs.labels }}
50+ cache-from : type=gha
51+ cache-to : type=gha,mode=max
Original file line number Diff line number Diff line change 1+ # Multi-stage production Dockerfile
2+ # Combines WASM client and Axum server on a single port.
3+
4+ # 1. Build the WASM frontend
5+ FROM rust:1.89-bookworm AS wasm-builder
6+ RUN rustup target add wasm32-unknown-unknown
7+ RUN cargo install trunk --locked
8+ WORKDIR /app
9+ COPY Cargo.toml Cargo.lock ./
10+ COPY crates ./crates
11+ COPY apps ./apps
12+ RUN cd crates/client && trunk build --release
13+
14+ # 2. Build the Axum backend server
15+ FROM rust:1.89-bookworm AS server-builder
16+ WORKDIR /app
17+ COPY Cargo.toml Cargo.lock ./
18+ COPY crates ./crates
19+ COPY apps ./apps
20+ COPY --from=wasm-builder /app/dist ./dist
21+ RUN cargo build --release -p excaildraw-server
22+
23+ # 3. Create the final lightweight runtime image
24+ FROM debian:bookworm-slim
25+ RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
26+
27+ COPY --from=server-builder /app/target/release/excaildraw-server /usr/local/bin/
28+ COPY --from=wasm-builder /app/dist /app/dist
29+
30+ # Default to 7860 for compatibility with Hugging Face Spaces.
31+ # This environment variable can be overridden at runtime.
32+ ENV PORT=7860
33+ ENV FRONTEND_DIST=/app/dist
34+ EXPOSE 7860
35+
36+ CMD ["excaildraw-server" ]
Original file line number Diff line number Diff line change @@ -8,6 +8,9 @@ use wasm_bindgen::JsCast;
88use web_sys:: { MessageEvent , WebSocket } ;
99
1010fn api_base ( ) -> String {
11+ if let Some ( url) = option_env ! ( "API_BASE_URL" ) {
12+ return url. to_string ( ) ;
13+ }
1114 web_sys:: window ( )
1215 . and_then ( |w| w. location ( ) . origin ( ) . ok ( ) )
1316 . filter ( |origin| !origin. ends_with ( ":3000" ) )
You can’t perform that action at this time.
0 commit comments