Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2 dev containers to chose from #6

Merged
merged 2 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
FROM lcas.lincoln.ac.uk/lcas/ros:humble as base
ARG BASE_IMAGE=ros:humble

FROM ${BASE_IMAGE} as base

USER root

ENV DEBIAN_FRONTEND=noninteractive

Expand All @@ -22,12 +26,15 @@ RUN rosdep update && apt-get update
RUN cd /tmp/src && rosdep install --from-paths . --ignore-src -r -y && cd && rm -rf /tmp/src

FROM depbuilder as final
# add user ros with sudo rights
RUN useradd -ms /bin/bash ros && echo "ros:ros" | chpasswd && adduser ros sudo
# add user ros with sudo rights if it doesn't exist
RUN if ! id ros; then \
useradd -ms /bin/bash ros && echo "ros:ros" | chpasswd && adduser ros sudo; \
echo "ALL ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers; \
echo "source /opt/ros/humble/setup.bash" >> /etc/bash.bashrc; \
else echo "user ros already exists"; \
fi

# add sudo without password
RUN echo "ALL ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

RUN echo "source /opt/ros/humble/setup.bash" >> /etc/bash.bashrc
ENV DEBIAN_FRONTEND=noninteractive

USER ros
46 changes: 46 additions & 0 deletions .devcontainer/cuda-opengl/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
{
"name": "L-CAS Humble CUDA-OpenGL Devcontainer",
"build": {
"dockerfile": "../Dockerfile",
"args": {
"BASE_IMAGE": "lcas.lincoln.ac.uk/lcas/ros:jammy-humble-cuda-opengl"
},
"context": "../.."
},

"forwardPorts": [5801],
"portsAttributes": {
"5801": {
"label": "desktop",
"onAutoForward": "openBrowser"
}
},

// Use 'postCreateCommand' to run commands after the container is created.
// Here we run `colcon build` to build the workspace initially, (to speed up later builds), and we keep going if it fails for some packages to get as much compiled as possible
"postCreateCommand": "/opt/entrypoint.sh /bin/true; .devcontainer/post-create.sh",

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
"remoteUser": "ros",
"updateRemoteUserUID": true, // ensure internal user has the same UID as the host user and update file permissions
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"GitHub.vscode-pull-request-github",
"ms-vscode.cpptools",
"JaehyunShim.vscode-ros2",
"nonanonno.vscode-ros2",
"deitry.colcon-helper",
"github.vscode-github-actions"
]
}
},
"hostRequirements": {
"gpu": "optional",
"cpus": 2,
"memory": "8gb"
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
{
"name": "L-CAS Humble Devcontainer",
"dockerFile": "./Dockerfile",
"context": "..",
"name": "L-CAS Humble Default Devcontainer",
"build": {
"dockerfile": "../Dockerfile",
"args": {
"BASE_IMAGE": "lcas.lincoln.ac.uk/lcas/ros:humble"
},
"context": "../.."
},

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
Expand All @@ -14,9 +19,9 @@
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [6080],
"portsAttributes": {
"6080": {
"6080": {
"label": "desktop"
}
}
},

// Use 'postCreateCommand' to run commands after the container is created.
Expand All @@ -38,5 +43,10 @@
"github.vscode-github-actions"
]
}
},
"hostRequirements": {
"gpu": "optional",
"cpus": 2,
"memory": "8gb"
}
}
8 changes: 7 additions & 1 deletion .github/workflows/dev-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ on:
jobs:
build_devcontainer:
runs-on: ubuntu-latest
strategy:
matrix:
config:
- default
- cuda-opengl
steps:
- name: Checkout from github
uses: actions/checkout@v3
Expand All @@ -23,6 +28,7 @@ jobs:
uses: devcontainers/[email protected]
with:
imageName: lcas.lincoln.ac.uk/devcontainer/${{ steps.docker_image_name.outputs.docker_image }}
configFile: ./.devcontainer/${{ matrix.config }}/devcontainer.json
push: never
imageTag: ${{ env.BRANCH }}
imageTag: ${{ matrix.config }}-${{ env.BRANCH }}
#runCmd: "bash .devcontainer/run-ci.sh"
Loading