-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.client
More file actions
73 lines (47 loc) · 1.97 KB
/
Dockerfile.client
File metadata and controls
73 lines (47 loc) · 1.97 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
FROM rust:1.52.1 AS build-rust
WORKDIR /usr/local/bin
RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
RUN wget https://github.com/TomWright/dasel/releases/download/v1.15.0/dasel_linux_amd64 -O dasel
RUN chmod u+x dasel
RUN wget https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 -O jq
RUN chmod u+x jq
WORKDIR /app
RUN mkdir -p www
RUN mkdir -p www/pkg
WORKDIR /app/rust/client
COPY rust/client/rust-toolchain.toml rust-toolchain.toml
RUN dasel select -f rust-toolchain.toml -s .toolchain.targets -w json | jq -r '.[]' | xargs -n1 rustup target add
WORKDIR /app/rust
COPY rust/client client
COPY rust/server/Cargo.toml server/
RUN mkdir -p server/src && echo "fn main() {}" > server/src/main.rs
COPY rust/server/models/Cargo.toml server/models/
RUN mkdir -p server/models/src && touch server/models/src/lib.rs
RUN dasel put document -f server/Cargo.toml -s ".target.cfg(not(target_arch = \"wasm32\"))" dependencies={}
RUN dasel put document -f server/models/Cargo.toml -s ".target.cfg(not(target_arch = \"wasm32\"))" dependencies={}
COPY rust/Cargo.lock rust/Cargo.toml .
WORKDIR /app/rust/client
RUN cargo fetch --target=wasm32-unknown-unknown
WORKDIR /app
COPY rust rust
WORKDIR /app/rust/client
ARG SERVER_HOST
ENV SERVER_HOST=$SERVER_HOST
RUN wasm-pack build --out-dir ../../www/pkg --release
FROM node:12.20.2 as build-js
RUN apt-get update && apt-get install -y jq
WORKDIR /app/www
RUN mkdir -p pkg
COPY www/package.json www/yarn.lock ./
RUN yarn --ignore-engines
COPY --from=build-rust /app/www/pkg ./pkg
RUN yarn add ./pkg --ignore-engines
RUN yarn --ignore-engines
COPY www ./
RUN yarn build
FROM nginx:1.21.0
COPY nginx /etc/nginx
COPY --from=build-js /app/www/dist /usr/share/nginx/html
RUN ROOT=/usr/share/nginx/html envsubst < /etc/nginx/nginx.conf.template | sed -e 's/§/$/g' > /etc/nginx/nginx.conf
EXPOSE 3000
CMD ["nginx", "-g", "daemon off;"]