diff --git a/.github/workflows/melodic.yml b/.github/workflows/cd.yml similarity index 50% rename from .github/workflows/melodic.yml rename to .github/workflows/cd.yml index 01df235..118242f 100644 --- a/.github/workflows/melodic.yml +++ b/.github/workflows/cd.yml @@ -1,25 +1,12 @@ # This is a basic workflow to help you get started with Actions -name: Melodic +name: Binary Deployment # Controls when the action will run. on: - # Triggers the workflow on push or pull request events but only for the main branch push: - branches: [ main ] - paths-ignore: - - '**/README.md' - - '**/HOWTO.md' - - '**/DEVELOPMENT.md' - - '**/FAQ.md' - pull_request: - branches: [ main ] - - schedule: - - cron: '0 0 * * *' # at the end of every day - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: + tags: + - '[v]?[0-9]+.[0-9]+.[0-9]+' # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: @@ -34,29 +21,44 @@ jobs: access_token: ${{ github.token }} deploy: - # The type of runner that the job will run on - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest needs: cancel if: github.event_name != 'pull_request' + strategy: + matrix: + distro: [bionic, focal] steps: + - name: Setup SSH Keys and known_hosts + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock + run: | + ssh-agent -a $SSH_AUTH_SOCK > /dev/null + ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}" - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - name: Build and push id: docker_build - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v5 + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock with: - file: Dockerfile.bionic - push: true - tags: lmark1/uav_ros_simulation:bionic + file: Dockerfile.binary + push: true + tags: lmark1/uav_ros_simulation:${{ matrix.distro }}-bin-${{ github.ref_name }} + build-args: | + DISTRO=${{ matrix.distro }} + VERSION=${{ github.ref_name }} + --ssh=default + diff --git a/.github/workflows/noetic.yml b/.github/workflows/ci.yml similarity index 55% rename from .github/workflows/noetic.yml rename to .github/workflows/ci.yml index 6abe580..012eec6 100644 --- a/.github/workflows/noetic.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ # This is a basic workflow to help you get started with Actions -name: Noetic +name: CI/CD # Controls when the action will run. on: @@ -9,15 +9,10 @@ on: branches: [ main ] paths-ignore: - '**/README.md' - - '**/HOWTO.md' - '**/DEVELOPMENT.md' - - '**/FAQ.md' pull_request: branches: [ main ] - schedule: - - cron: '0 0 * * *' # at the end of every day - # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -35,20 +30,33 @@ jobs: # This workflow contains a single job called "build" build: - # The type of runner that the job will run on runs-on: ubuntu-20.04 needs: cancel + env: CATKIN_WORKSPACE: uav_ws - + # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # fetch the whole history + + # Use ssh key in private repository + # https://www.webfactory.de/blog/use-ssh-key-for-private-repositories-in-github-actions + - name: Setup SSH Keys and known_hosts + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock + run: | + ssh-agent -a $SSH_AUTH_SOCK > /dev/null + ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}" # Runs a single command using the runners shell - name: Install + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock run: ./.ci/ci_before_install.sh # Runs a set of commands using the runners shell @@ -60,57 +68,44 @@ jobs: run: ./.ci/ci_run_tests.sh deploy: - - # The type of runner that the job will run on - runs-on: ubuntu-20.04 - needs: build - if: github.event_name != 'pull_request' - steps: - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - - name: Build and push - id: docker_build - uses: docker/build-push-action@v2 - with: - file: Dockerfile.focal - push: true - tags: lmark1/uav_ros_simulation:focal - - deploy-nogpu: - # The type of runner that the job will run on - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest needs: build if: github.event_name != 'pull_request' + strategy: + matrix: + distro: [bionic, focal] steps: + # Use ssh key in private repository + # https://www.webfactory.de/blog/use-ssh-key-for-private-repositories-in-github-actions + - name: Setup SSH Keys and known_hosts + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock + run: | + ssh-agent -a $SSH_AUTH_SOCK > /dev/null + ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}" - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} + username: ${{ secrets.DOCKERHUB_USERNAME2 }} + password: ${{ secrets.DOCKERHUB_PASSWORD2 }} - name: Build and push id: docker_build - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v5 + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock with: - file: Dockerfile.focal-nogpu + file: Dockerfile.source push: true - tags: lmark1/uav_ros_simulation:focal-nogpu + tags: lmark2/uav_ros_simulation_source:${{ matrix.distro }} + build-args: | + DISTRO=${{ matrix.distro }} + --ssh=default diff --git a/CHANGELOG.rst b/CHANGELOG.rst new file mode 100644 index 0000000..2d32173 --- /dev/null +++ b/CHANGELOG.rst @@ -0,0 +1,11 @@ +Changelog +========= + +Upcoming +-------------- +- TODO + +v0.0.1 (22-12-2023) +-------------- + +- Initial Release diff --git a/Dockerfile.binary b/Dockerfile.binary index ebcce47..d6c207e 100644 --- a/Dockerfile.binary +++ b/Dockerfile.binary @@ -1,8 +1,11 @@ -FROM lmark1/uav_ros_stack:focal-bin-0.0.1 +ARG VERSION=0.0.1 +ARG DISTRO=focal + +FROM lmark1/uav_ros_stack:$DISTRO-bin-$VERSION # https://blog.alexellis.io/mutli-stage-docker-builds/ - Neat! -FROM nvidia/opengl:1.2-glvnd-runtime-ubuntu20.04 -# FROM ubuntu:focal +# FROM nvidia/opengl:1.2-glvnd-runtime-ubuntu20.04 +FROM ubuntu:$DISTRO # Use ARG - persists only during docker build # https://github.com/moby/moby/issues/4032#issuecomment-192327844 diff --git a/Dockerfile.bionic b/Dockerfile.bionic deleted file mode 100644 index 2a65dd7..0000000 --- a/Dockerfile.bionic +++ /dev/null @@ -1,42 +0,0 @@ -FROM nvidia/opengl:1.2-glvnd-runtime-ubuntu18.04 - -# Use ARG - persists only during docker build -# https://github.com/moby/moby/issues/4032#issuecomment-192327844 -ARG CATKIN_WORKSPACE=uav_ws -ARG DEBIAN_FRONTEND=noninteractive -ARG HOME=/root -ARG USER=root - -# Install all the things to stop docker build from breaking -RUN ln -fs /usr/share/zoneinfo/Europe/Zagreb /etc/localtime && \ - apt-get update && apt-get install -q -y \ - git \ - sudo \ - lsb-release \ - gnupg2 \ - apt-utils \ - dialog \ - tzdata \ - python \ - python-pip \ - curl \ - python3-pip && \ - dpkg-reconfigure --frontend noninteractive tzdata - -# Install uav_ros_simulation and setup catkin workspace -WORKDIR $HOME -RUN git clone https://github.com/larics/uav_ros_simulation.git -RUN ./uav_ros_simulation/installation/install_and_setup_workspace.sh $CATKIN_WORKSPACE - -# Build catkin workspace -WORKDIR $HOME/$CATKIN_WORKSPACE/src -RUN catkin build --limit-status-rate 0.2 - -# Build ardupilot binaries -WORKDIR $HOME/uav_ros_simulation/firmware/ardupilot -RUN modules/waf/waf-light configure --board sitl -RUN modules/waf/waf-light build --target bin/arducopter - -# Prepare for startup -RUN echo "export PATH=\$HOME/.local/bin:\$PATH" >> $HOME/.bashrc -WORKDIR $HOME/uav_ros_simulation/startup/kopterworx_one_flying diff --git a/Dockerfile.focal-nogpu b/Dockerfile.focal-nogpu deleted file mode 100644 index a3bc1f2..0000000 --- a/Dockerfile.focal-nogpu +++ /dev/null @@ -1,41 +0,0 @@ -FROM ubuntu:focal - -# Use ARG - persists only during docker build -# https://github.com/moby/moby/issues/4032#issuecomment-192327844 -ARG CATKIN_WORKSPACE=uav_ws -ARG DEBIAN_FRONTEND=noninteractive -ARG HOME=/root -ARG USER=root - -# Install all the things to stop docker build from breaking -RUN ln -fs /usr/share/zoneinfo/Europe/Zagreb /etc/localtime && \ - apt-get update && apt-get install -q -y \ - git \ - sudo \ - lsb-release \ - gnupg2 \ - apt-utils \ - dialog \ - tzdata \ - curl \ - keyboard-configuration && \ - dpkg-reconfigure --frontend noninteractive tzdata - -# Install uav_ros_simulation and setup catkin workspace -WORKDIR $HOME -RUN git clone https://github.com/larics/uav_ros_simulation.git -RUN ./uav_ros_simulation/installation/install_and_setup_workspace.sh $CATKIN_WORKSPACE - -# Build catkin workspace -WORKDIR $HOME/$CATKIN_WORKSPACE/src -RUN catkin build --limit-status-rate 0.2 - -# Build ardupilot binaries -RUN sudo ln -sf /usr/bin/python3 /usr/bin/python -WORKDIR $HOME/uav_ros_simulation/firmware/ardupilot -RUN modules/waf/waf-light configure --board sitl -RUN modules/waf/waf-light build --target bin/arducopter - -# Prepare for startup -RUN echo "export PATH=\$HOME/.local/bin:\$PATH" >> $HOME/.bashrc -WORKDIR $HOME/uav_ros_simulation/startup/kopterworx_one_flying diff --git a/Dockerfile.focal b/Dockerfile.source similarity index 73% rename from Dockerfile.focal rename to Dockerfile.source index 1772f42..584eb64 100644 --- a/Dockerfile.focal +++ b/Dockerfile.source @@ -3,9 +3,10 @@ FROM nvidia/opengl:1.2-glvnd-runtime-ubuntu20.04 # Use ARG - persists only during docker build # https://github.com/moby/moby/issues/4032#issuecomment-192327844 ARG CATKIN_WORKSPACE=uav_ws -ARG DEBIAN_FRONTEND=noninteractive ARG HOME=/root ARG USER=root +ENV DEBIAN_FRONTEND=noninteractive +RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections # Install all the things to stop docker build from breaking RUN ln -fs /usr/share/zoneinfo/Europe/Zagreb /etc/localtime && \ @@ -21,10 +22,13 @@ RUN ln -fs /usr/share/zoneinfo/Europe/Zagreb /etc/localtime && \ keyboard-configuration && \ dpkg-reconfigure --frontend noninteractive tzdata +# download public key for github.com +RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts + # Install uav_ros_simulation and setup catkin workspace WORKDIR $HOME -RUN git clone https://github.com/larics/uav_ros_simulation.git -RUN ./uav_ros_simulation/installation/install_and_setup_workspace.sh $CATKIN_WORKSPACE +RUN --mount=type=ssh git clone git@github.com:larics/uav_ros_simulation.git +RUN --mount=type=ssh ./uav_ros_simulation/installation/install_and_setup_workspace.sh $CATKIN_WORKSPACE # Build catkin workspace WORKDIR $HOME/$CATKIN_WORKSPACE/src diff --git a/run_docker.sh b/run_docker.sh index 2348ec9..369bdb6 100755 --- a/run_docker.sh +++ b/run_docker.sh @@ -9,7 +9,7 @@ echo "Running Docker Container" CONTAINER_NAME=uav_ros_simulation # Get distro of the built image -distro="focal" +distro="focal-bin-0.0.1" run_args="" for (( i=1; i<=$#; i++)); @@ -64,5 +64,5 @@ docker run \ --env DISPLAY=$DISPLAY \ --env TERM=xterm-256color \ --name $full_container_name \ - lmark1/uav_ros_simulation:$distro \ + uav_ros_simulation:focal-bin-0.0.1 \ /bin/bash