Repository navigation
Expand file tree
/
Copy pathDockerfile.mongodb
More file actions
88 lines (82 loc) · 4.27 KB
/
Copy pathDockerfile.mongodb
File metadata and controls
88 lines (82 loc) · 4.27 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# syntax=docker/dockerfile:1.7@sha256:a57df69d0ea827fb7266491f2813635de6f17269be881f696fbfdf2d83dda33e
# Production ExtendDB image with the MongoDB backend. MongoDB itself is an
# external service: use MongoDB Atlas, a managed replica set, or the optional
# docker-compose.mongodb.yml reference stack.
FROM public.ecr.aws/docker/library/rust:1.91.1-bookworm@sha256:c1e5f19e773b7878c3f7a805dd00a495e747acbdc76fb2337a4ebf0418896b33 AS build
ARG VCS_REF
ARG BUILD_DATE
WORKDIR /src
RUN apt-get update \
&& apt-get install -y --no-install-recommends cmake=3.25.1-1 \
&& rm -rf /var/lib/apt/lists/*
# cargo-auditable embeds in the binary the list of crates Cargo resolved for
# the build, so the image SBOM lists the Rust dependencies as well as the OS
# packages. The list can include resolved crates that are not linked. The
# crate is pinned by a recorded checksum and built --locked.
RUN curl -fsSL -o /tmp/cargo-auditable.crate \
https://static.crates.io/crates/cargo-auditable/cargo-auditable-0.7.7.crate \
&& echo "ccdd489bc94d1338cd04389a842e00661300331ec915fb376b4810ef7d480b5d /tmp/cargo-auditable.crate" \
| sha256sum --check --strict - \
&& mkdir /tmp/cargo-auditable \
&& tar -xzf /tmp/cargo-auditable.crate -C /tmp/cargo-auditable --strip-components=1 \
&& cargo install --locked --path /tmp/cargo-auditable \
&& rm -rf /tmp/cargo-auditable /tmp/cargo-auditable.crate
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
RUN test -n "${VCS_REF}" \
&& test "${VCS_REF}" != unknown \
&& test -n "${BUILD_DATE}" \
&& test "${BUILD_DATE}" != unknown \
&& EXTENDDB_GIT_HASH="${VCS_REF}" \
EXTENDDB_BUILD_TIME="${BUILD_DATE}" \
AWS_LC_SYS_USE_SYSTEM=0 \
cargo auditable build --locked --release \
-p extenddb --no-default-features --features mongodb
FROM public.ecr.aws/debian/debian:bookworm-slim@sha256:8eeeb3e089a27d34c398a5580fe479b71a457cba535f59d85e52a303610ec583 AS runtime
ARG VERSION
ARG VCS_REF
ARG BUILD_DATE
ARG DEBIAN_FRONTEND=noninteractive
# The runtime base is explicitly approved for this public OSS distribution.
# Keep both references digest-pinned and update them only through reviewed CRs.
# The base digest is a point-in-time snapshot, and package versions in this
# layer are not pinned: apt-get upgrade installs the bookworm-security updates
# published since the snapshot, so a release build does not ship a package
# Debian has already fixed. --with-new-pkgs installs an update that needs a new
# dependency instead of holding it back.
RUN test -n "${VERSION}" \
&& test -n "${VCS_REF}" \
&& test "${VCS_REF}" != unknown \
&& test -n "${BUILD_DATE}" \
&& test "${BUILD_DATE}" != unknown \
&& apt-get update \
&& apt-get upgrade -y --with-new-pkgs --no-install-recommends \
&& apt-get install -y --no-install-recommends \
ca-certificates \
tini=0.19.0-1+b3 \
&& rm -rf /var/lib/apt/lists/* \
&& groupadd --gid 10001 extenddb \
&& useradd --uid 10001 --gid 10001 --create-home \
--home-dir /var/lib/extenddb --shell /usr/sbin/nologin extenddb \
&& install -d -o 10001 -g 10001 /usr/share/doc/extenddb
# ExtendDB needs no setuid/setgid executable; remove those privilege paths.
RUN find / -xdev -type f -perm /6000 -exec chmod a-s {} +
COPY --from=build --chmod=0555 /src/target/release/extenddb /usr/local/bin/extenddb
COPY --chmod=0444 LICENSE NOTICE SOFTWARE-LICENSE-NOTICES-MONGODB.html /usr/share/doc/extenddb/
LABEL org.opencontainers.image.title="ExtendDB MongoDB backend" \
org.opencontainers.image.description="DynamoDB-compatible API backed by an external MongoDB 7+ replica set" \
org.opencontainers.image.source="https://github.com/ExtendDB/extenddb" \
org.opencontainers.image.url="https://github.com/ExtendDB/extenddb" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.revision="${VCS_REF}" \
org.opencontainers.image.created="${BUILD_DATE}" \
org.opencontainers.image.licenses="Apache-2.0"
ENV HOME=/var/lib/extenddb
WORKDIR /var/lib/extenddb
USER 10001:10001
EXPOSE 18443
STOPSIGNAL SIGTERM
HEALTHCHECK --interval=10s --timeout=5s --start-period=30s --retries=5 \
CMD ["extenddb", "healthcheck", "--config", "/var/lib/extenddb/extenddb.toml"]
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/extenddb"]
CMD ["serve", "--config", "/var/lib/extenddb/extenddb.toml", "--foreground"]