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 . .
|
||||
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
|
||||
RUN cargo chef cook --release --recipe-path recipe.json
|
||||
COPY . .
|
||||
ENV API_BASE_URL="/api/v1"
|
||||
RUN cargo chef cook --release -p peazyweb-backend --recipe-path recipe.json
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
COPY backend/ ./backend/
|
||||
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
|
||||
RUN trunk build --release --public-url "/frontend"
|
||||
|
||||
@ -29,8 +37,8 @@ RUN mkdir -p /app/frontend
|
||||
RUN mkdir /data
|
||||
WORKDIR /app
|
||||
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 /app/frontend/dist/ /app/frontend
|
||||
COPY --from=builder-peasyweb-backend /app/target/release/peazyweb-backend /usr/local/bin/peazyweb-backend
|
||||
COPY --from=builder-peasyweb-frontend /app/frontend/dist/ /app/frontend
|
||||
|
||||
VOLUME [ "/data" ]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user