From a7c957d58ed3812592f9c55a9ad65c7d57d1de76 Mon Sep 17 00:00:00 2001 From: Mike Matera Date: Sat, 25 Nov 2023 16:26:59 -0800 Subject: [PATCH] Test building a custom devcontainer. --- .github/workflows/build-devbox.yaml | 44 +++++++++++++++++++++++++++++ Dockerfile.devcontainer | 16 +++++++++++ setup/roles/ros/tasks/main.yaml | 7 ++++- 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build-devbox.yaml create mode 100644 Dockerfile.devcontainer diff --git a/.github/workflows/build-devbox.yaml b/.github/workflows/build-devbox.yaml new file mode 100644 index 00000000..935097e5 --- /dev/null +++ b/.github/workflows/build-devbox.yaml @@ -0,0 +1,44 @@ +name: build-devbox + +on: + push: + tags: + - "devcontainer-*" + workflow_dispatch: {} + +env: + REGISTRY: ghcr.io + IMAGE_NAME: "${{ github.repository }}-devcontainer" + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Extract version and branch metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=sha + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile.devcontainer + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile.devcontainer b/Dockerfile.devcontainer new file mode 100644 index 00000000..5336d805 --- /dev/null +++ b/Dockerfile.devcontainer @@ -0,0 +1,16 @@ +FROM docker.io/eprosima/vulcanexus:humble-desktop + +# Setup packages needed for `make devbox-install` +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install git ansible python3-pip vim sudo + +# Install the latest devbox playbook from git +COPY . /seahawk +RUN make -C /seahawk devbox-install + +# For vulcanexus container... make a user. +RUN useradd -Um -d /home/student -s /usr/bin/bash --uid 1000 -G adm,sudo student \ + && echo 'student ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/student_nopasswd \ + && echo '. /opt/vulcanexus/humble/setup.bash' >> /home/student/.bashrc + +USER student diff --git a/setup/roles/ros/tasks/main.yaml b/setup/roles/ros/tasks/main.yaml index 106cec86..4e7d94a7 100644 --- a/setup/roles/ros/tasks/main.yaml +++ b/setup/roles/ros/tasks/main.yaml @@ -29,6 +29,12 @@ ## Perform the instructions here: # https://docs.ros.org/en/humble/Installation/Alternatives/Ubuntu-Development-Setup.html +- name: Update all packages to their latest version + ansible.builtin.apt: + name: "*" + state: latest + update_cache: yes + - name: Install helper packages become: true ansible.builtin.apt: @@ -36,7 +42,6 @@ - software-properties-common - curl state: latest - cache_valid_time: 86400 # consider cache up-to-date if its < 1 day old - name: Check for ROS2 repos in apt sources command: /bin/bash -c "grep -q packages.ros.org /etc/apt/sources.list /etc/apt/sources.list.d/*"