Skip to content

Commit

Permalink
added docker support
Browse files Browse the repository at this point in the history
  • Loading branch information
rabdomant committed Jul 11, 2024
1 parent 8adb063 commit 57bac42
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-24.04

ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="3.22.2"

# Optionally install the cmake for vcpkg
COPY ./reinstall-cmake.sh /tmp/

RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \
chmod +x /tmp/reinstall-cmake.sh && /tmp/reinstall-cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE}; \
fi \
&& rm -f /tmp/reinstall-cmake.sh

# [Optional] Uncomment this section to install additional vcpkg ports.
# RUN su vscode -c "${VCPKG_ROOT}/vcpkg install <your-port-name-here>"

# [Optional] Uncomment this section to install additional packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends openmpi-common openmpi-bin libopenmpi-dev clang-format

37 changes: 37 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/cpp
{
"name": "HiRep",
"build": {
"dockerfile": "Dockerfile"
},
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"containerEnv": { "TZ": "Europe/Rome" },
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": {
"git-hooks": "ln -sf /workspaces/${localWorkspaceFolderBasename}/Make/git-hooks-pre-commit /workspaces/${localWorkspaceFolderBasename}/.git/hooks/pre-commit",
"python3": "sudo ln -s /usr/bin/python3 /usr/bin/python"
},
"postStartCommand": {
"setupenv": "printenv > .devcontainer/container.env"
},
// Configure tool-specific properties.
// "customizations": {},
"customizations": {
"vscode": {
"extensions": [
"eamodio.gitlens",
"ms-vscode-remote.remote-containers",
"ms-vscode.cpptools-extension-pack",
"ms-azuretools.vscode-dockert",
"ms-vscode.cpptools-themes"
]
}
}
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
1 change: 1 addition & 0 deletions .devcontainer/start-shell
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker exec -it -w /workspaces/$(basename `pwd`) -u vscode --env-file="$(pwd)/.devcontainer/container.env" $(awk -F'=' '$1=="HOSTNAME" { print $2 }' "$(pwd)/.devcontainer/container.env") zsh

0 comments on commit 57bac42

Please sign in to comment.