1+ # syntax=docker/dockerfile:1.7-labs
2+ FROM gcc:13.2.0-bookworm
3+
4+ ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="vcpkg.json,vcpkg-configuration.json"
5+
6+ RUN apt-get update && \
7+ apt-get install --no-install-recommends -y zip=3.* && \
8+ apt-get install --no-install-recommends -y g++=4:* && \
9+ apt-get install --no-install-recommends -y build-essential=12.* && \
10+ apt-get clean && \
11+ rm -rf /var/lib/apt/lists/*
12+
13+ # cmake 3.29.2 is required by vcpkg
14+ RUN wget --progress=dot:giga https://github.com/Kitware/CMake/releases/download/v3.29.2/cmake-3.29.2-Linux-x86_64.tar.gz && \
15+ tar -xzvf cmake-3.29.2-Linux-x86_64.tar.gz && \
16+ mv cmake-3.29.2-linux-x86_64/ /cmake
17+
18+ ENV CMAKE_BIN="/cmake/bin"
19+ ENV PATH="${CMAKE_BIN}:$PATH"
20+
21+ RUN git clone https://github.com/microsoft/vcpkg.git && \
22+ ./vcpkg/bootstrap-vcpkg.sh -disableMetrics
23+
24+ ENV VCPKG_ROOT="/vcpkg"
25+ ENV PATH="${VCPKG_ROOT}:$PATH"
26+
27+ WORKDIR /app
28+
29+ # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses
30+ COPY --exclude=.git --exclude=README.md . /app
31+
32+ RUN vcpkg install --no-print-usage
33+ RUN sed -i '1s/^/set(VCPKG_INSTALL_OPTIONS --no-print-usage)\n /' ${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
34+
35+ RUN mkdir -p /app-cached/build
36+ RUN if [ -d "/app/build" ]; then mv /app/build /app-cached; fi
37+ RUN if [ -d "/app/vcpkg_installed" ]; then mv /app/vcpkg_installed /app-cached/build; fi
38+
39+ RUN echo "cd \$ {CODECRAFTERS_SUBMISSION_DIR} && cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake && cmake --build ./build && sed -i '/^cmake/ s/^/# /' ./your_sqlite3.sh" > /codecrafters-precompile.sh
40+ RUN chmod +x /codecrafters-precompile.sh
41+
42+ # Once the heavy steps are done, we can copy all files back
43+ COPY . /app
0 commit comments