This commit is contained in:
@@ -6,10 +6,20 @@ ARG CMAKE_BUILD_TYPE=Debug
|
|||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Create cache directories
|
||||||
|
RUN mkdir -p /ccache /build-cache
|
||||||
|
|
||||||
|
# Set up ccache
|
||||||
|
ENV CCACHE_DIR=/ccache
|
||||||
|
ENV CCACHE_COMPILERCHECK=content
|
||||||
|
ENV CCACHE_MAXSIZE=2G
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Configure and build with ccache
|
# Configure and build with ccache using cache mounts
|
||||||
RUN mkdir -p /build && \
|
RUN --mount=type=cache,target=/ccache \
|
||||||
|
--mount=type=cache,target=/build \
|
||||||
|
mkdir -p /build && \
|
||||||
cmake -G Ninja -S /app -B /build \
|
cmake -G Ninja -S /app -B /build \
|
||||||
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
|
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
|
||||||
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
||||||
@@ -29,14 +39,18 @@ RUN mkdir -p /build && \
|
|||||||
-DOPENSSL_INCLUDE_DIR=/usr/local/include \
|
-DOPENSSL_INCLUDE_DIR=/usr/local/include \
|
||||||
${CMAKE_TOOLCHAIN_FILE:+-DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE}
|
${CMAKE_TOOLCHAIN_FILE:+-DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE}
|
||||||
|
|
||||||
|
# Build with cache mounts
|
||||||
|
RUN --mount=type=cache,target=/ccache \
|
||||||
|
--mount=type=cache,target=/build \
|
||||||
|
cmake --build /build --target run_prebuild_script
|
||||||
|
|
||||||
# Explicitly build dependencies first
|
RUN --mount=type=cache,target=/ccache \
|
||||||
RUN cmake --build /build --target run_prebuild_script
|
--mount=type=cache,target=/build \
|
||||||
|
cmake --build /build
|
||||||
RUN cmake --build /build
|
|
||||||
|
|
||||||
# Copy the built executable to a regular directory for the final stage
|
# Copy the built executable to a regular directory for the final stage
|
||||||
RUN mkdir -p /output && \
|
RUN --mount=type=cache,target=/build \
|
||||||
|
mkdir -p /output && \
|
||||||
find /build -type f -executable -name "*${PROJECT}*" -exec cp {} /output/${PROJECT} \; || \
|
find /build -type f -executable -name "*${PROJECT}*" -exec cp {} /output/${PROJECT} \; || \
|
||||||
find /build -type f -executable -exec cp {} /output/${PROJECT} \;
|
find /build -type f -executable -exec cp {} /output/${PROJECT} \;
|
||||||
|
|
||||||
|
4
build.sh
4
build.sh
@@ -11,6 +11,10 @@ rm -rf "${SCRIPT_DIR}/output"
|
|||||||
mkdir -p "${SCRIPT_DIR}/output"
|
mkdir -p "${SCRIPT_DIR}/output"
|
||||||
|
|
||||||
PROJECT="simple-object-server"
|
PROJECT="simple-object-server"
|
||||||
|
|
||||||
|
# Enable Docker buildkit for cache support
|
||||||
|
export DOCKER_BUILDKIT=1
|
||||||
|
|
||||||
docker build \
|
docker build \
|
||||||
-t "gitea.jde.nz/public/${PROJECT}-build:latest" \
|
-t "gitea.jde.nz/public/${PROJECT}-build:latest" \
|
||||||
-f "${SCRIPT_DIR}/Dockerfile.dropshell-build" \
|
-f "${SCRIPT_DIR}/Dockerfile.dropshell-build" \
|
||||||
|
@@ -78,7 +78,7 @@ bool load_config(const std::string& config_path, ServerConfig& config) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(config.object_store_path.empty(), "object_store_path is not empty");
|
// Test incremental build comment
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
|
Reference in New Issue
Block a user