diff --git a/.github/workflows/build-latest-images.yml b/.github/workflows/build-latest-images.yml index 7b5020a..92f544f 100644 --- a/.github/workflows/build-latest-images.yml +++ b/.github/workflows/build-latest-images.yml @@ -1,14 +1,14 @@ -name: Build latest images manually +name: Build latest images automatically on: - workflow_dispatch: {} + push: + branches: + - main jobs: deploy: strategy: - fail-fast: false - matrix: - latest-version: ["0.0.2"] + fail-fast: true runs-on: ubuntu-latest @@ -29,14 +29,13 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push release - id: docker_build_release + name: Build and push + id: docker_build_latest uses: docker/build-push-action@v4 with: context: . build-args: | BCC_VERSION=v0.28.0 - DUETECTOR_VERSION=${{ matrix.latest-version }} platforms: linux/amd64,linux/arm64/v8 file: ./docker/Dockerfile push: true diff --git a/.github/workflows/build-images.yml b/.github/workflows/docker-image.yml similarity index 64% rename from .github/workflows/build-images.yml rename to .github/workflows/docker-image.yml index 3d11cdc..bfba132 100644 --- a/.github/workflows/build-images.yml +++ b/.github/workflows/docker-image.yml @@ -1,14 +1,13 @@ -name: Build images manually +name: Testing docker image build on: - workflow_dispatch: {} + pull_request: + branches: [ "master", "main" ] jobs: deploy: strategy: - fail-fast: false - matrix: - duetector-version: ["0.0.1", "0.0.2"] + fail-fast: true runs-on: ubuntu-latest @@ -29,15 +28,14 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push image - id: docker_build + name: Build image + id: docker_build_test uses: docker/build-push-action@v4 with: context: . build-args: | BCC_VERSION=v0.28.0 - DUETECTOR_VERSION=${{ matrix.duetector-version }} platforms: linux/amd64,linux/arm64/v8 file: ./docker/Dockerfile - push: true - tags: ${{ secrets.DOCKERHUB_USERNAME }}/duetector:${{ matrix.duetector-version }} + push: false + tags: build diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..6d7dff9 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,41 @@ +name: Release docker image + +on: + workflow_dispatch: {} + release: + types: [published] + +permissions: + contents: write + +jobs: + deploy: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - + name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Build and push + id: docker_build_release + uses: docker/build-push-action@v4 + with: + context: . + build-args: | + BCC_VERSION=v0.28.0 + platforms: linux/amd64,linux/arm64/v8 + file: ./docker/Dockerfile + push: true + tags: ${{ secrets.DOCKERHUB_USERNAME }}/duetector:${{ github.ref_name }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 9f593f8..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,81 +0,0 @@ -name: Upload Python Package and Build Image - -on: - release: - types: [published] - -permissions: - contents: write - -jobs: - deploy: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install build twine hatch - - name: Build package - run: python -m build - - name: Publish package - uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} - - name: Upload dists to release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: dist/* - file_glob: true - tag: ${{ github.ref }} - overwrite: true - # Build docker images - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push image - id: docker_build - uses: docker/build-push-action@v4 - with: - context: . - build-args: | - BCC_VERSION=v0.28.0 - DUETECTOR_VERSION=${{ github.ref_name }} - platforms: linux/amd64,linux/arm64/v8 - file: ./docker/Dockerfile - push: true - tags: ${{ secrets.DOCKERHUB_USERNAME }}/duetector:${{ github.ref_name }} - - # Build latest if release - - - name: Build and push release - if: '!github.event.release.prerelease' - id: docker_build_release - uses: docker/build-push-action@v4 - with: - context: . - build-args: | - BCC_VERSION=v0.28.0 - DUETECTOR_VERSION=${{ github.ref_name }} - platforms: linux/amd64,linux/arm64/v8 - file: ./docker/Dockerfile - push: true - tags: ${{ secrets.DOCKERHUB_USERNAME }}/duetector:latest diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index b645c08..b525c1c 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -1,4 +1,4 @@ -name: Python package +name: Testing python package on: push: diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml new file mode 100644 index 0000000..cf218e9 --- /dev/null +++ b/.github/workflows/python-publish.yml @@ -0,0 +1,39 @@ +name: Upload Python Package + +on: + release: + types: [published] + +permissions: + contents: write + +jobs: + deploy: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build twine hatch + - name: Build package + run: python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} + - name: Upload dists to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: dist/* + file_glob: true + tag: ${{ github.ref }} + overwrite: true diff --git a/docker/Dockerfile b/docker/Dockerfile index a5752fd..7f5c40d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,23 +1,28 @@ ARG BCC_VERSION=v0.28.0 -FROM dataucon/ubuntu-bcc:${BCC_VERSION} +FROM python:3.10.12-slim-bookworm as builder + +RUN pip install build twine hatch +COPY . /source +WORKDIR /source +RUN python -m build -ARG DUETECTOR_VERSION +FROM dataucon/ubuntu-bcc:${BCC_VERSION} RUN apt-get update && apt-get install -y tini \ && rm -rf /var/lib/apt/lists/* -RUN pip install jupyterlab - -RUN pip install duetector==${DUETECTOR_VERSION} --no-cache-dir +COPY --from=builder /source/dist/*.whl /tmp/ +RUN pip install /tmp/*.whl --no-cache-dir # Add application user - ARG APPLICATION_UID=9999 ARG APPLICATION_GID=9999 RUN addgroup --system --gid ${APPLICATION_GID} application && \ adduser --system --gid ${APPLICATION_GID} --home /home/application --uid ${APPLICATION_UID} --disabled-password application && \ usermod -s /bin/bash application +# Install Jupyterlab as example application +RUN pip install jupyterlab --no-cache-dir COPY docker/start.sh /start.sh RUN chmod +x /start.sh diff --git a/docker/Dockerfile.dev b/docker/Dockerfile.dev deleted file mode 100644 index 04c2cad..0000000 --- a/docker/Dockerfile.dev +++ /dev/null @@ -1,32 +0,0 @@ -ARG BCC_VERSION=v0.28.0 - -FROM dataucon/ubuntu-bcc:${BCC_VERSION} - -RUN apt-get update && apt-get install -y tini \ - && rm -rf /var/lib/apt/lists/* - -RUN pip install jupyterlab - -COPY . /duetector -RUN pip install -e /duetector --no-cache-dir - - -ARG APPLICATION_UID=9999 -ARG APPLICATION_GID=9999 -RUN addgroup --system --gid ${APPLICATION_GID} application && \ - adduser --system --gid ${APPLICATION_GID} --home /home/application --uid ${APPLICATION_UID} --disabled-password application && \ - usermod -s /bin/bash application - -COPY docker/start.sh /start.sh -RUN chmod +x /start.sh - -CMD [ "/sbin/tini", "--" ] -ENTRYPOINT [ "/start.sh" ] - -# docker build -t duetector:dev -f docker/Dockerfile.dev . - -# Current kernel build with CONFIG_IKHEADERS=m -# docker run -it --rm -p 8888:8888 --cap-add=sys_admin -v /sys/kernel/kheaders.tar.xz:/sys/kernel/kheaders.tar.xz -v /sys/kernel/debug:/sys/kernel/debug duetector:dev - -# Currnet kernel installed with headers -# docker run -it --rm -p 8888:8888 --cap-add=sys_admin -v /usr/lib/modules:/usr/lib/modules -v /sys/kernel/debug:/sys/kernel/debug duetector:dev