-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathDockerfile_front
63 lines (32 loc) · 1.62 KB
/
Dockerfile_front
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
FROM node as asset_builder
WORKDIR /home/usr/front
COPY ./tchatchers_front/src ./src
COPY ./tchatchers_front/Cargo.toml ./Cargo.toml
COPY ./tchatchers_front/tailwind.config.js ./tailwind.config.js
COPY ./tchatchers_front/main.css ./main.css
COPY ./tchatchers_front/index.html ./index.html
RUN mkdir assets
RUN npx tailwindcss@3.3.0 -i main.css -o assets/tailwind.css -c tailwind.config.js --minify
FROM rust:1.84.0 as src_builder
RUN apt-get update; apt-get install clang -y
WORKDIR /usr/tchatchers/front
COPY --from=asset_builder /home/usr/front /usr/tchatchers/front/tchatchers_front
COPY ./tchatchers_core ./tchatchers_core
COPY ./tchatchers_macro ./tchatchers_macro
COPY ./tchatchers_front/services ./tchatchers_front/services
COPY ./tchatchers_front/favicon.ico ./tchatchers_front/favicon.ico
COPY ./tchatchers_front/assets/no_pfp.webp ./tchatchers_front/assets/no_pfp.webp
RUN printf "\n[profile.release]\nlto = true\ncodegen-units = 1\nstrip = true\npanic = \"abort\"\nopt-level = \"z\"\n" >> tchatchers_front/Cargo.toml
RUN rustup target add wasm32-unknown-unknown
RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
RUN cargo binstall trunk -y
WORKDIR /usr/tchatchers/front/tchatchers_front
RUN trunk build --release true --minify true
FROM ubuntu as compressor
WORKDIR /usr/tchatchers/dist
COPY --from=src_builder /usr/tchatchers/front/tchatchers_front/dist /usr/tchatchers/dist
RUN gzip -r ./*
FROM nginx:alpine-slim
WORKDIR /usr/share/nginx/html
COPY --from=compressor /usr/tchatchers/dist /usr/share/nginx/html
EXPOSE 80