From 8ca9c45435a339a0b5c53ee33113393836051097 Mon Sep 17 00:00:00 2001 From: Fernando Cladera Date: Wed, 24 Jan 2024 23:43:18 -0500 Subject: [PATCH] Github action for Docker build --- .github/workflows/docker-build.yaml | 40 +++++++++++++++++++++++++++++ Dockerfile | 22 ++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 .github/workflows/docker-build.yaml create mode 100644 Dockerfile diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml new file mode 100644 index 0000000..a4beaad --- /dev/null +++ b/.github/workflows/docker-build.yaml @@ -0,0 +1,40 @@ +name: docker-build-base + +# Only build base when any of the files in the base directory are modified +on: + push: + branches: [master, ci] + tags: + - '*' + workflow_dispatch: + schedule: + - cron: '0 0 * * 0' + +jobs: + main: + runs-on: ubuntu-20.04 + + steps: + - + name: Free Disk Space + uses: jlumbroso/free-disk-space@main + with: + tool-cache: true + - + name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - + name: Build and push + id: docker_build + uses: docker/build-push-action@v5 + with: + context: "{{defaultContext}}" + push: false + platforms: linux/amd64 + build-args: git_hash=${{ github.sha }} + - + name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ce2b765 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +# Note: this Dockerfile is only used for the CI. Please refer to the +# instructions in README.md to use this repo + +FROM kumarrobotics/dcist-master:latest + +# Requires a docker build argument `user_id` +ARG user_id=1000 +env USER dcist + +# Create a base docker environment +RUN . /home/$USER/dcist_ws/devel/setup.sh \ + && mkdir -p /home/$USER/user_ws/src && cd /home/$USER/user_ws \ + && catkin config --extend ~/dcist_ws/devel \ + && catkin build --no-status -DCMAKE_BUILD_TYPE=Release + +# Copy the spomp environment into the user workspace +COPY --chown=$USER:$USER . /home/$USER/user_ws/src/spomp-system + +# Build the workspace +RUN cd /home/$USER/user_ws \ + && catkin build --no-status -DCMAKE_BUILD_TYPE=Release \ + && catkin build