-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
50 lines (37 loc) · 1.36 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
FROM node:21-alpine3.18 as frontend-builder
WORKDIR /app
COPY package-lock.json package.json buildscript.js ./
COPY src ./src/
RUN npm ci
RUN npm run build
FROM rust:1.72-alpine3.18 as builder
RUN mkdir -p ~/.cargo && \
echo '[registries.crates-io]' > ~/.cargo/config && \
echo 'protocol = "sparse"' >> ~/.cargo/config
RUN apk add --no-cache libc-dev
RUN USER=root cargo new --bin /app
WORKDIR /app
# Just copy the Cargo.toml files and trigger
# a build so that we compile our dependencies only.
# This way we avoid layer cache invalidation
# if our dependencies haven't changed,
# resulting in faster builds.
COPY Cargo.toml .
COPY Cargo.lock .
RUN cargo build --release && rm -rf src/
RUN strip target/release/mastodon-bookmark-rss
# Copy the source code and run the build again.
# This should only compile the app itself as the
# dependencies were already built above.
COPY . ./
COPY --from=frontend-builder /app/build/ /app/build/
RUN rm ./target/release/deps/mastodon_bookmark_rss* && cargo build --release
# Our production image starts here, which uses
# the files from the builder image above.
FROM alpine:3.18
COPY --from=builder /app/target/release/mastodon-bookmark-rss /usr/local/bin/mastodon-bookmark-rss
RUN apk add --no-cache tini
RUN addgroup -S app && adduser -S app -G app
USER app
ENTRYPOINT ["/sbin/tini", "--", "mastodon-bookmark-rss"]
EXPOSE 3000