From d073a5cb7ace18e966c03c2242de59ce7764ac3a Mon Sep 17 00:00:00 2001 From: James Sansbury Date: Wed, 11 Oct 2023 13:45:00 -0400 Subject: [PATCH] initial working --- .github/workflows/build.yml | 66 ++++++++++++++++++++++++++++ .idea/.gitignore | 5 +++ .idea/docker-zfs-utils.iml | 12 ++++++ .idea/modules.xml | 8 ++++ .idea/vcs.xml | 6 +++ Dockerfile | 8 ++++ README.md | 2 + Taskfile.yml | 85 +++++++++++++++++++++++++++++++++++++ 8 files changed, 192 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .idea/.gitignore create mode 100644 .idea/docker-zfs-utils.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 Taskfile.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..0c3854e --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,66 @@ +name: build + +on: + pull_request: + types: [opened, reopened, synchronize] + push: + branches: + - main + workflow_dispatch: + inputs: + push: + description: Push to Docker hub after build is complete. + default: true + type: boolean + services: + description: Space delimited string of services to build. If empty, all will be built. + type: string + schedule: + - cron: '0 0 * * 6' + +env: + TASK_VERSION: v3.29.1 + TASK_CHECKSUM: e411770abf73d5e094100ab7a1c8278f35b591ecadbfd778200b6b2ad1ee340b + # If this changes, also update the if on the docs job. We unfortunately can't + # use env.PUSH in the if there. + PUSH: ${{ (inputs.push || github.event_name == 'schedule' || github.event_name == 'push') && 'true' || 'false' }} + +jobs: + build: + name: Build + runs-on: ubuntu-latest + strategy: + matrix: ${{ fromJSON(needs.matrix.outputs.matrix) }} + fail-fast: false + steps: + - uses: actions/checkout@v3 + - name: Install dependencies + run: sudo apt-get update + && sudo apt-get install -y eatmydata + && sudo ln -snf /usr/bin/eatmydata /usr/local/bin/apt-get + && sudo apt-get install -y curl + && curl -L -o /tmp/task_linux_amd64.deb https://github.com/go-task/task/releases/download/${{ env.TASK_VERSION }}/task_linux_amd64.deb + && sha256sum /tmp/task_linux_amd64.deb | grep -q ${{ env.TASK_CHECKSUM }} + && sudo dpkg -i /tmp/task_linux_amd64.deb + && sudo apt-get clean + && sudo rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + - + # Add support for more platforms with QEMU (optional) + # https://github.com/docker/setup-qemu-action + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + # Expose the actions cache url and token. + # https://github.com/tonistiigi/go-actions-cache/blob/master/api.md#authentication + name: Expose GitHub Runtime + uses: crazy-max/ghaction-github-runtime@v2 + - run: task + id: task diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..b58b603 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/docker-zfs-utils.iml b/.idea/docker-zfs-utils.iml new file mode 100644 index 0000000..24643cc --- /dev/null +++ b/.idea/docker-zfs-utils.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..0101aa4 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0c2361d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +ARG FROM_TAG + +FROM debian:$FROM_TAG + +RUN \ + sed -e 's/^Components: main$/& contrib/g' -i /etc/apt/sources.list.d/debian.sources && \ + apt-get update && \ + apt-get install --yes --no-install-recommends zfsutils-linux diff --git a/README.md b/README.md new file mode 100644 index 0000000..6a03352 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +This is a very simple docker image starting from Debian slim with just +zfsutils-linux package installed. \ No newline at end of file diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 0000000..dc604f3 --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1,85 @@ +# yaml-language-server: $schema=https://taskfile.dev/schema.json +version: 3 + +dotenv: + - .env.local + - .local.env + - .env + +env: + NAMESPACE: tugboat + IMAGE_NAME: zfs-utils + # Separate each platform with a comma. + PLATFORMS: linux/amd64,linux/arm64 + # Separate each tag with a comma. + TAGS: latest,bookworm-slim + FROM_TAG: bookworm-slim + +vars: + BUILDX_BUILDER: + sh: echo "{{.NAMESPACE}}-{{.IMAGE_NAME}}" + IMAGE_TAGS: + sh: echo "{{.TAGS}}" | sed -E 's@(^|,)([^,]+)@ --tag {{.NAMESPACE}}/{{.IMAGE_NAME}}:\2@g' + +tasks: + default: + desc: 'Builds the image. Set PUSH=1 to push after building.' + cmds: + - task: create-builder + - task: build + + create-builder: + desc: '[subtask] Create the Docker buildx builder.' + status: + # Exits zero (up to date) if there is already a builder. + - docker buildx ls | grep -q '^{{.BUILDX_BUILDER}}\s' + cmds: + - docker buildx create + --name "{{.BUILDX_BUILDER}}" + --platform "{{.PLATFORMS}}" + --bootstrap + --use + + build: + desc: '[subtask] Build any docker image tarballs generated from bake for Tugboat usage.' + vars: + PUSH_OPT: + sh: (test "$PUSH" != "true" && test "$PUSH" != "1") || echo "--push" + cmds: + - docker buildx use "{{.BUILDX_BUILDER}}" + - echo 'PUSH_OPT {{.PUSH_OPT}}' + - docker buildx build + --build-arg FROM_TAG={{.FROM_TAG}} + --platform "{{.PLATFORMS}}" + {{.IMAGE_TAGS}} {{.PUSH_OPT}} . + + clean: + desc: 'Removes all generated files and docker images.' + prompt: This will remove any generated files and delete all docker images in + the {{.NAMESPACE}}/* namespace. Do you want to continue? + deps: + - rm-images + + clean-all: + desc: 'Removes the buildkit builder, all generated files, and all docker images.' + deps: + - rm-builder + - rm-images + prompt: This will remove the buildkit builder, all generated files, and + delete all docker images in the {{.NAMESPACE}}/* namespace. Do you + want to continue? + + rm-builder: + internal: true + status: + - if docker buildx ls | grep -q '^{{.BUILDX_BUILDER}}\s'; then exit 1; fi + cmd: docker buildx rm -f '{{.BUILDX_BUILDER}}' + rm-images: + internal: true + status: + - test -z "{{.IMAGES}}" + vars: + IMAGES: + sh: docker images ls --filter=reference="{{.NAMESPACE}}/{{.IMAGE_NAME}}" -q | sort | uniq + cmd: docker rmi --force $(echo "{{.IMAGES}}") || true +