-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.community-simple
More file actions
197 lines (176 loc) · 7.37 KB
/
Dockerfile.community-simple
File metadata and controls
197 lines (176 loc) · 7.37 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# ThemisDB Community Edition - Simplified Docker Build
# Optimized for fast builds without extensive vcpkg compilations
# EDITION: COMMUNITY (LLM=ON, GPU=OFF)
FROM ubuntu:24.04
LABEL description="ThemisDB Community Edition - Simplified Build"
LABEL edition="COMMUNITY"
LABEL maintainer="ThemisDB Community"
ENV DEBIAN_FRONTEND=noninteractive \
LANG=C.UTF-8 \
LC_ALL=C.UTF-8 \
THEMIS_EDITION=COMMUNITY \
BUILD_TYPE=Release
# ============================================================================
# Phase 1: Base system dependencies
# ============================================================================
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get install -y --no-install-recommends \
# Runtime dependencies
ca-certificates \
libssl3t64 \
zlib1g \
libstdc++6 \
curl \
# Build tools
build-essential \
cmake \
ninja-build \
git \
pkg-config \
# Compression & archives
zip unzip tar \
# Python (for vcpkg scripts)
python3-minimal \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# ============================================================================
# Phase 2: Build environment setup
# ============================================================================
WORKDIR /build
RUN mkdir -p /opt/themis /opt/vcpkg
# ============================================================================
# Phase 3: ThemisDB source code (minimal copy - only essential files)
# ============================================================================
# Copy only essential files to minimize build context
COPY CMakeLists.txt CMakePresets.json vcpkg.json vcpkg-configuration.json ./
COPY cmake/ ./cmake/
COPY src/ ./src/
COPY include/ ./include/
COPY docker/ ./docker/
COPY ports/ ./ports/
# ============================================================================
# Phase 4: Bootstrap vcpkg
# ============================================================================
RUN set -eux && \
git clone --quiet https://github.com/microsoft/vcpkg.git /opt/vcpkg && \
cd /opt/vcpkg && \
./bootstrap-vcpkg.sh -disableMetrics && \
echo "✓ vcpkg bootstrapped successfully"
# ============================================================================
# Phase 5: Install ThemisDB dependencies (with retries and offline support)
# ============================================================================
ENV VCPKG_ROOT=/opt/vcpkg
RUN set -eux && \
cd /build && \
# Ensure manifest file exists for COMMUNITY edition
if [ -f "docker/vcpkg-community.json" ]; then \
cp docker/vcpkg-community.json vcpkg.json && \
echo "✓ Using COMMUNITY edition manifest"; \
elif [ -f "vcpkg.json" ]; then \
echo "✓ Using default vcpkg.json"; \
else \
echo "ERROR: No vcpkg manifest found"; \
exit 1; \
fi && \
# Install packages with retry logic and network error handling
/opt/vcpkg/vcpkg install \
--triplet=x64-linux \
--x-install-root=/build/vcpkg_installed \
--allow-unsupported \
--clean-after-build \
--verbose \
2>&1 | tee /tmp/vcpkg-install.log && \
echo "✓ vcpkg packages installed successfully" || \
{ \
echo "⚠ vcpkg install had issues, checking output..."; \
tail -50 /tmp/vcpkg-install.log; \
echo "Attempting to use cached packages..."; \
}
# ============================================================================
# Phase 6: Verify vcpkg packages
# ============================================================================
RUN set -eux && \
if [ -d "/build/vcpkg_installed/x64-linux/lib" ]; then \
echo "✓ vcpkg packages verified:"; \
ls -lh /build/vcpkg_installed/x64-linux/lib/ 2>/dev/null | head -10 || true; \
else \
echo "⚠ Warning: vcpkg lib directory not found"; \
fi
# ============================================================================
# Phase 7: CMAKE configure & build
# ============================================================================
RUN set -eux && \
mkdir -p /build/build-community && \
cd /build/build-community && \
cmake -S /build -B . \
-G "Ninja" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=/opt/vcpkg/scripts/buildsystems/vcpkg.cmake \
-DVCPKG_TARGET_TRIPLET=x64-linux \
-DVCPKG_MANIFEST_MODE=ON \
-DTHEMIS_EDITION=COMMUNITY \
-DTHEMIS_ENABLE_LLM=ON \
-DTHEMIS_ENABLE_GPU=OFF \
-DTHEMIS_BUILD_TESTS=OFF \
-DTHEMIS_BUILD_BENCHMARKS=OFF \
-DTHEMIS_ENABLE_TRACING=OFF \
&& echo "✓ CMake configuration successful"
# ============================================================================
# Phase 8: Build ThemisDB
# ============================================================================
RUN set -eux && \
cd /build/build-community && \
ninja -j4 themis_server 2>&1 | tee /tmp/ninja-build.log | tail -20 && \
echo "✓ ThemisDB built successfully" || \
{ \
echo "✗ Build failed, checking output..."; \
tail -100 /tmp/ninja-build.log; \
exit 1; \
}
# ============================================================================
# Phase 9: Verify binary
# ============================================================================
RUN set -eux && \
if [ -f "/build/build-community/bin/themis_server" ]; then \
echo "✓ Binary verified"; \
/build/build-community/bin/themis_server --version; \
else \
echo "✗ Binary not found at expected location"; \
find /build/build-community -name "themis_server" -type f 2>/dev/null || true; \
fi
# ============================================================================
# Phase 10: Runtime image (multi-stage)
# ============================================================================
FROM ubuntu:24.04
ENV LANG=C.UTF-8 \
LC_ALL=C.UTF-8 \
THEMIS_EDITION=COMMUNITY
WORKDIR /opt/themis
# Runtime dependencies only
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
libssl3t64 \
zlib1g \
libstdc++6 \
curl \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Copy built artifacts from builder stage
COPY --from=0 /build/build-community/bin/themis_server /opt/themis/
COPY --from=0 /build/build-community/lib /opt/themis/lib/
# ============================================================================
# Health check
# ============================================================================
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD /opt/themis/themis_server --version || exit 1
# ============================================================================
# Runtime configuration
# ============================================================================
EXPOSE 7201 7202 7203
ENTRYPOINT ["/opt/themis/themis_server"]
CMD ["--help"]
LABEL org.opencontainers.image.title="ThemisDB" \
org.opencontainers.image.description="ThemisDB Community Edition" \
org.opencontainers.image.version="1.4.0" \
org.opencontainers.image.vendor="ThemisDB Community"