From 0ab073897569ab29022b967063711e2191a207cd Mon Sep 17 00:00:00 2001 From: Conlan Cesar Date: Thu, 3 Oct 2024 22:17:35 -0400 Subject: [PATCH] Split dockerfiles up --- .github/workflows/docker-publish.yaml | 79 ++++++++++++++++++++++----- docker/moos-ivp-gui/Dockerfile | 13 +++++ docker/{ => moos-ivp}/Dockerfile | 0 3 files changed, 77 insertions(+), 15 deletions(-) create mode 100644 docker/moos-ivp-gui/Dockerfile rename docker/{ => moos-ivp}/Dockerfile (100%) diff --git a/.github/workflows/docker-publish.yaml b/.github/workflows/docker-publish.yaml index bb8afd97d..b3b22452d 100644 --- a/.github/workflows/docker-publish.yaml +++ b/.github/workflows/docker-publish.yaml @@ -43,21 +43,15 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max - build: + build-minrobot: runs-on: ubuntu-latest needs: - build-base - strategy: - fail-fast: false - matrix: - flavor: - - minrobot - - gui + env: + FLAVOR: "" steps: - name: Prepare run: | - platform=${{ matrix.arch }} - echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV echo "COMMIT_TIMESTAMP=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV - name: Set up QEMU @@ -75,13 +69,13 @@ jobs: images: ${{ env.REGISTRY_IMAGE }} tags: | # branch event - type=ref,enable=true,prefix=${{ matrix.flavor }}-,event=branch + type=ref,enable=true,prefix=${{ env.flavor }},event=branch # tag event - type=ref,enable=true,prefix=${{ matrix.flavor }}-,event=tag + type=ref,enable=true,prefix=${{ env.flavor }},event=tag # pull request event - type=ref,enable=true,prefix=${{ matrix.flavor }}-pr-,suffix=,event=pr + type=ref,enable=true,prefix=${{ env.flavor }}pr-,suffix=,event=pr # commit sha - type=sha,prefix=${{ matrix.flavor }}-,suffix=,format=short + type=sha,prefix=${{ env.flavor }},suffix=,format=short - name: Login to Docker Hub uses: docker/login-action@v3 @@ -98,7 +92,62 @@ jobs: with: platforms: linux/amd64,linux/arm64 annotations: ${{ steps.meta.outputs.annotations }} - file: docker/Dockerfile - target: ${{ matrix.flavor }} + file: docker/moos-ivp/Dockerfile + cache-from: type=gha + cache-to: type=gha,mode=max + tags: ${{ steps.meta.outputs.tags }} + + build-gui: + runs-on: ubuntu-latest + needs: + - build-minrobot + env: + FLAVOR: "-gui" + steps: + - name: Prepare + run: | + echo "COMMIT_TIMESTAMP=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + env: + SOURCE_DATE_EPOCH: ${{ env.COMMIT_TIMESTAMP }} + with: + images: ${{ env.REGISTRY_IMAGE }} + tags: | + # branch event + type=ref,enable=true,suffix=${{ env.FLAVOR }},event=branch + # tag event + type=ref,enable=true,suffix=${{ env.FLAVOR }},event=tag + # pull request event + type=ref,enable=true,suffix=pr-,suffix=${{ env.FLAVOR }},event=pr + # commit sha + type=sha,prefix=${{ env.FLAVOR }},suffix=,format=short + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push by digest + id: build + uses: docker/build-push-action@v6 + env: + SOURCE_DATE_EPOCH: ${{ env.COMMIT_TIMESTAMP }} + with: + platforms: linux/amd64,linux/arm64 + annotations: ${{ steps.meta.outputs.annotations }} + build-args: | + FROM=${{ needs.build-minrobot.build.outputs.digest }} + file: docker/moos-ivp-gui/Dockerfile cache-from: type=gha tags: ${{ steps.meta.outputs.tags }} \ No newline at end of file diff --git a/docker/moos-ivp-gui/Dockerfile b/docker/moos-ivp-gui/Dockerfile new file mode 100644 index 000000000..cf57e1ab1 --- /dev/null +++ b/docker/moos-ivp-gui/Dockerfile @@ -0,0 +1,13 @@ +ARG FROM=moosivp/moos-ivp:trunk +FROM $FROM + +LABEL maintainer="Conlan Cesar "" + +# Install required MOOS dependencies +USER root +RUN apt-get update -y && apt-get install -y cmake build-essential subversion git libtiff5-dev libfltk1.3-dev freeglut3-dev libpng-dev libjpeg-dev libxinerama-dev libxft-dev && apt-get clean +USER moos + +# Build the MOOS-IvP tools +RUN cd "$HOME/moos-ivp" && ./build-moos.sh --release && ./build-ivp.sh + diff --git a/docker/Dockerfile b/docker/moos-ivp/Dockerfile similarity index 100% rename from docker/Dockerfile rename to docker/moos-ivp/Dockerfile