File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed
Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -19,11 +19,21 @@ Build without initializing a dotfiles repo:
1919docker build -t my-chezmoi ./chezmoi
2020```
2121
22- Build and initialize with a dotfiles repo:
22+ Build and initialize with a public dotfiles repo:
2323``` bash
2424docker build --build-arg CHEZMOI_REPO=https://github.com/username/dotfiles.git -t my-chezmoi ./chezmoi
2525```
2626
27+ Build and initialize with a private dotfiles repo using SSH keys:
28+ ``` bash
29+ docker buildx build --ssh default --build-arg
[email protected] :username/dotfiles.git -t my-chezmoi ./chezmoi
30+ ```
31+
32+ Build and initialize with a private dotfiles repo using token:
33+ ``` bash
34+ docker build --build-arg CHEZMOI_REPO=https://
[email protected] /username/dotfiles.git -t my-chezmoi ./chezmoi
35+ ```
36+
2737> [ !WARNING]
2838> Using ` CHEZMOI_REPO ` will execute code from the dotfiles repository during the build process. Only use with trusted repositories.
2939
Original file line number Diff line number Diff line change @@ -18,9 +18,19 @@ RUN mise use --global aqua:twpayne/chezmoi@${CHEZMOI_VERSION}
1818# Optional: Initialize chezmoi with a dotfiles repo
1919# WARNING: This will execute code from the dotfiles repository during build.
2020# Only use with trusted repositories.
21+ #
22+ # For public repos or repos with token:
23+ # docker build --build-arg CHEZMOI_REPO=https://github.com/user/dotfiles.git
24+ # docker build --build-arg CHEZMOI_REPO=https://[email protected] /user/dotfiles.git25+ #
26+ # For private repos with SSH:
27+ # docker buildx build --ssh default --build-arg [email protected] :user/dotfiles.git2128ARG CHEZMOI_REPO=""
22- RUN if [ -n "$CHEZMOI_REPO" ]; then \
23- chezmoi init --apply "$CHEZMOI_REPO" ; \
29+ RUN --mount=type=ssh \
30+ mkdir -p ~/.ssh && \
31+ ssh-keyscan github.com >> ~/.ssh/known_hosts 2>/dev/null || true && \
32+ if [ -n "$CHEZMOI_REPO" ]; then \
33+ chezmoi init --apply "$CHEZMOI_REPO" ; \
2434 fi
2535
2636CMD ["/bin/zsh" ]
You can’t perform that action at this time.
0 commit comments