-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
58 lines (46 loc) · 2.25 KB
/
Copy pathDockerfile
File metadata and controls
58 lines (46 loc) · 2.25 KB
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
# syntax=docker/dockerfile:1
#
# Multi-stage build producing one slim image that ships both Cellora binaries:
# * cellora-api — REST + GraphQL gateway
# * cellora-indexer — CKB block poller
#
# Pick which to run via the container command:
# docker run --rm cellora cellora-api
# docker run --rm cellora cellora-indexer
#
# The build is fully offline: SQLx compile-time query checking reads the
# committed .sqlx/ cache, so no database is needed to build the image.
# ---- Stage 1: build ----------------------------------------------------------
FROM rust:1.82-bookworm AS builder
WORKDIR /build
# Read cached SQLx query metadata instead of connecting to a database.
ENV SQLX_OFFLINE=true
# Copy the whole workspace. .dockerignore keeps the context small (no target/,
# no .git/). migrations/ must be present: the indexer embeds it via
# sqlx::migrate!, and the .sqlx cache is required for offline query checking.
COPY . .
# Build both release binaries. BuildKit cache mounts persist the cargo registry
# and the target directory across builds for fast incremental rebuilds; the
# finished binaries are copied out before the target cache mount is unmounted.
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/build/target \
cargo build --release --locked \
--bin cellora-api --bin cellora-indexer && \
mkdir -p /out && \
cp target/release/cellora-api target/release/cellora-indexer /out/
# ---- Stage 2: runtime --------------------------------------------------------
FROM debian:bookworm-slim AS runtime
# ca-certificates: outbound TLS to the CKB node, GitHub OAuth, and webhook
# endpoints. No OpenSSL runtime is needed — every TLS client is rustls.
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates && \
rm -rf /var/lib/apt/lists/*
# Run as an unprivileged system user.
RUN useradd --system --uid 10001 --user-group --no-create-home cellora
COPY --from=builder /out/cellora-api /out/cellora-indexer /usr/local/bin/
USER cellora
# REST + GraphQL gateway. The indexer exposes its metrics server on a
# separately configured port; publish whatever you map at run time.
EXPOSE 8080
# Default to the API; override the command with `cellora-indexer` to poll.
CMD ["cellora-api"]