-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
49 lines (40 loc) · 1.06 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
FROM rust:1.81 AS wasm
WORKDIR /app/wasm
RUN rustup update && \
rustup target add wasm32-unknown-unknown && \
cargo install wasm-pack
COPY wasm/Cargo.* ./
RUN mkdir -p src/ && \
touch src/lib.rs && \
wasm-pack build && \
rm -r src/
COPY wasm/ ./
RUN touch src/lib.rs && wasm-pack build
FROM node:lts AS frontend
WORKDIR /app/frontend
ARG BASE_URL /
COPY frontend/package*.json ./
COPY --from=wasm /app/wasm/pkg /app/wasm/pkg
RUN npm ci
COPY frontend/ ./
RUN npm run build
FROM rust:1.81 AS backend
WORKDIR /app/backend
COPY backend/Cargo.* ./
RUN mkdir -p src/ && \
echo "fn main() {}" > src/main.rs && \
cargo build --release && \
rm -r src/
COPY backend/ ./
RUN touch src/main.rs && cargo build --release
FROM debian
WORKDIR /app
RUN apt-get update && apt-get -y install openssl ca-certificates
COPY --from=backend /app/backend/target/release/backend /app
COPY --from=frontend /app/frontend/dist /app/public
ENV PUBLIC_DIR ./public
ENV PORT 8080
ENV DATABASE_FILE /app/data/database.db
EXPOSE 8080
VOLUME [ "/app/data" ]
CMD ["/app/backend"]