├── .github └── workflows │ ├── build.yaml │ └── dependabot.yml ├── Dockerfile ├── LICENSE ├── README.md └── install_compilers.sh /.github/workflows/build.yaml: -------------------------------------------------------------------------------- 1 | name: Build and Publish 2 | 3 | on: 4 | # run it on push to the default repository branch 5 | push: 6 | branches: [master] 7 | # run it during pull request 8 | pull_request: 9 | 10 | jobs: 11 | # define job to build and publish docker image 12 | build: 13 | name: Build Docker image and push to repositories 14 | # run only when code is compiling and tests are passing 15 | runs-on: ubuntu-latest 16 | 17 | # steps to perform in job 18 | steps: 19 | - name: Checkout code 20 | uses: actions/checkout@v4 21 | 22 | # setup Docker buld action 23 | - name: Set up Docker Buildx 24 | id: buildx 25 | uses: docker/setup-buildx-action@v3 26 | 27 | - name: Login to DockerHub 28 | uses: docker/login-action@v3 29 | with: 30 | username: ${{ secrets.DOCKERHUB_USERNAME }} 31 | password: ${{ secrets.DOCKERHUB_TOKEN }} 32 | 33 | - name: Build image and push to Docker Hub 34 | uses: docker/build-push-action@v6 35 | with: 36 | # relative path to the place where source code with Dockerfile is located 37 | context: ./ 38 | # Note: tags has to be all lower-case 39 | tags: | 40 | madduci/docker-linux-cpp:latest 41 | madduci/docker-linux-cpp:2.1 42 | # build on feature branches, push only on master branch 43 | push: ${{ github.ref == 'refs/heads/master' }} 44 | 45 | - name: Image digest 46 | run: echo ${{ steps.docker_build.outputs.digest }} 47 | -------------------------------------------------------------------------------- /.github/workflows/dependabot.yml: -------------------------------------------------------------------------------- 1 | # Set update schedule for GitHub Actions 2 | version: 2 3 | updates: 4 | - package-ecosystem: "github-actions" 5 | directory: "/" 6 | schedule: 7 | # Check for updates to GitHub Actions every week 8 | interval: "weekly" 9 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:24.04 2 | 3 | LABEL maintainer="Michele Adduci " \ 4 | license="MIT" 5 | 6 | WORKDIR /project 7 | 8 | ARG DEB_COMPILERS="g++-12 g++-13 g++-14" 9 | ARG EXTRA_CLANG_COMPILERS="18 19 20" 10 | 11 | RUN echo "Installing required packages " \ 12 | && export DEBIAN_FRONTEND=noninteractive \ 13 | && apt-get update \ 14 | && apt-get install -y \ 15 | wget \ 16 | gnupg2 \ 17 | lsb-release \ 18 | apt-utils \ 19 | software-properties-common \ 20 | && apt-get autoremove --purge -y \ 21 | && apt-get autoclean -y \ 22 | && rm -rf /var/cache/apt/* 23 | 24 | ADD install_compilers.sh /install_compilers.sh 25 | 26 | RUN echo "Installing C++ Compilers" \ 27 | && chmod +x /install_compilers.sh \ 28 | && sh /install_compilers.sh "${DEB_COMPILERS}" "${EXTRA_CLANG_COMPILERS}" 29 | 30 | ENTRYPOINT [ "/usr/bin/g++-13" ] 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017-current Michele Adduci 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # docker-linux-cpp 2 | 3 | [![Build and Publish](https://github.com/madduci/docker-linux-cpp/actions/workflows/build.yaml/badge.svg)](https://github.com/madduci/docker-linux-cpp/actions/workflows/build.yaml) 4 | 5 | A basic docker image for C++ developers, featuring g++ (from 8 to 10) and clang (from 9 to 10). The default compiler is g++9, but you're free to modify the Dockerfile and set your own. 6 | 7 | As default working directory, `/project` is being used, but feel free to change it. 8 | 9 | ## Requirements 10 | 11 | * Docker (possibly the latest version) 12 | 13 | ## Note 14 | 15 | Since the Debian repository are changing rapidly, older versions of g++ and newer versions of clang aren't available in repositories anymore. 16 | 17 | ## Build/Run instructions 18 | 19 | You can just type in your terminal: 20 | 21 | `docker pull madduci/docker-linux-cpp` 22 | 23 | to use my docker image or, in case of adjustments to the `Dockerfile`, just type: 24 | 25 | `docker run --rm -it -v /your/folder:/project madduci/docker-linux-cpp my_file.cpp` 26 | -------------------------------------------------------------------------------- /install_compilers.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | readonly DEBIAN_PACKAGES="${1}" 4 | readonly CLANG_PACKAGES="${2}" 5 | 6 | DEBIAN_FRONTEND=noninteractive 7 | add-apt-repository -y ppa:ubuntu-toolchain-r/test \ 8 | apt-get update 9 | 10 | echo "Installing ${DEBIAN_PACKAGES}" 11 | apt-get install -y ${DEBIAN_PACKAGES} libstdc++6 12 | 13 | wget -O /tmp/llvm.sh https://apt.llvm.org/llvm.sh 14 | chmod +x /tmp/llvm.sh 15 | 16 | echo "Installing ${CLANG_PACKAGES}" 17 | for version in ${CLANG_PACKAGES} 18 | do 19 | /tmp/llvm.sh $version 20 | done 21 | 22 | apt-get autoremove --purge -y 23 | apt-get autoclean -y 24 | rm -rf /var/cache/apt/* /tmp/* 25 | --------------------------------------------------------------------------------