-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(dev): improve devcontainer setup
Splits the devcontainer into two distinct parts: one for building the image and one for consuming and adding lifecycle commands. The image-building devcontainer.json uses devcontainer features and populates the `ghcr.io/loft-sh/devpod:dev` image. The top-level devcontainer.json consumes the image and adds lifecycle commands and potentially other properties that don't force the image to change to it. Also added a couple of smaller niceties
- Loading branch information
1 parent
8e5ace8
commit afc4b6c
Showing
5 changed files
with
112 additions
and
16 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 |
---|---|---|
@@ -1,18 +1,6 @@ | ||
{ | ||
"name": "Go", | ||
"build": { | ||
"dockerfile": "Dockerfile" | ||
}, | ||
"remoteUser": "vscode", | ||
"features": { | ||
"ghcr.io/devcontainers/features/docker-in-docker:2": { | ||
"version": "latest" | ||
}, | ||
"ghcr.io/devcontainers/features/kubectl-helm-minikube:1": { | ||
"version": "latest" | ||
}, | ||
"ghcr.io/dhoeric/features/k9s:1": { | ||
"version": "latest" | ||
} | ||
} | ||
"name": "DevPod Development", | ||
"image": "ghcr.io/loft-sh/devpod:dev", | ||
"remoteUser": "devpod", | ||
"postCreateCommand": "bash ./.devcontainer/post_create.sh" | ||
} |
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,28 @@ | ||
|
||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
log() { | ||
echo "[POST_CREATE] $*" | ||
} | ||
|
||
REBUILD_SCRIPT="./hack/rebuild.sh" | ||
|
||
if [[ ! -f "$REBUILD_SCRIPT" ]]; then | ||
log "Error: Rebuild script not found at $REBUILD_SCRIPT" >&2 | ||
exit 1 | ||
fi | ||
|
||
|
||
log "Building initial version of devpod binary" | ||
chmod +x "$REBUILD_SCRIPT" | ||
BUILD_PLATFORMS="linux" "$REBUILD_SCRIPT" | ||
|
||
# Add our user to docker group | ||
sudo usermod -aG docker $USER | ||
|
||
log "Installing docker provider with default options" | ||
devpod provider add docker | ||
|
||
log "Done" |
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
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,27 @@ | ||
{ | ||
"name": "DevPod Development Image", | ||
"build": { | ||
"dockerfile": "Dockerfile", | ||
"context": "." | ||
}, | ||
"features": { | ||
"ghcr.io/devcontainers/features/common-utils:2": { | ||
"installZsh": true, | ||
"configureZshAsDefaultShell": true, | ||
"installOhMyZsh": true, | ||
"installOhMyZshConfig": true, | ||
"upgradePackages": true, | ||
"username": "devpod" | ||
}, | ||
"ghcr.io/devcontainers/features/github-cli:1": {}, | ||
"ghcr.io/devcontainers/features/docker-in-docker:2": { | ||
"version": "latest" | ||
}, | ||
"ghcr.io/devcontainers/features/kubectl-helm-minikube:1": { | ||
"version": "latest" | ||
}, | ||
"ghcr.io/dhoeric/features/k9s:1": { | ||
"version": "latest" | ||
} | ||
} | ||
} |
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,41 @@ | ||
name: Build Dev Container | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- "main" | ||
paths: | ||
- ".github/devcontainer/**" | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: "write" | ||
contents: "read" | ||
steps: | ||
- name: Checkout | ||
id: checkout | ||
uses: actions/checkout@v1 | ||
|
||
- name: Prepare DevPod | ||
run: | | ||
curl -L -o devpod "https://github.com/loft-sh/devpod/releases/latest/download/devpod-linux-amd64" \ | ||
&& sudo install -c -m 0755 devpod /usr/local/bin \ | ||
&& rm -f devpod | ||
devpod provider add docker | ||
- name: "Build and push image" | ||
run: | | ||
devpod build . --devcontainer-path .github/devcontainer/devcontainer.json --platform linux/amd64,linux/arm64 --skip-push | ||
# Change tag to `latest` | ||
ID=$(docker images --format "{{.ID}} {{.CreatedAt}} {{.Tag}}" | sort -rk 2 | grep "devpod" | awk 'NR==1{print $1}') | ||
echo "found image: $ID" | ||
if [ -z "${ID}" ]; then | ||
echo "Image ID empty, exiting" | ||
exit 0 | ||
fi | ||
docker image ls | ||
docker tag $ID ghcr.io/loft-sh/devpod:dev | ||
docker push ghcr.io/loft-sh/devpod:dev |