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

Add debian+nix dev container #360

Merged
merged 3 commits into from
Sep 18, 2023
Merged

Conversation

moeffju
Copy link
Contributor

@moeffju moeffju commented Sep 17, 2023

This commit adds a dev container configuration file for a debian bullseye + nix container. Supporting IDEs, such as VS Code, should offer to open the cloned repository in the dev container, where users can then follow the minimal setup steps to quickly have a running dev instance without fiddling with their linux distro or nix locally.

It's a little bit more comfortable for VS Code users than the minimal docker setup.

This commit adds a dev container configuration file for a debian
bullseye + nix container. Supporting IDEs, such as VS Code, should offer
to open the cloned repository in the dev container, where users can then
follow the [minimal setup](https://github.com/bugbakery/transcribee/blob/main/doc/development_setup.md#minimal-setup-nix) steps
to quickly have a running dev instance without fiddling with their linux
distro or nix locally.

It's a little bit more comfortable for VS Code users than the minimal
docker setup.
@pajowu
Copy link
Member

pajowu commented Sep 17, 2023

Nice, this also enables github codespaces, right?

@moeffju moeffju force-pushed the feature/devcontainer branch from d94541a to bd152e3 Compare September 17, 2023 21:52
@moeffju
Copy link
Contributor Author

moeffju commented Sep 17, 2023

Yeah, I believe that should also enable codespaces!

It does not currently automatically run nix-shell or ./packaging/dev.sh, but that could be added.
Alternatively, dependencies can be added as dev container features, but that would be a bit messier because then there's multiple ways to manage dependencies.

@pajowu
Copy link
Member

pajowu commented Sep 17, 2023

I think not running nix-shell or dev.sh is fine (at least for now), but could you please add some documentation on how to use this to doc/development_setup.md

@pajowu
Copy link
Member

pajowu commented Sep 17, 2023

Also sadly this doesn't seem to work in codespaces right now due to some bug NixOS/nix#6680

@moeffju
Copy link
Contributor Author

moeffju commented Sep 17, 2023

I tried running a codespace on my fork and it seemed to work, but I'll try again.
Pushing commits for auto-building the nix env and running packaging/dev on first container run too, and will add documentation (although there isn't a lot to say, conforming IDEs should just notify the user).

@moeffju
Copy link
Contributor Author

moeffju commented Sep 17, 2023

Another thing that might be useful is to mount /nix into a volume so it persists between rebuilds. Currently if you rebuild the container, the nix cache is blown away as well, which is a bit annoying.

@moeffju moeffju force-pushed the feature/devcontainer branch from c4e1553 to 60a6d33 Compare September 18, 2023 08:25
* Switch to nix-devcontainer, which automatically runs
  nix-shell shell.nix
* Use compose file to enable caching /nix in a volume
* Add onCreateCommand to initialize nix env on first
  container run
* Add documentation for dev container in `development_setup.md`
@moeffju moeffju force-pushed the feature/devcontainer branch from 60a6d33 to e6b8d6b Compare September 18, 2023 08:26
@moeffju
Copy link
Contributor Author

moeffju commented Sep 18, 2023

Ok, I think I'm happy with this. Changes:

  • Switch to nix-devcontainer, which automatically runs nix-shell shell.nix
  • Use compose file to enable caching /nix in a volume
  • Add onCreateCommand to initialize nix env on first container run
  • Add documentation for dev container in development_setup.md

@moeffju
Copy link
Contributor Author

moeffju commented Sep 18, 2023

$ pre-commit run --all-files
check for added large files..............................................Passed
check for merge conflicts................................................Passed
check toml...............................................................Passed
check yaml...............................................................Passed
debug statements (python)................................................Passed
fix end of files.........................................................Passed
trim trailing whitespace.................................................Passed
black....................................................................Passed
Run ruff for python files................................................Passed
Run typechecker for backend..............................................Passed
Run typechecker for worker...............................................Passed
update openapi-schema of the backend.....................................Passed
run backend tests........................................................Passed
run worker tests.........................................................Passed
eslint...................................................................Passed
openapi-typescript.......................................................Passed
tsc......................................................................Passed
format...................................................................Passed
pnpm test................................................................Passed

@pajowu
Copy link
Member

pajowu commented Sep 18, 2023

At least in code spaces the image does not build with the following error message:

The Compose file is invalid because:
Service dev has neither an image nor a build context specified. At least one must be provided.
Screenshot 2023-09-18 at 11 23 25

@pajowu pajowu enabled auto-merge September 18, 2023 10:16
@pajowu pajowu added this pull request to the merge queue Sep 18, 2023
Merged via the queue into bugbakery:main with commit e4633a2 Sep 18, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Offer a dev container config for easier setup of dev environments for non-nix users
2 participants