-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
44 lines (29 loc) · 1022 Bytes
/
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
# Step 1: Build backend
FROM rust:1.57-alpine AS builder-backend
RUN rustup target add x86_64-unknown-linux-musl
RUN apk add --no-cache musl-dev openssl-dev
WORKDIR /src
COPY backend/. .
RUN USER=root cargo build -p yab-backend --target x86_64-unknown-linux-musl --release
# Step 2: Build frontend
FROM rust:latest AS builder-frontend
RUN rustup target add wasm32-unknown-unknown
RUN cargo install wasm-pack
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get update && apt-get install nodejs
RUN npm install --global rollup
WORKDIR /src
COPY frontend/. .
RUN wasm-pack build --target web
RUN rollup ./main.js --format iife --file ./pkg/bundle.js
RUN rm -rf static
RUN mkdir static
RUN cp -r ./pkg ./static/pkg
RUN cp ./index.html ./static/index.html
# Step 3: Compose final image
FROM alpine
WORKDIR /src
COPY --from=builder-backend /src/target/x86_64-unknown-linux-musl/release/yab-backend ./
COPY --from=builder-frontend /src/static ./static
ENV RUST_LOG=debug
CMD ["./yab-backend"]