-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathDockerfile
55 lines (37 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
FROM lukemathwalker/cargo-chef:latest-rust-1.83-slim AS chef
# Install additional build dependencies.
#
# NOTE: we should consider building sqlean against
# libsql/libsql-sqlite3/src/sqlite3ext.h rather than upstrean libsqlite3-dev
# for increased consistency.
RUN apt-get update && apt-get install -y --no-install-recommends curl libssl-dev pkg-config libclang-dev protobuf-compiler libprotobuf-dev libsqlite3-dev
ENV PATH=/usr/local/node/bin:$PATH
ARG NODE_VERSION=22.9.0
RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
/tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \
rm -rf /tmp/node-build-master
RUN npm install -g pnpm
RUN pnpm --version
FROM chef AS planner
WORKDIR /app
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
FROM planner AS builder
# Re-build dependencies in case they have changed.
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
COPY . .
RUN RUSTFLAGS="-C target-feature=+crt-static" cargo build --target x86_64-unknown-linux-gnu --release --bin trail
FROM alpine:3.20 AS runtime
RUN apk add --no-cache tini curl
COPY --from=builder /app/target/x86_64-unknown-linux-gnu/release/trail /app/
# When `docker run` is executed, launch the binary as unprivileged user.
RUN adduser -D trailbase
RUN mkdir -p /app/traildepot
RUN chown trailbase /app/traildepot
USER trailbase
WORKDIR /app
EXPOSE 4000
ENTRYPOINT ["tini", "--"]
CMD ["/app/trail", "--data-dir", "/app/traildepot", "run", "--address", "0.0.0.0:4000"]
HEALTHCHECK CMD curl --fail http://localhost:4000/api/healthcheck || exit 1