-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDockerfile
More file actions
124 lines (107 loc) · 4.36 KB
/
Dockerfile
File metadata and controls
124 lines (107 loc) · 4.36 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
# Global ARGs (must be before FROM to be available in FROM instructions)
ARG BASE_IMAGE=ubuntu:24.04
# ==================== Stage 1: Builder (init + configure + build) ====================
FROM ubuntu:24.04 AS builder
ARG DEBIAN_FRONTEND=noninteractive
ARG CMAKE_VERSION=3.31.1
ARG GCC_VERSION=14
ARG RUST_VERSION=stable
ENV DEBIAN_FRONTEND=${DEBIAN_FRONTEND}
ENV CMAKE_VERSION=${CMAKE_VERSION}
ENV GCC_VERSION=${GCC_VERSION}
ENV RUST_VERSION=${RUST_VERSION}
ARG GIT_COMMIT=unknown
ARG GIT_BRANCH=unknown
ENV VCPKG_FORCE_SYSTEM_BINARIES=1
ENV PROJECT=/qlean-mini
ENV VENV=${PROJECT}/.venv
ENV BUILD=${PROJECT}/.build
ENV PATH=${VENV}/bin:/root/.cargo/bin:${PATH}
ENV CARGO_HOME=/root/.cargo
ENV RUSTUP_HOME=/root/.rustup
WORKDIR ${PROJECT}
# Copy project files
COPY . ${PROJECT}
# Run all inits and build with vcpkg cache
RUN set -eux; \
chmod +x .ci/scripts/*.sh; \
# System dependencies and Rust via init.sh
./.ci/scripts/init.sh; \
# Clean up any existing venv that might have incompatible Python version
rm -rf ${VENV}; \
# Python venv and cmake via init_py
make init_py
# Configure and build with full vcpkg cache
RUN --mount=type=cache,target=/qlean-mini/.vcpkg,id=vcpkg-full \
set -eux; \
export PATH="${HOME}/.cargo/bin:${PATH}"; \
source ${HOME}/.cargo/env 2>/dev/null || true; \
# Init vcpkg inside cache mount if needed
if [ ! -f "/qlean-mini/.vcpkg/vcpkg" ]; then \
make init_vcpkg; \
fi; \
# Clean build directory to avoid CMake cache path mismatch
rm -rf ${BUILD}; \
make configure; \
make build; \
# Collect artifacts
mkdir -p /opt/artifacts/bin /opt/artifacts/modules /opt/artifacts/lib /opt/artifacts/vcpkg; \
# Copy executable
cp -v ${BUILD}/src/executable/qlean /opt/artifacts/bin/; \
# Copy all module .so files
find ${BUILD}/src/modules -type f -name "*_module.so" -exec cp -v {} /opt/artifacts/modules/ \; || true; \
# Copy all other project .so libraries (app, utils, etc)
find ${BUILD}/src -type f -name "*.so" ! -name "*_module.so" -exec cp -v {} /opt/artifacts/lib/ \; || true; \
# Copy vcpkg installed libraries
if [ -d "${BUILD}/vcpkg_installed" ]; then \
cp -R ${BUILD}/vcpkg_installed /opt/artifacts/vcpkg/installed; \
fi; \
# List collected artifacts
echo "=== Collected artifacts ==="; \
ls -lh /opt/artifacts/bin/; \
ls -lh /opt/artifacts/modules/ || true; \
ls -lh /opt/artifacts/lib/ || true
# ==================== Stage 2: Runtime ====================
FROM ${BASE_IMAGE} AS runtime
ARG BASE_IMAGE
ARG GIT_COMMIT=unknown
ARG GIT_BRANCH=unknown
ARG BUILD_DATE=unknown
ARG VERSION=unknown
# Install minimal runtime dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libstdc++6 \
ca-certificates && \
rm -rf /var/lib/apt/lists/*
# Environment variables for runtime
ENV LD_LIBRARY_PATH=/opt/qlean/lib:/opt/qlean/vcpkg/installed/x64-linux/lib:/opt/qlean/vcpkg/installed/x64-linux-dynamic/lib:/opt/qlean/vcpkg/installed/lib:/usr/local/lib
ENV QLEAN_MODULES_DIR=/opt/qlean/modules
WORKDIR /work
# Copy artifacts from builder
COPY --from=builder /opt/artifacts/bin/qlean /usr/local/bin/qlean
COPY --from=builder /opt/artifacts/lib/ /opt/qlean/lib/
COPY --from=builder /opt/artifacts/modules/ /opt/qlean/modules/
COPY --from=builder /opt/artifacts/vcpkg/installed/ /opt/qlean/vcpkg/installed/
# Verify artifacts
RUN echo "=== Runtime image contents ===" && \
ls -lh /usr/local/bin/qlean && \
echo "=== Project libraries ===" && \
ls -lh /opt/qlean/lib/ || true && \
echo "=== Modules ===" && \
ls -lh /opt/qlean/modules/ || true
# OCI Image Spec annotations
# https://github.com/opencontainers/image-spec/blob/main/annotations.md
LABEL org.opencontainers.image.title="qlean-mini"
LABEL org.opencontainers.image.description="Qlean-mini: lean Ethereum consensus client for devnets — minimal optimized runtime"
LABEL org.opencontainers.image.source="https://github.com/qdrvm/qlean-mini"
LABEL org.opencontainers.image.documentation="https://github.com/qdrvm/qlean-mini#readme"
LABEL org.opencontainers.image.vendor="QDRVM"
LABEL org.opencontainers.image.licenses="Apache-2.0"
LABEL org.opencontainers.image.version=$VERSION
LABEL org.opencontainers.image.created=$BUILD_DATE
LABEL org.opencontainers.image.revision=$GIT_COMMIT
LABEL org.opencontainers.image.ref.name=$GIT_BRANCH
LABEL org.opencontainers.image.base.name=$BASE_IMAGE
ENTRYPOINT ["qlean", "--modules-dir", "/opt/qlean/modules"]
CMD ["--help"]