-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
64 lines (42 loc) · 1.67 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
FROM rust:1.69 as wasm-build
ENV PATH=$PATH:~/.cargo/bin
# This could be more reproducible by pinning the version of wasm-pack
RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh && rustup target add wasm32-unknown-unknown
WORKDIR /app
COPY ./Cargo.toml ./Cargo.toml
COPY ./Cargo.lock ./Cargo.lock
COPY ./src ./src
# Cargo updates the cargo.io index whenever it runs. To avoid this we can cache the index
# Caching for cargo: https://stackoverflow.com/questions/67001033/skip-updating-crates-io-index-when-using-cargo-run
# Caching in gitlab: https://docs.gitlab.com/ee/ci/caching/
RUN wasm-pack build --target bundler --release --out-name index --out-dir ./pkg
RUN cargo doc --no-deps
FROM node:latest as frontend-build
ENV CI=true
ARG API_URL=/api/v1
WORKDIR /app
COPY --from=wasm-build /app/pkg /app/pkg
COPY package.json package.json
COPY package-lock.json package-lock.json
COPY webpack.config.js webpack.config.js
COPY tsconfig.json tsconfig.json
COPY ./ts ./ts
COPY ./static ./static
COPY ./bindings ./bindings
RUN npm install && npm run frontend-build
# FROM nginx:latest
# COPY --from=frontend-build /app/dist /usr/share/nginx/html
# EXPOSE 80
FROM alpine:3.12
# Image Shrinking effect
# - activate to perform all steps ending in one image layer
# - deactivate all RUN commands above
RUN apk update && apk add nginx && rm -rf /var/cache/apk/*
# ADD web /var/www/html
COPY --from=frontend-build /app/dist /var/www/html
COPY --from=wasm-build /app/target/doc /var/www/html/doc
ADD nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
ENTRYPOINT ["nginx", "-g", "daemon off;pid /tmp/nginx.pid;"]
#(100 / 132) * 6.99 = 5.30 %
# 100 - 5.30 = 94.70 % kleiner