Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Distribute as docker image #1875

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .devcontainer/devcontainer.json
mircea-pavel-anton marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/go
{
"name": "Go",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/go:1-1.23-bookworm",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/marcozac/devcontainer-features/goreleaser:1": {},
"ghcr.io/guiyomh/features/golangci-lint:0": {}
}

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "go version",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
48 changes: 48 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,51 @@ winget:
owner: go-task
name: winget-pkgs
branch: "bump-task-to-{{.Tag}}"

dockers:
- image_templates:
- "ghcr.io/go-task/task:v{{.Version}}-amd64"
use: buildx
dockerfile: Dockerfile
extra_files:
- completion/bash/task.bash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct usage of these files is deprecated.

Copy link
Author

@mircea-pavel-anton mircea-pavel-anton Dec 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh damn, I completely missed that. Will fix!

FWIW, they still seem to be referenced throughout the goreleaser config. If I understand correctly, the brew installer also uses them as well as the nfpms?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah unfortunately, they are still used in a few places. This is why we deprecated them instead of removing them. We need to slowly remove the references to them. We could probably still add completions to the image by writing a .bashrc during the build and using the new method

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about generating the completions in the container, but then I decided against it.

It doesn't make much sense to generate the bash completions given the image is based on scratch IMHO, and even then, if we generate and include one set of completions we might as well generate all.

I think that, given the completions can be generated from the binary, it is just as simple to add a RUN command in your dockerfile to set up your required completions.

There are already instructions for generating the completions so that should have it covered. At the end of the day, the container image is a means to distribute the binary, right?

Let me know what you think!

build_flag_templates:
- "--platform=linux/amd64"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.url=https://github.com/go-task/task"
mircea-pavel-anton marked this conversation as resolved.
Show resolved Hide resolved
- "--label=org.opencontainers.image.source=https://github.com/go-task/task"
- "--label=org.opencontainers.image.licenses=MIT"
- "--label=org.opencontainers.image.authors=Andrey Nering <[email protected]>"
mircea-pavel-anton marked this conversation as resolved.
Show resolved Hide resolved
- "--label=org.opencontainers.image.description=Task is a task runner / build tool that aims to be simpler and easier to use than, for example, GNU Make."
- image_templates:
- "ghcr.io/go-task/task:v{{.Version}}-arm64v8"
use: buildx
goarch: arm64
dockerfile: Dockerfile
extra_files:
- completion/bash/task.bash
build_flag_templates:
- "--platform=linux/arm64/v8"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.url=https://github.com/go-task/task"
mircea-pavel-anton marked this conversation as resolved.
Show resolved Hide resolved
- "--label=org.opencontainers.image.source=https://github.com/go-task/task"
- "--label=org.opencontainers.image.licenses=MIT"
- "--label=org.opencontainers.image.authors=Andrey Nering <[email protected]>"
mircea-pavel-anton marked this conversation as resolved.
Show resolved Hide resolved
- "--label=org.opencontainers.image.description=Task is a task runner / build tool that aims to be simpler and easier to use than, for example, GNU Make."

docker_manifests:
- name_template: "ghcr.io/go-task/task:v{{.Version}}"
image_templates:
- "ghcr.io/go-task/task:v{{.Version}}-amd64"
- "ghcr.io/go-task/task:v{{.Version}}-arm64v8"

- name_template: "ghcr.io/go-task/task:latest"
image_templates:
- "ghcr.io/go-task/task:v{{.Version}}-amd64"
- "ghcr.io/go-task/task:v{{.Version}}-arm64v8"
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM scratch
COPY task /usr/local/bin/task
COPY completion/* /etc/completion/
CMD ["/usr/local/bin/task"]
14 changes: 14 additions & 0 deletions website/docs/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,20 @@ If you want to install Task in GitHub Actions you can try using

This installation method is community owned.

### Docker

If you are building a docker image that, among other utilities, must contain `Task` as well, you can copy over both the binary as well as the appropriate bash completion for your shell from the official `ghcr.io/go-task/task` docker image:
mircea-pavel-anton marked this conversation as resolved.
Show resolved Hide resolved

> Note: The image is available only for `amd64` and `arm64v8` architectures and only for Task versions starting at `v3.40.2`
mircea-pavel-anton marked this conversation as resolved.
Show resolved Hide resolved

```Dockerfile
FROM ubuntu:22.04
# ...
COPY --from=ghcr.io/go-task/task:v3.40.2 /usr/local/bin/task /usr/local/bin/task
COPY --from=ghcr.io/go-task/task:v3.40.2 /etc/completion/bash/task.bash /etc/bash_completion.d/task
# ...
```

## Build From Source

### Go Modules
Expand Down