-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
189 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
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 | ||
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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This is a very simple docker image starting from Debian slim with just | ||
zfsutils-linux package installed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|