Skip to content

Commit

Permalink
Do not generate dockerfile on shell command (#54)
Browse files Browse the repository at this point in the history
## Summary
Do not generate dockerfile on shell command, as someone who is using the shell command may not need to use language detector, or need to fill in `install`, `build` and `start` command if the language planner is absent.

## How was it tested?
devbox shell
devbox generate
devbox build
  • Loading branch information
LucilleH committed Sep 2, 2022
1 parent e472379 commit 8470053
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions devbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,14 @@ func (d *Devbox) Plan() *planner.Plan {
// the devbox environment.
func (d *Devbox) Generate() error {
plan := d.Plan()
return generate(d.srcDir, plan)
return generate(d.srcDir, plan, append(shellFiles, buildFiles...))
}

// Shell generates the devbox environment and launches nix-shell as a child
// process.
func (d *Devbox) Shell() error {
err := d.Generate()
plan := d.Plan()
err := generate(d.srcDir, plan, shellFiles)
if err != nil {
return errors.WithStack(err)
}
Expand Down
8 changes: 5 additions & 3 deletions generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ import (
//go:embed tmpl/* tmpl/.*
var tmplFS embed.FS

func generate(rootPath string, plan *planner.Plan) error {
// TODO: we should also generate a .dockerignore file
files := []string{".gitignore", "Dockerfile", "shell.nix", "default.nix"}
var shellFiles = []string{".gitignore", "shell.nix"}

// TODO: we should also generate a .dockerignore file
var buildFiles = []string{".gitignore", "default.nix", "Dockerfile"}

func generate(rootPath string, plan *planner.Plan, files []string) error {
outPath := filepath.Join(rootPath, ".devbox/gen")

for _, file := range files {
Expand Down

0 comments on commit 8470053

Please sign in to comment.