-
Notifications
You must be signed in to change notification settings - Fork 4
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
Provide devcontainer #517
Merged
Merged
Provide devcontainer #517
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
5ea047d
Enable dockerfile plugin in dprint
kachick 358d774
WIP
kachick 24e80a9
Devcontainer
kachick 86f1550
Super hard!
kachick 6a802bc
Merge branch 'main' into docker-or-devcontainer
kachick c4eff5d
Drop dprint-plugin-dockerfile to avoid the incorrect alerts
kachick 4998b57
Integrate hadolint
kachick 5f4f770
Looks like hadolint action does not consider dotfiles in file glob
kachick 26c2a00
Remove testing code because of checked the hadolint behabvior in CI
kachick 9b15d53
Finish basic of devcontainer...!
kachick 1e21a0e
Add devcontainer CI
kachick d1571ac
Enable scheduled trigger for container CI
kachick 4d01d2b
Try the PATH setting
kachick 99474ae
I dont know why bin/sh used only in CI...
kachick cabc9aa
Remove outdaetd code
kachick 1042544
Give it a try!
kachick ed5a3ae
Add debug log
kachick 206e8ad
Looks like a same issue of https://github.com/devcontainers/ci/issues…
kachick af54fc3
We drop the mkdir phase again
kachick 9ae97c7
Merge branch 'main' into docker-or-devcontainer
kachick 481643a
Prefer 22.04
kachick 826963d
Give it a try! (I guess, this will fail)
kachick 051525f
I am tired
kachick 471efad
Add more debugg logging
kachick feca185
Revert 826963d2819a89de49cfadcdfc10e73565e3ac9e
kachick 8743170
I am a new in debugger;
kachick 4a497cf
Persially revert 051525ff7317a500dac4424a67e06f7402910923
kachick 23b7f15
Update UID/GID with hostmachine before installing NIX
kachick 2a63dd7
Fix missing commit
kachick 48e41e8
Restrict with whole timeout-minutes
kachick 08743fc
Is this the correct shell specifier?
kachick 5b4025f
This action can not simulate actuall devcontainer use :<
kachick 3c14af5
`git checkout main dprint.json`
kachick 31c3820
Fix a typo
kachick dc9977c
Merge branch 'main' into docker-or-devcontainer
kachick f8c454a
Fix merge miss
kachick 34cec69
Update docs
kachick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,48 @@ | ||
# Do not use `FROM nixos/nix`. It cannot use `groupadd` even not the NixOS | ||
# See https://stackoverflow.com/questions/75653182/why-do-some-official-nix-docker-containers-not-have-the-nixos-rebuild-command | ||
FROM mcr.microsoft.com/devcontainers/base:ubuntu-22.04 | ||
|
||
# Above microsoft image contains to create vscode user | ||
|
||
# Use same UID/GID to avoid mount and nix path permission issues | ||
ARG container_user_uid | ||
ARG container_user_gid | ||
RUN usermod -u $container_user_uid vscode && groupmod -g $container_user_gid vscode | ||
|
||
# Switching the user should be after the changed IDs | ||
USER vscode | ||
|
||
# This just uses for following build steps. | ||
# vscode will set the WORKDIR into `/workspaces/wait-other-job` | ||
WORKDIR /home/vscode/sandbox | ||
|
||
# The install scripts will be syntax error if it will be eval with dash | ||
SHELL ["/bin/bash", "-c"] | ||
|
||
# daemon mode required systemd, docker disables it | ||
# As I understand the definition https://hub.docker.com/r/nixos/nix/dockerfile at Nix 2.17, it looks like a single user installation(no-daemon) | ||
# See https://github.com/NixOS/nix/blob/fd4f03b8fdcb0f33552730c786139019e29f5dbe/scripts/install-nix-from-closure.sh#L129-L139 | ||
RUN bash <(curl -L https://nixos.org/nix/install) --no-daemon --yes | ||
Comment on lines
+22
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
ENV PATH /home/vscode/.nix-profile/bin:$PATH | ||
|
||
# Basically do NOT merge files in COPY to prefer inline cache benefit | ||
|
||
# Make sure the building phase done. To cache. `nix-build --no-out-link` does similar, but it skips bash. | ||
# NOTE: This does not mean the entry point is in nix-shell. | ||
COPY ["../default.nix", "./"] | ||
|
||
# Do no include like `npm install` here. Cuurently I don't cache it in container | ||
RUN nix-channel --update && nix-shell --run 'echo "Keep this line to build nix environment in this phase"' | ||
|
||
COPY ["./.devcontainer/setup_direnv.bash", "./"] | ||
RUN ./setup_direnv.bash | ||
|
||
# Clean up to avoid confusion | ||
# hadolint ignore=DL3059 | ||
RUN rm ./default.nix ./setup_direnv.bash | ||
|
||
# `ENTRYPOINT` and `CMD` will be ignored in .devcontainer. Use postCreateCommand instead | ||
# To simulate in docker, following CMD requires to specify PWD with repository files. Check `makers docker-shell` | ||
ENTRYPOINT ["./.devcontainer/bootstrap.bash"] | ||
CMD ["zsh"] |
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,11 @@ | ||
## How to update path for each extentions of devcontainer.json? | ||
|
||
Like this. | ||
|
||
```console | ||
nix-instantiate --eval -E '(import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/4ef0dd85324fca49bf06fd9f2d52711503b1128c.tar.gz") {}).pkgs.dprint.outPath' | tr -d '"' | ||
``` | ||
|
||
You should update them after updating fetchTarball path in default.nix | ||
|
||
I want to realize better integration, but I don't know it. |
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,4 @@ | ||
#!/usr/bin/env bash | ||
|
||
whoami && id && cat /etc/passwd && ls -alh /nix && ls -alh . && \ | ||
nix-shell --run 'direnv allow && makers setup' |
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,62 @@ | ||
{ | ||
"build": { | ||
"dockerfile": "Dockerfile", | ||
"context": "..", | ||
"args": { | ||
"container_user_uid": "${localEnv:container_user_uid:1000}", | ||
"container_user_gid": "${localEnv:container_user_gid:1000}" | ||
} | ||
}, | ||
"remoteUser": "vscode", | ||
"containerUser": "vscode", | ||
"updateRemoteUserUID": true, | ||
"containerEnv": { | ||
"HOME": "/home/vscode" | ||
}, | ||
"userEnvProbe": "loginShell", | ||
"postCreateCommand": "./.devcontainer/bootstrap.bash", | ||
"customizations": { | ||
"vscode": { | ||
"settings": { | ||
"terminal.integrated.profiles.linux": { | ||
"zsh": { | ||
"path": "/usr/bin/zsh" | ||
} | ||
}, | ||
"terminal.integrated.defaultProfile.linux": "zsh", | ||
"editor.defaultFormatter": "dprint.dprint", | ||
"editor.formatOnSave": true, | ||
"hadolint.hadolintPath": "/nix/store/3lrlw90virfykpbxv4n1mbap0g8593r5-hadolint-2.12.0/bin/hadolint", | ||
"dprint.path": "/nix/store/6rzbms3q4p7yfp56c9vcr9ip83r1rl8m-dprint-0.36.1/bin/dprint", | ||
"[nix]": { | ||
"editor.defaultFormatter": "jnoortheen.nix-ide" | ||
}, | ||
"json.schemas": [ | ||
{ | ||
"fileMatch": [ | ||
"dprint.json" | ||
], | ||
"url": "https://docs.renovatebot.com/renovate-schema.json" | ||
} | ||
], | ||
"cSpell.words": [ | ||
"deno", | ||
"dprint", | ||
"OIDC", | ||
"rmrf" | ||
] | ||
}, | ||
"extensions": [ | ||
"github.vscode-github-actions", | ||
"dbaeumer.vscode-eslint", | ||
"redhat.vscode-yaml", | ||
"editorconfig.editorconfig", | ||
"dprint.dprint", | ||
"jnoortheen.nix-ide", | ||
"tamasfe.even-better-toml", | ||
"exiasr.hadolint", | ||
"ms-azuretools.vscode-docker" | ||
] | ||
} | ||
} | ||
} |
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,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
docker build . --tag wait-other-jobs:latest --build-arg container_user_uid="$(stat -c '%u' .)" --build-arg container_user_gid="$(stat -c '%g' .)" --file .devcontainer/Dockerfile |
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,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
docker run --interactive --tty --rm --volume "$(pwd):/workspaces/wait-other-job" --workdir "/workspaces/wait-other-job" wait-other-jobs: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,4 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo 'eval "$(nix-shell --run '"'"'direnv hook bash'"'"')"' >> ~/.bashrc | ||
echo 'eval "$(nix-shell --run '"'"'direnv hook zsh'"'"')"' >> ~/.zshrc |
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 @@ | ||
use_nix |
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,44 @@ | ||
name: 'CI - Devcontainer' | ||
on: | ||
push: | ||
branches: [main] | ||
paths: | ||
- '.devcontainer/**' | ||
- '.github/workflows/ci-devcontainer.yml' | ||
- '*.nix' | ||
- 'Makefile.toml' | ||
- '**vscode**' | ||
pull_request: | ||
paths: | ||
- '.devcontainer/**' | ||
- '.github/workflows/ci-devcontainer.yml' | ||
- '*.nix' | ||
- 'Makefile.toml' | ||
- '**vscode**' | ||
schedule: | ||
# About JST 8:00 | ||
- cron: '0 17 * * *' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
timeout-minutes: 30 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Log host users and file owners | ||
run: | | ||
whoami | ||
id | ||
ls -alh | ||
- name: Set UID and GID as ENV from repository files | ||
run: | | ||
uid="$(stat -c '%u' .)" | ||
gid="$(stat -c '%g' .)" | ||
echo "container_user_uid=${uid}" | tee -a "$GITHUB_ENV" | ||
echo "container_user_gid=${gid}" | tee -a "$GITHUB_ENV" | ||
- name: Build and run dev container task | ||
uses: devcontainers/[email protected] | ||
with: | ||
# Can't we call these comands on the nix-shell even enabled direnv...? | ||
runCmd: nix-shell --run 'makers help && makers versions && makers check' |
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,24 @@ | ||
name: hadolint | ||
on: | ||
push: | ||
branches: [main] | ||
paths: | ||
- '**Dockerfile' | ||
- '**.dockerfile' | ||
- '.github/workflows/hadolint.yml' | ||
pull_request: | ||
paths: | ||
- '**Dockerfile' | ||
- '**.dockerfile' | ||
- '.github/workflows/hadolint.yml' | ||
|
||
jobs: | ||
lint: | ||
timeout-minutes: 15 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: hadolint/[email protected] | ||
with: | ||
recursive: 'true' | ||
dockerfile: .devcontainer/Dockerfile |
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,10 +1,13 @@ | ||
{ | ||
"recommendations": [ | ||
"github.vscode-github-actions", | ||
"dbaeumer.vscode-eslint", | ||
"redhat.vscode-yaml", | ||
"editorconfig.editorconfig", | ||
"dprint.dprint", | ||
"jnoortheen.nix-ide", | ||
"tamasfe.even-better-toml" | ||
"tamasfe.even-better-toml", | ||
"exiasr.hadolint", | ||
"ms-azuretools.vscode-docker" | ||
] | ||
} |
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
NixOS/nix#4896 Looks same issue