-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
58 lines (44 loc) · 1.63 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
FROM node:alpine as frontend
# install envsubst
RUN apk add -U --upgrade --no-cache gettext
RUN yarn global add elm uglify-js
COPY ./frontend/build.sh ./build.sh
COPY ./frontend/assets ./assets
COPY ./frontend/template.html ./template.html
COPY ./frontend/elm.json ./elm.json
COPY ./frontend/src ./src
# COPY ./frontend/tests ./tests
RUN ./build.sh
# FROM ekidd/rust-musl-builder:stable as backend
FROM clux/muslrust:stable as backend
# create new cargo project
RUN cargo new --bin yagcdn
RUN cargo new --lib time-cache
# copy build config
COPY ./backend/Cargo.lock ./yagcdn/Cargo.lock
COPY ./backend/Cargo.toml ./yagcdn/Cargo.toml
COPY ./time-cache/Cargo.toml ./time-cache/Cargo.toml
WORKDIR /volume/yagcdn
# build to cache dependencies
RUN cargo build --release
# delete build cache to prevent caching issues later on
RUN rm -r ./target/x86_64-unknown-linux-musl/release/.fingerprint/yagcdn*
RUN rm -r ./target/x86_64-unknown-linux-musl/release/.fingerprint/time-cache-*
COPY ./backend/static ./static
COPY ./backend/src ./src
COPY ./time-cache/src ../time-cache/src
# build source code
RUN cargo build --release
# create /etc/password for rootless scratch container
FROM alpine:latest as user_builder
RUN USER=root adduser -D -u 10001 dummy
FROM scratch
# copy certificates
COPY --from=linuxkit/ca-certificates:v0.7 / /
COPY --from=user_builder /etc/passwd /etc/passwd
USER dummy
COPY --from=backend /volume/yagcdn/target/x86_64-unknown-linux-musl/release/yagcdn /
COPY --from=frontend /output/index.html /public/index.html
COPY --from=frontend /output/scripts /public/scripts
COPY --from=frontend /output/assets /public/assets
ENTRYPOINT ["/yagcdn"]