diff --git a/.github/workflows/reusable-integration-tests.yml b/.github/workflows/reusable-integration-tests.yml index 12699f4..acb915f 100644 --- a/.github/workflows/reusable-integration-tests.yml +++ b/.github/workflows/reusable-integration-tests.yml @@ -178,9 +178,18 @@ jobs: uses: actions/download-artifact@v4 with: name: bf_questions + - name: Set up docker-ce + uses: docker/setup-docker-action@v4 - name: Start bf run: | - docker load --input bf.tar + ls -la bf.tar + tar tvf bf.tar + dpkg -l |grep docker + docker --version + docker image load --help + cat /etc/lsb-release + docker image load --input bf.tar --platform linux/amd64 + docker images docker run -d --net=host batfish/batfish:test-${{ inputs.bf_version }} - uses: actions/setup-python@v5 with: @@ -199,51 +208,51 @@ jobs: popd - name: Stop bf run: docker stop $(docker ps -q) - allinone_image_test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Download allinone image - uses: actions/download-artifact@v4 - with: - name: allinone_image - - name: Download pybf whl - uses: actions/download-artifact@v4 - with: - name: pybf_whl - - name: Download pybf notebooks - uses: actions/download-artifact@v4 - with: - name: pybf_notebooks - - name: Download pybf tests - uses: actions/download-artifact@v4 - with: - name: pybf_tests - - name: Download questions - uses: actions/download-artifact@v4 - with: - name: bf_questions - - uses: actions/setup-python@v5 - with: - python-version: 3.9 - - name: Setup pybf - run: pip install "$(ls pybatfish-*.whl)"[dev] - - name: Run tests inside allinone container - run: | - ABS_SOURCE_DIR="$(realpath .)" - TEMP_DIR=$(mktemp -d) - tar xzf pybatfish-tests.tgz -C ${TEMP_DIR} - tar xzf pybatfish-notebooks.tgz -C ${TEMP_DIR} - tar xzf questions.tgz -C ${TEMP_DIR} - PYBF_WHEEL="$(ls pybatfish-*.whl)" - cp ${PYBF_WHEEL} ${TEMP_DIR} - docker load --input allinone.tar - docker run \ - -v ${ABS_SOURCE_DIR}/tests/test.sh:/test.sh:ro \ - -v ${TEMP_DIR}/tests/:/pybatfish/tests/ \ - -v ${TEMP_DIR}/jupyter_notebooks/:/pybatfish/jupyter_notebooks/ \ - -v ${TEMP_DIR}/questions/:/pybatfish/questions/ \ - -v ${TEMP_DIR}/${PYBF_WHEEL}:/pybatfish/dist/${PYBF_WHEEL} \ - --entrypoint /bin/bash \ - batfish/allinone:test-${{ inputs.bf_version }} \ - test.sh +# allinone_image_test: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# - name: Download allinone image +# uses: actions/download-artifact@v4 +# with: +# name: allinone_image +# - name: Download pybf whl +# uses: actions/download-artifact@v4 +# with: +# name: pybf_whl +# - name: Download pybf notebooks +# uses: actions/download-artifact@v4 +# with: +# name: pybf_notebooks +# - name: Download pybf tests +# uses: actions/download-artifact@v4 +# with: +# name: pybf_tests +# - name: Download questions +# uses: actions/download-artifact@v4 +# with: +# name: bf_questions +# - uses: actions/setup-python@v5 +# with: +# python-version: 3.9 +# - name: Setup pybf +# run: pip install "$(ls pybatfish-*.whl)"[dev] +# - name: Run tests inside allinone container +# run: | +# ABS_SOURCE_DIR="$(realpath .)" +# TEMP_DIR=$(mktemp -d) +# tar xzf pybatfish-tests.tgz -C ${TEMP_DIR} +# tar xzf pybatfish-notebooks.tgz -C ${TEMP_DIR} +# tar xzf questions.tgz -C ${TEMP_DIR} +# PYBF_WHEEL="$(ls pybatfish-*.whl)" +# cp ${PYBF_WHEEL} ${TEMP_DIR} +# docker load --input allinone.tar +# docker run \ +# -v ${ABS_SOURCE_DIR}/tests/test.sh:/test.sh:ro \ +# -v ${TEMP_DIR}/tests/:/pybatfish/tests/ \ +# -v ${TEMP_DIR}/jupyter_notebooks/:/pybatfish/jupyter_notebooks/ \ +# -v ${TEMP_DIR}/questions/:/pybatfish/questions/ \ +# -v ${TEMP_DIR}/${PYBF_WHEEL}:/pybatfish/dist/${PYBF_WHEEL} \ +# --entrypoint /bin/bash \ +# batfish/allinone:test-${{ inputs.bf_version }} \ +# test.sh diff --git a/.github/workflows/reusable-precommit.yml b/.github/workflows/reusable-precommit.yml index dba1e1d..c3f8b79 100644 --- a/.github/workflows/reusable-precommit.yml +++ b/.github/workflows/reusable-precommit.yml @@ -203,9 +203,9 @@ jobs: cp allinone-bundle.jar assets cp log4j2.yaml assets - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Build Batfish image - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v6 with: push: false file: batfish.dockerfile @@ -214,45 +214,47 @@ jobs: labels: | org.batfish.batfish-tag=${{ needs.bf_version.outputs.bf_sha }} org.batfish.batfish-version=${{ needs.bf_version.outputs.bf_version }} - outputs: type=docker,dest=/tmp/bf.tar + outputs: type=oci,dest=/tmp/bf.tar context: . + platforms: linux/amd64, linux/arm64 - name: Upload docker image uses: actions/upload-artifact@v4 with: name: bf_image path: /tmp/bf.tar - - name: Download pybf whl - uses: actions/download-artifact@v4 - with: - name: pybf_whl - - name: Download pybf notebooks - uses: actions/download-artifact@v4 - with: - name: pybf_notebooks - - name: Setup Allinone image assets - run: | - cp pybatfish-*.whl assets - TEMP_DIR=$(mktemp -d) - tar xzf pybatfish-notebooks.tgz -C ${TEMP_DIR} - cp -r ${TEMP_DIR}/jupyter_notebooks/ assets/notebooks/ - # Script that starts Batfish + Jupyter server - cp wrapper.sh assets - - name: Build allinone image - uses: docker/build-push-action@v3 - with: - push: false - file: allinone.dockerfile - build-args: ASSETS=./assets - tags: batfish/allinone:test-${{ needs.bf_version.outputs.bf_version }} - labels: | - org.batfish.allinone-tag=${{ needs.bf_version.outputs.bf_sha }}_${{ needs.bf_version.outputs.pybf_sha }} - org.batfish.batfish-tag=${{ needs.bf_version.outputs.bf_sha }} - org.batfish.pybatfish-tag=${{ needs.bf_version.outputs.pybf_sha }} - org.batfish.batfish-version=${{ needs.bf_version.outputs.bf_version }} - outputs: type=docker,dest=/tmp/allinone.tar - context: . - - name: Upload docker image - uses: actions/upload-artifact@v4 - with: - name: allinone_image - path: /tmp/allinone.tar +# - name: Download pybf whl +# uses: actions/download-artifact@v4 +# with: +# name: pybf_whl +# - name: Download pybf notebooks +# uses: actions/download-artifact@v4 +# with: +# name: pybf_notebooks +# - name: Setup Allinone image assets +# run: | +# cp pybatfish-*.whl assets +# TEMP_DIR=$(mktemp -d) +# tar xzf pybatfish-notebooks.tgz -C ${TEMP_DIR} +# cp -r ${TEMP_DIR}/jupyter_notebooks/ assets/notebooks/ +# # Script that starts Batfish + Jupyter server +# cp wrapper.sh assets +# - name: Build allinone image +# uses: docker/build-push-action@v6 +# with: +# push: false +# file: allinone.dockerfile +# build-args: ASSETS=./assets +# tags: batfish/allinone:test-${{ needs.bf_version.outputs.bf_version }} +# labels: | +# org.batfish.allinone-tag=${{ needs.bf_version.outputs.bf_sha }}_${{ needs.bf_version.outputs.pybf_sha }} +# org.batfish.batfish-tag=${{ needs.bf_version.outputs.bf_sha }} +# org.batfish.pybatfish-tag=${{ needs.bf_version.outputs.pybf_sha }} +# org.batfish.batfish-version=${{ needs.bf_version.outputs.bf_version }} +# outputs: type=oci,dest=/tmp/allinone.tar +# context: . +# platforms: linux/amd64, linux/arm64 +# - name: Upload docker image +# uses: actions/upload-artifact@v4 +# with: +# name: allinone_image +# path: /tmp/allinone.tar diff --git a/allinone.dockerfile b/allinone.dockerfile index d8c78d7..097b9ee 100644 --- a/allinone.dockerfile +++ b/allinone.dockerfile @@ -4,11 +4,21 @@ FROM ubuntu:24.04 # and questions/ directory (containing question templates to be loaded by Batfish) ARG ASSETS +# multi-platform pre-defined args +ARG BUILDPLATFORM +ARG BUILDOS +ARG BUILDARCH +ARG BUILDVARIANT +ARG TARGETPLATFORM +ARG TARGETOS +ARG TARGETARCH +ARG TARGETVARIANT + # Make /data dir available to any user, so this container can be run by any user RUN mkdir -p /data RUN chmod a+rw /data COPY ${ASSETS} ./ -ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64/ +ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-$TARGETARCH/ ENV JAVA_LIBRARY_PATH=/usr/lib ENV HOME=/data diff --git a/batfish.dockerfile b/batfish.dockerfile index 5dccbe8..4dc2294 100644 --- a/batfish.dockerfile +++ b/batfish.dockerfile @@ -4,11 +4,21 @@ FROM ubuntu:24.04 # and questions/ directory (containing question templates to be loaded by Batfish) ARG ASSETS +# multi-platform pre-defined args +ARG BUILDPLATFORM +ARG BUILDOS +ARG BUILDARCH +ARG BUILDVARIANT +ARG TARGETPLATFORM +ARG TARGETOS +ARG TARGETARCH +ARG TARGETVARIANT + # Make /data dir available to any user, so this container can be run by any user RUN mkdir -p /data RUN chmod a+rw /data COPY ${ASSETS} ./ -ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64/ +ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-$TARGETARCH/ ENV JAVA_LIBRARY_PATH=/usr/lib ENV HOME=/data