-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (50 loc) · 2.43 KB
/
Copy pathDockerfile
File metadata and controls
60 lines (50 loc) · 2.43 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
# SPDX-License-Identifier: Apache-2.0
#
# Multi-stage build for fastcached. The build stage compiles a Release binary
# with TLS enabled (system OpenSSL); the runtime stage is a slim image carrying
# just the binary and the shared libraries it needs.
#
# docker build -t fastcached .
# docker run --rm -p 11211:11211 -p 9259:9259 fastcached \
# --metrics --requirepass=secret
#
# The image binds 0.0.0.0 so it is reachable from outside the container — pair
# that with --requirepass (and --tls for encryption) for any non-trusted network.
#
# Base is ubuntu:26.04: it ships CMake >= 3.28 (the project floor) and a C++23
# g++. yaml-cpp is NOT installed, so CPM fetches and links it statically —
# the runtime image then needs only the OpenSSL runtime (pulled by the `openssl`
# package) on top of the base C/C++ runtime.
# ---- build stage ----------------------------------------------------------
FROM ubuntu:26.04 AS build
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates git cmake ninja-build g++ libssl-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /src
COPY . .
RUN cmake -S . -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_COMPILER=g++ \
-DFASTCACHED_BUILD_TESTS=OFF \
-DFASTCACHED_ENABLE_TLS=ON \
-DUSE_SCCACHE=OFF \
&& cmake --build build --target fastcached
# ---- runtime stage --------------------------------------------------------
FROM ubuntu:26.04 AS runtime
# Installing `openssl` pulls in the matching libssl/libcrypto runtime without
# pinning a version-suffixed package name; libstdc++/libgcc are already present
# in the base image. yaml-cpp is linked statically, so no extra package needed.
RUN apt-get update && apt-get install -y --no-install-recommends \
openssl ca-certificates \
&& rm -rf /var/lib/apt/lists/*
COPY --from=build /src/build/target/fastcached /usr/local/bin/fastcached
# Cache on 11211, admin/metrics on 9259.
EXPOSE 11211 9259
# Self-probe /healthz using the binary itself (no curl in the image). Requires
# the daemon to be started with --metrics (see CMD).
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD ["fastcached", "--healthcheck"]
ENTRYPOINT ["fastcached"]
# Default: listen on all interfaces with the metrics endpoint enabled. Override
# at `docker run` to add --requirepass / --tls etc.
CMD ["--bind=0.0.0.0", "--port=11211", "--metrics", "--metrics-bind=0.0.0.0"]