-
Notifications
You must be signed in to change notification settings - Fork 29
/
Dockerfile
68 lines (59 loc) · 1.79 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
65
66
67
68
# Cache dependencies
FROM node:16 as web-deps
WORKDIR /src/web
COPY web/package.json web/yarn.lock ./
RUN yarn install --frozen-lockfile
# Create base image for building Rust
FROM rust:1.62-alpine AS rust-build-image
RUN apk add --no-cache musl-dev git
# Cache dependencies
FROM rust-build-image AS rust-deps
WORKDIR /src
COPY Cargo.toml Cargo.lock ./
RUN set -ex; \
mkdir src; \
echo 'fn main() {}' > src/main.rs; \
cargo build --locked --release --target x86_64-unknown-linux-musl; \
rm -rf src;
# Generate TypeScript bindings
FROM rust-build-image AS ts-bind
WORKDIR /src
COPY --from=rust-deps /usr/local/cargo /usr/local/cargo
COPY . .
RUN set -ex; \
touch src/main.rs; \
cargo test
# Build the web app
FROM node:16 AS web-builder
WORKDIR /src/web
COPY web .
COPY --from=web-deps /src/web/node_modules /src/web/node_modules
COPY --from=ts-bind /src/web/src/bindings /src/web/src/bindings
RUN yarn build
# Build the Rust app
FROM rust-build-image AS rust-builder
WORKDIR /src
COPY --from=ts-bind /usr/local/cargo /usr/local/cargo
COPY --from=ts-bind /src /src
COPY --from=rust-deps /src/target /src/target
COPY --from=web-builder /src/web/dist /src/web/dist
RUN touch src/main.rs && \
cargo build --locked --release --target x86_64-unknown-linux-musl
# Build ytarchive
FROM golang:1.20-alpine AS ytarchive-builder
WORKDIR /src
RUN set -ex; \
apk add --no-cache git; \
git clone https://github.com/Kethsar/ytarchive.git; \
cd ytarchive; \
git checkout v0.3.2; \
go build .
FROM alpine AS runner
WORKDIR /app
RUN apk add --no-cache ffmpeg
COPY --from=ytarchive-builder /src/ytarchive/ytarchive /usr/local/bin/ytarchive
USER 1000
COPY --from=rust-builder --chown=1000:1000 \
/src/target/x86_64-unknown-linux-musl/release/hoshinova \
/app/hoshinova
CMD ["/app/hoshinova"]