-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
52 lines (42 loc) · 1.6 KB
/
Dockerfile
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
ARG TARGET=gcc
FROM ${TARGET} AS build
ARG COMPILER=gcc
ARG BUILD_TYPE=release
# Install necessary packages for development in a single step to reduce layers and leverage caching
RUN apt-get update && \
apt-get -y install \
cmake \
python3 \
python3-pip \
python3-virtualenv && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*
# Set up working directory
WORKDIR /workspaces
# Create and activate virtual environment in one RUN command for better layer optimization
ENV VIRTUAL_ENV=/opt/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN python3 -m virtualenv "$VIRTUAL_ENV" && \
. "$VIRTUAL_ENV/bin/activate" && \
python3 -m pip install --upgrade pip conan
# Setup Conan profiles and install dependencies
COPY conanfile.txt .
COPY conan conan
RUN test -f "conan/profiles/release-${COMPILER}" || (echo "Error: No Conan profile found for compiler ${COMPILER}" && exit 1)
RUN conan install . --output-folder=build \
--profile:build=conan/profiles/${BUILD_TYPE}-${COMPILER} \
--profile:host=conan/profiles/${BUILD_TYPE}-${COMPILER} \
--build=missing
# Copy project files after dependencies to maximize caching
COPY . .
# Generate and build the project
RUN cp -f ./build/CMakePresets.json . && \
cmake --preset conan-${BUILD_TYPE} && \
cmake --build ./build
# Test stage for running tests
FROM build AS test
WORKDIR /workspaces
# Copy binaries directly from the build stage
COPY --from=build /workspaces/build/DBTest build/DBTest
COPY --from=build /workspaces/build/LSMTreeTest build/LSMTreeTest
COPY --from=build /workspaces/build/MemTableTest build/MemTableTest