-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
100 lines (80 loc) · 2.7 KB
/
Dockerfile
File metadata and controls
100 lines (80 loc) · 2.7 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
89
90
91
92
93
94
95
96
97
98
99
100
# Multi-stage build for MygramDB
# Stage 1: Builder - Build the application
FROM ubuntu:22.04 AS builder
# Build argument for version (pass with --build-arg MYGRAMDB_VERSION=x.y.z)
ARG MYGRAMDB_VERSION
# Set version as environment variable for CMake
# If not provided, CMake will use git tag or default to 0.0.0
ENV MYGRAMDB_VERSION=${MYGRAMDB_VERSION}
# Prevent interactive prompts
ENV DEBIAN_FRONTEND=noninteractive
# Install build dependencies
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
git \
pkg-config \
libmysqlclient-dev \
liblz4-dev \
libicu-dev \
libreadline-dev \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /build
# Copy source code
COPY . .
# Build the project
RUN mkdir -p build && cd build && \
if [ -n "$MYGRAMDB_VERSION" ]; then \
echo "Building with version: $MYGRAMDB_VERSION"; \
else \
echo "MYGRAMDB_VERSION not set, CMake will use git tag or default to 0.0.0"; \
fi && \
cmake -DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTS=OFF \
-DUSE_ICU=ON \
-DUSE_MYSQL=ON \
-DMYGRAMDB_PORTABLE_BUILD=ON \
-DCMAKE_INSTALL_PREFIX=/usr/local \
.. && \
make -j$(nproc) && \
make install DESTDIR=/install
# Stage 2: Runtime - Minimal runtime image
FROM ubuntu:22.04
# Install runtime dependencies only
RUN apt-get update && apt-get install -y \
libstdc++6 \
libmysqlclient21 \
liblz4-1 \
libicu70 \
libreadline8 \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user for running the application
RUN groupadd -g 1000 mygramdb && \
useradd -r -u 1000 -g mygramdb -s /bin/bash mygramdb
# Copy binaries and files from builder
COPY --from=builder /install/usr/local /usr/local
# Create directories for data and configuration
RUN mkdir -p /var/lib/mygramdb /etc/mygramdb && \
chown -R mygramdb:mygramdb /var/lib/mygramdb /etc/mygramdb
# Copy configuration example
COPY --from=builder /build/examples/config-minimal.yaml /etc/mygramdb/config.yaml.example
# Copy entrypoint script
COPY support/docker/entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
# Switch to non-root user
USER mygramdb
# Set working directory
WORKDIR /var/lib/mygramdb
# Expose default ports (TCP API + HTTP API)
EXPOSE 11016 8080
# Health check via HTTP API (health endpoints bypass CIDR restrictions)
HEALTHCHECK --interval=30s --timeout=3s --start-period=30s --retries=3 \
CMD curl -sf http://localhost:8080/health/live || exit 1
# Entrypoint script handles configuration generation from env vars
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
# Default command
CMD ["mygramdb"]