Skip to content

Add C++ specialized Dockerfile#40

Open
toshi0806 wants to merge 3 commits intomainfrom
issue-18-cpp-pro-dockerfile
Open

Add C++ specialized Dockerfile#40
toshi0806 wants to merge 3 commits intomainfrom
issue-18-cpp-pro-dockerfile

Conversation

@toshi0806
Copy link
Copy Markdown
Member

Summary

C++競技プログラミング専用の Dockerfile.cpp を作成しました。

Changes

  • Dockerfile.cpp を新規作成
    • C++ とそのライブラリのみに特化
    • 他言語サポート(Python, Ruby, Node.js, Java, Erlang, Elixir, Rust)を全て削除
    • マルチステージビルドで最適化

Included C++ Libraries

toml/config.toml の設定に基づき、以下のライブラリを含めています:

  • GCC 15.2.0
  • Boost 1.88.0
  • Abseil 20250512.1
  • LibTorch 2.8.0
  • OR-Tools 9.14
  • Eigen 3.4.0
  • Z3 4.15.2
  • AC Library 1.6
  • range-v3 0.12.0
  • unordered_dense 4.5.0
  • immer 0.8.1
  • LightGBM 4.6.0
  • GMP 6.3.0

Usage

# Build
docker build -t atcoder-container:cpp -f Dockerfile.cpp .

# Compile C++ code
docker run --rm -v $(pwd):/work -w /work atcoder-container:cpp atcoder-compile Main.cpp

# Run
docker run --rm -v $(pwd):/work -w /work atcoder-container:cpp ./a.out

Resolves #18

Copilot AI review requested due to automatic review settings October 24, 2025 11:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a specialized C++-only Dockerfile (Dockerfile.cpp) for competitive programming on AtCoder, removing support for other languages (Python, Ruby, Node.js, Java, Erlang, Elixir, Rust) and optimizing the build using multi-stage compilation.

Key Changes:

  • Multi-stage Docker build separating compilation (builder) from runtime environment
  • Installation of 13 C++ libraries including GCC 15.2.0, Boost 1.88.0, and various competitive programming tools
  • Custom atcoder-compile script with comprehensive compiler flags and library linking

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copilot AI review requested due to automatic review settings October 24, 2025 12:54
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 10 out of 27 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +547 to +548
echo '#include <iostream>
int main() { std::cout << "Hello AtCoder" << std::endl; return 0; }' > /tmp/test.cpp
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The C++ test code embedded in the shell script is missing proper indentation and formatting. Consider using a here-document with proper escaping for better readability and maintainability.

Suggested change
echo '#include <iostream>
int main() { std::cout << "Hello AtCoder" << std::endl; return 0; }' > /tmp/test.cpp
cat << 'EOF' > /tmp/test.cpp
#include <iostream>
int main() {
std::cout << "Hello AtCoder" << std::endl;
return 0;
}
EOF

Copilot uses AI. Check for mistakes.
- Create Dockerfile.cpp with comprehensive C++ libraries
- Include GCC 15.2.0, Boost 1.88.0, LibTorch, OR-Tools, and more
- Add build-cpp job to CI workflow
- Support both amd64 and arm64 architectures
- Trigger build with [build-cpp] tag in commit message

Closes #18
Copilot AI review requested due to automatic review settings October 24, 2025 13:54
@toshi0806 toshi0806 force-pushed the issue-18-cpp-pro-dockerfile branch from 27cdcce to 21e561e Compare October 24, 2025 13:54
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Dockerfile.cpp Outdated
/usr/share/eigen3/cmake/Eigen3Targets.cmake \
/usr/share/eigen3/cmake/Eigen3Config.cmake \
"$AC_INSTALL_DIR/cmake" && \
CMAKE_PATH="${AC_INSTALL_DIR/'/opt/'/}/include" && \
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string replacement pattern '/opt/' uses hardcoded path prefix that may not match AC_INSTALL_DIR. Consider using a more robust path manipulation or verify AC_INSTALL_DIR always starts with /opt/.

Suggested change
CMAKE_PATH="${AC_INSTALL_DIR/'/opt/'/}/include" && \
CMAKE_PATH="${AC_INSTALL_DIR#/opt/}/include" && \

Copilot uses AI. Check for mistakes.
Replace bash string substitution with plain sed command to fix
build error on CI.
@toshi0806 toshi0806 force-pushed the issue-18-cpp-pro-dockerfile branch from 6a3c581 to 280329e Compare October 24, 2025 16:30
Copilot AI review requested due to automatic review settings October 25, 2025 05:14
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# Download and install LibTorch 2.8.0
ARG LIBTORCH_VERSION=2.8.0
WORKDIR $AC_TEMP_DIR
RUN wget "https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-$LIBTORCH_VERSION%2Bcpu.zip" -O libtorch.zip && \
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wget command is missing the -q flag for quiet output, which is inconsistent with other download commands in this Dockerfile (lines 52, 85, 112, 121, 186, 214, 249, 281). Add -q flag for consistency and cleaner build logs.

Suggested change
RUN wget "https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-$LIBTORCH_VERSION%2Bcpu.zip" -O libtorch.zip && \
RUN wget -q "https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-$LIBTORCH_VERSION%2Bcpu.zip" -O libtorch.zip && \

Copilot uses AI. Check for mistakes.
# Build unordered_dense 4.5.0
ARG UNORDERED_DENSE_VERSION=4.5.0
WORKDIR $AC_TEMP_DIR
RUN wget "https://github.com/martinus/unordered_dense/archive/refs/tags/v$UNORDERED_DENSE_VERSION.tar.gz" -O unordered_dense.tar.gz && \
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wget command is missing the -q flag for quiet output, which is inconsistent with other download commands in this Dockerfile. Add -q flag for consistency with lines 52, 85, 112, 121, 186, 214, 249, and 281.

Suggested change
RUN wget "https://github.com/martinus/unordered_dense/archive/refs/tags/v$UNORDERED_DENSE_VERSION.tar.gz" -O unordered_dense.tar.gz && \
RUN wget -q "https://github.com/martinus/unordered_dense/archive/refs/tags/v$UNORDERED_DENSE_VERSION.tar.gz" -O unordered_dense.tar.gz && \

Copilot uses AI. Check for mistakes.
# Stage 4: Summary and notification
build-summary:
needs: [determine-strategy, build-lite, build-full]
needs: [determine-strategy, build-lite, build-full, build-cpp]
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build-summary job unconditionally depends on build-cpp, but build-cpp only runs conditionally (when build_cpp == 'true'). This will cause the summary job to be skipped when C++ builds are not triggered. Use if: always() on individual jobs or make the dependency conditional.

Suggested change
needs: [determine-strategy, build-lite, build-full, build-cpp]
needs: [determine-strategy, build-lite, build-full]

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

C++専用版 Dockerfile.cpp-pro を新規作成

2 participants