Dockerfile: separate backend/frontend build
This commit is contained in:
parent
75a5e3740f
commit
6cd8a2edc1
20
Dockerfile
20
Dockerfile
@ -12,12 +12,20 @@ FROM chef AS planner-peasyweb
|
|||||||
COPY . .
|
COPY . .
|
||||||
RUN cargo chef prepare --recipe-path recipe.json
|
RUN cargo chef prepare --recipe-path recipe.json
|
||||||
|
|
||||||
FROM chef AS builder-peasyweb
|
FROM chef AS builder-peasyweb-backend
|
||||||
COPY --from=planner-peasyweb /app/recipe.json recipe.json
|
COPY --from=planner-peasyweb /app/recipe.json recipe.json
|
||||||
RUN cargo chef cook --release --recipe-path recipe.json
|
RUN cargo chef cook --release -p peazyweb-backend --recipe-path recipe.json
|
||||||
COPY . .
|
COPY Cargo.toml Cargo.lock ./
|
||||||
ENV API_BASE_URL="/api/v1"
|
COPY backend/ ./backend/
|
||||||
RUN cargo build -p peazyweb-backend --release
|
RUN cargo build -p peazyweb-backend --release
|
||||||
|
|
||||||
|
FROM chef AS builder-peasyweb-frontend
|
||||||
|
ENV API_BASE_URL="/api/v1"
|
||||||
|
COPY Cargo.toml Cargo.lock ./
|
||||||
|
COPY frontend/ ./frontend/
|
||||||
|
RUN mkdir ./backend && echo "[package]" > ./backend/Cargo.toml && \
|
||||||
|
echo name = "\"peazyweb-backend\"" >> ./backend/Cargo.toml && \
|
||||||
|
mkdir ./backend/src && echo "pub fn main() {}" > ./backend/src/main.rs
|
||||||
WORKDIR /app/frontend
|
WORKDIR /app/frontend
|
||||||
RUN trunk build --release --public-url "/frontend"
|
RUN trunk build --release --public-url "/frontend"
|
||||||
|
|
||||||
@ -29,8 +37,8 @@ RUN mkdir -p /app/frontend
|
|||||||
RUN mkdir /data
|
RUN mkdir /data
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=builder-peazyrsa /usr/local/cargo/bin/peazyrsa /usr/local/bin/peazyrsa
|
COPY --from=builder-peazyrsa /usr/local/cargo/bin/peazyrsa /usr/local/bin/peazyrsa
|
||||||
COPY --from=builder-peasyweb /app/target/release/peazyweb-backend /usr/local/bin/peazyweb-backend
|
COPY --from=builder-peasyweb-backend /app/target/release/peazyweb-backend /usr/local/bin/peazyweb-backend
|
||||||
COPY --from=builder-peasyweb /app/frontend/dist/ /app/frontend
|
COPY --from=builder-peasyweb-frontend /app/frontend/dist/ /app/frontend
|
||||||
|
|
||||||
VOLUME [ "/data" ]
|
VOLUME [ "/data" ]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user