toka toimiva vedos
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
FROM rust:slim AS builder
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
@@ -8,40 +9,34 @@ RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 1. Kopioi vain Cargo-tiedostot → riippuvuudet cacheen
|
||||
# Kopioi kaikki Cargo-tiedostot
|
||||
COPY Cargo.toml ./
|
||||
COPY Cargo.lock* ./
|
||||
COPY hub/Cargo.toml hub/Cargo.toml
|
||||
COPY node/Cargo.toml node/Cargo.toml
|
||||
COPY native-node/Cargo.toml native-node/Cargo.toml
|
||||
|
||||
# Tyhjät lähteet riippuvuuksien esikääntämistä varten
|
||||
RUN mkdir -p hub/src node/src native-node/src \
|
||||
&& echo "fn main(){}" > hub/src/main.rs \
|
||||
&& echo "" > node/src/lib.rs \
|
||||
&& mkdir -p node/src && touch node/src/storage.rs \
|
||||
&& echo "fn main(){}" > native-node/src/main.rs \
|
||||
&& cargo build --release -p hub 2>/dev/null || true \
|
||||
&& wasm-pack build node --target web --out-dir ../static/pkg 2>/dev/null || true
|
||||
|
||||
# 2. Kopioi oikea lähdekoodi → vain src käännetään uudelleen
|
||||
# Kopioi lähdekoodi
|
||||
COPY hub/src hub/src
|
||||
COPY node/src node/src
|
||||
COPY native-node/src native-node/src
|
||||
COPY static static
|
||||
|
||||
# Pakota uudelleenkäännös
|
||||
RUN touch hub/src/main.rs node/src/lib.rs
|
||||
# Rakenna Wasm — cache mount pitää Cargo-rekisterin ja target-kansion buildien välillä
|
||||
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||
--mount=type=cache,target=/app/target \
|
||||
cd node && wasm-pack build --target web --out-dir ../static/pkg
|
||||
|
||||
# Rakenna Wasm-paketti
|
||||
RUN cd node && wasm-pack build --target web --out-dir ../static/pkg
|
||||
|
||||
# Rakenna Hub release-binääri
|
||||
RUN cargo build --release -p hub
|
||||
# Rakenna Hub
|
||||
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||
--mount=type=cache,target=/app/target \
|
||||
cargo build --release -p hub \
|
||||
&& cp /app/target/release/hub /usr/local/bin/hub
|
||||
|
||||
FROM debian:bookworm-slim
|
||||
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=builder /app/target/release/hub /usr/local/bin/hub
|
||||
COPY --from=builder /usr/local/bin/hub /usr/local/bin/hub
|
||||
COPY --from=builder /app/static /app/static
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
Reference in New Issue
Block a user