-
Notifications
You must be signed in to change notification settings - Fork 0
Add chezmoi toolbox image with optional dotfiles initialization #10
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
base: main
Are you sure you want to change the base?
Changes from 6 commits
eb61f1c
477a5fd
55f3384
8c68db7
66210e0
0506649
679a0c4
f716f20
f8ca570
dcfd2b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| name: Build and Push Chezmoi Image | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - 'chezmoi/**' | ||
| - '.github/workflows/build-chezmoi-image.yml' | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - 'chezmoi/**' | ||
| - '.github/workflows/build-chezmoi-image.yml' | ||
| workflow_run: | ||
| workflows: ["Build and Push Base Image"] | ||
| types: | ||
| - completed | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
|
|
||
| env: | ||
| REGISTRY: ghcr.io | ||
| IMAGE_NAME: ${{ github.repository }}/chezmoi | ||
|
|
||
| jobs: | ||
| build-and-push: | ||
| runs-on: ubuntu-latest | ||
| if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }} | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Log in to Container Registry | ||
| if: github.event_name != 'pull_request' | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ${{ env.REGISTRY }} | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Determine base image tag | ||
| id: base-tag | ||
| run: | | ||
| if [ "${{ github.event_name }}" = "workflow_run" ]; then | ||
| echo "tag=sha-$(echo ${{ github.event.workflow_run.head_sha }} | cut -c1-7)" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "tag=latest" >> $GITHUB_OUTPUT | ||
| fi | ||
| - name: Extract metadata for Docker | ||
| id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
| tags: | | ||
| type=ref,event=branch | ||
| type=ref,event=pr | ||
| type=sha,prefix=sha- | ||
| type=raw,value=latest,enable={{is_default_branch}} | ||
| - name: Build and push Docker image | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: ./chezmoi | ||
| push: ${{ github.event_name != 'pull_request' }} | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| build-args: | | ||
| BASE_IMAGE_TAG=${{ steps.base-tag.outputs.tag }} | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,2 +1,34 @@ | ||||||
| # toolbox | ||||||
| Various special purpose toolboxes as container images | ||||||
|
|
||||||
| ## Available Toolboxes | ||||||
|
|
||||||
| ### Base | ||||||
| Base toolbox image with common dependencies (ca-certificates, curl, git, zsh, mise). | ||||||
|
|
||||||
| ### Devcontainer | ||||||
| Development container image with git, SSH, GPG, and locale support. | ||||||
|
||||||
| Development container image with git, SSH, GPG, and locale support. | |
| Development container image with SSH, GPG, and locale support. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit 679a0c4.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make zsh the default command for a run or start
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit 679a0c4 by adding CMD ["/bin/zsh"] to the Dockerfile.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,26 @@ | ||||||
| ARG BASE_IMAGE_TAG=latest | ||||||
| FROM ghcr.io/jhulten/toolbox/base:${BASE_IMAGE_TAG} | ||||||
|
|
||||||
| LABEL org.opencontainers.image.title="Toolbox Chezmoi" | ||||||
| LABEL org.opencontainers.image.description="Container image with chezmoi for dotfiles management" | ||||||
| LABEL org.opencontainers.image.source="https://github.com/jhulten/toolbox" | ||||||
| LABEL org.opencontainers.image.licenses="MIT" | ||||||
|
|
||||||
| ENV DEBIAN_FRONTEND=noninteractive | ||||||
|
|
||||||
| USER root | ||||||
|
|
||||||
| # Install chezmoi using the official installation script | ||||||
| ARG CHEZMOI_VERSION=2.56.1 | ||||||
| RUN sh -c "$(curl -fsLS get.chezmoi.io)" -- -b /usr/local/bin -t v${CHEZMOI_VERSION} | ||||||
|
||||||
| RUN sh -c "$(curl -fsLS get.chezmoi.io)" -- -b /usr/local/bin -t v${CHEZMOI_VERSION} | |
| RUN sh -c "$(curl -fsLS --proto '=https' https://get.chezmoi.io)" -- -b /usr/local/bin -t v${CHEZMOI_VERSION} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using the curl endpoint, please install chezmoi with mise (aqua:twpayne/chezmoi).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would we pass credentials to chezmoi to get dotfiles from a private repo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For private repos, credentials can be passed by:
- Using
--build-arg CHEZMOI_REPO=https://[email protected]/user/dotfiles.gitwith a GitHub personal access token - Mounting SSH keys at build time with
--sshin Docker buildx (requires modifying the Dockerfile to useRUN --mount=type=ssh) - Or, skip initialization during build and run
chezmoi initmanually after starting the container with mounted credentials
The current implementation supports option 1. Options 2-3 would require additional Dockerfile modifications if you'd like me to add them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing trailing newline at end of file. According to POSIX standard and common best practices, text files should end with a newline character.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit 679a0c4.