diff --git a/README.md b/README.md index d6894983..cd205fa7 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ To help you start building real-world applications, we've created Kool Presets a - **Node**: [NestJS](docs/03-Presets/NestJS.md), [AdonisJs](docs/03-Presets/AdonisJs.md), [Express.js](/docs/03-Presets/ExpressJS.md) - **PHP**: [Laravel](docs/03-Presets/Laravel.md), [Laravel Octane](docs/03-Presets/Laravel+Octane.md), [Symfony](docs/03-Presets/Symfony.md), [CodeIgniter](docs/03-Presets/CodeIgniter.md) -- **Javascript**: [Next.js](docs/03-Presets/NextJS.md), [NuxtJS](docs/03-Presets/NuxtJS.md) +- **Javascript**: [Next.js](docs/03-Presets/NextJS.md), [NuxtJS](docs/03-Presets/NuxtJS.md), [Bun](docs/03-Presets/Bun.md) - **Others**: [Hugo](docs/03-Presets/Hugo.md), [WordPress](docs/03-Presets/WordPress.md) #### Monorepo structures diff --git a/commands/create.go b/commands/create.go index e0821f67..ba37f0ee 100644 --- a/commands/create.go +++ b/commands/create.go @@ -6,7 +6,6 @@ import ( "kool-dev/kool/core/presets" "kool-dev/kool/core/shell" "os" - "path" "path/filepath" "github.com/spf13/cobra" @@ -83,14 +82,16 @@ func (c *KoolCreate) Execute(args []string) (err error) { } } - // sets env variable CREATE_DIRECTORY so preset can use it - c.env.Set("CREATE_DIRECTORY", createDirectory) - if !c.parser.Exists(preset) { err = fmt.Errorf("unknown preset %s", preset) return } + var projectDir string + if projectDir, err = c.prepareCreateTarget(createDirectory); err != nil { + return + } + c.Shell().Println("Creating new", preset, "project...") c.parser.PrepareExecutor(c.Shell()) @@ -101,17 +102,16 @@ func (c *KoolCreate) Execute(args []string) (err error) { c.Shell().Println("Initializing", preset, "preset...") - if !path.IsAbs(createDirectory) { - if createDirectory, err = filepath.Abs(createDirectory); err != nil { - return - } + if _, err = os.Stat(projectDir); os.IsNotExist(err) { + err = fmt.Errorf("preset did not create folder %s", projectDir) + return } - if err = os.Chdir(createDirectory); err != nil { + if err = os.Chdir(projectDir); err != nil { return } - c.env.Set("PWD", createDirectory) + c.env.Set("PWD", projectDir) if err = c.parser.Install(preset); err != nil { return @@ -122,6 +122,31 @@ func (c *KoolCreate) Execute(args []string) (err error) { return } +// prepareCreateTarget makes CREATE_DIRECTORY a folder name relative to the +// current working directory so `kool docker` (which mounts cwd at /app) writes +// the new project onto the host. Absolute paths like /tmp/my-app otherwise +// land in the container's own /tmp and vanish when the container exits. +func (c *KoolCreate) prepareCreateTarget(createDirectory string) (projectDir string, err error) { + if projectDir, err = filepath.Abs(createDirectory); err != nil { + return + } + projectDir = filepath.Clean(projectDir) + + parent := filepath.Dir(projectDir) + base := filepath.Base(projectDir) + + if err = os.MkdirAll(parent, 0755); err != nil { + return + } + if err = os.Chdir(parent); err != nil { + return + } + + c.env.Set("CREATE_DIRECTORY", base) + c.env.Set("PWD", parent) + return +} + // NewCreateCommand initializes new kool create command func NewCreateCommand(create *KoolCreate) (createCmd *cobra.Command) { createCmd = &cobra.Command{ diff --git a/commands/create_test.go b/commands/create_test.go index 7560d6c1..fbbb9d40 100644 --- a/commands/create_test.go +++ b/commands/create_test.go @@ -7,6 +7,7 @@ import ( "kool-dev/kool/core/presets" "kool-dev/kool/core/shell" "os" + "path/filepath" "strings" "testing" ) @@ -117,3 +118,28 @@ func TestErrInstallCreateCommand(t *testing.T) { // return to original folder _ = os.Chdir(cwd) } + +func TestCreateCommandUsesRelativeCreateDirectory(t *testing.T) { + f := newFakeKoolCreate() + f.parser.(*presets.FakeParser).MockExists = true + + cwd, _ := os.Getwd() + defer func() { _ = os.Chdir(cwd) }() + + parent := t.TempDir() + dest := filepath.Join(parent, "my-app") + if err := os.Mkdir(dest, 0755); err != nil { + t.Fatal(err) + } + + cmd := NewCreateCommand(f) + cmd.SetArgs([]string{"laravel", dest}) + + if err := cmd.Execute(); err != nil { + t.Errorf("unexpected error executing create command; error: %v", err) + } + + if got := f.env.Get("CREATE_DIRECTORY"); got != "my-app" { + t.Errorf("CREATE_DIRECTORY should be the folder name for docker mounts, got %q", got) + } +} diff --git a/commands/docker.go b/commands/docker.go index 6e1b7349..782839e2 100644 --- a/commands/docker.go +++ b/commands/docker.go @@ -15,6 +15,7 @@ type KoolDockerFlags struct { Volumes []string Publish []string Network []string + User string } // KoolDocker holds handlers and functions to implement the docker command logic @@ -39,7 +40,7 @@ func AddKoolDocker(root *cobra.Command) { func NewKoolDocker() *KoolDocker { return &KoolDocker{ *newDefaultKoolService(), - &KoolDockerFlags{[]string{}, []string{}, []string{}, []string{}}, + &KoolDockerFlags{[]string{}, []string{}, []string{}, []string{}, ""}, environment.NewEnvStorage(), builder.NewCommand("docker", "run", "--init", "--rm", "-w", "/app", "-i"), } @@ -58,6 +59,12 @@ func (d *KoolDocker) Execute(args []string) (err error) { d.dockerRun.AppendArgs("--env", "ASUSER="+asuser) } + // run the container as the given user/UID (e.g. to keep created files + // owned by the host user on images that do not honor kool's ASUSER) + if d.Flags.User != "" { + d.dockerRun.AppendArgs("--user", d.Flags.User) + } + if len(d.Flags.EnvVariables) > 0 { for _, envVar := range d.Flags.EnvVariables { d.dockerRun.AppendArgs("--env", envVar) @@ -107,6 +114,7 @@ the [COMMAND] to provide optional arguments required by the COMMAND.`, cmd.Flags().StringArrayVarP(&docker.Flags.Volumes, "volume", "v", []string{}, "Bind mount a volume.") cmd.Flags().StringArrayVarP(&docker.Flags.Publish, "publish", "p", []string{}, "Publish a container's port(s) to the host.") cmd.Flags().StringArrayVarP(&docker.Flags.Network, "network", "n", []string{}, "Connect a container to a network.") + cmd.Flags().StringVarP(&docker.Flags.User, "user", "u", "", "Username or UID (format: [:]) to run the container as.") //After a non-flag arg, stop parsing flags cmd.Flags().SetInterspersed(false) diff --git a/commands/docker_test.go b/commands/docker_test.go index 172af55a..cea7f290 100644 --- a/commands/docker_test.go +++ b/commands/docker_test.go @@ -14,7 +14,7 @@ import ( func newFakeKoolDocker() *KoolDocker { return &KoolDocker{ *(newDefaultKoolService().Fake()), - &KoolDockerFlags{[]string{}, []string{}, []string{}, []string{}}, + &KoolDockerFlags{[]string{}, []string{}, []string{}, []string{}, ""}, environment.NewFakeEnvStorage(), &builder.FakeCommand{MockCmd: "docker"}, } @@ -23,7 +23,7 @@ func newFakeKoolDocker() *KoolDocker { func newFailedFakeKoolDocker() *KoolDocker { return &KoolDocker{ *(newDefaultKoolService().Fake()), - &KoolDockerFlags{[]string{}, []string{}, []string{}, []string{}}, + &KoolDockerFlags{[]string{}, []string{}, []string{}, []string{}, ""}, environment.NewFakeEnvStorage(), &builder.FakeCommand{MockCmd: "docker", MockInteractiveError: errors.New("error docker")}, } @@ -50,6 +50,10 @@ func TestNewKoolDocker(t *testing.T) { if len(k.Flags.Publish) > 0 { t.Errorf("bad default value for Publish flag on default KoolDocker instance") } + + if k.Flags.User != "" { + t.Errorf("bad default value for User flag on default KoolDocker instance") + } } if _, ok := k.dockerRun.(*builder.DefaultCommand); !ok { @@ -169,6 +173,24 @@ func TestEnvFlagNewDockerCommand(t *testing.T) { } } +func TestUserFlagNewDockerCommand(t *testing.T) { + f := newFakeKoolDocker() + f.shell.(*shell.FakeShell).MockIsTerminal = false + cmd := NewDockerCommand(f) + + cmd.SetArgs([]string{"--user=1000", "image"}) + + if err := cmd.Execute(); err != nil { + t.Errorf("unexpected error executing docker command; error: %v", err) + } + + argsAppend := f.dockerRun.(*builder.FakeCommand).ArgsAppend + + if len(argsAppend) != 4 || argsAppend[0] != "--user" || argsAppend[1] != "1000" { + t.Errorf("bad arguments to KoolDocker.dockerRun Command with User flag: %v", argsAppend) + } +} + func TestVolumesFlagNewDockerCommand(t *testing.T) { f := newFakeKoolDocker() f.shell.(*shell.FakeShell).MockIsTerminal = false diff --git a/commands/status.go b/commands/status.go index ca2acf91..f5468795 100644 --- a/commands/status.go +++ b/commands/status.go @@ -148,16 +148,33 @@ func (s *KoolStatus) getServices() (services []string, err error) { return } - parsedServices := strings.Split(strings.ReplaceAll(output, "\r\n", "\n"), "\n") - for _, s := range parsedServices { - if s != "" { - services = append(services, s) + services = parseComposeServices(output) + return +} + +func composeTokenLines(output string) (tokens []string) { + for _, line := range strings.Split(strings.ReplaceAll(output, "\r\n", "\n"), "\n") { + line = strings.TrimSpace(line) + if line == "" || strings.ContainsAny(line, " \t") { + continue } + tokens = append(tokens, line) } - return } +func parseComposeServices(output string) []string { + return composeTokenLines(output) +} + +func firstComposeToken(output string) string { + tokens := composeTokenLines(output) + if len(tokens) == 0 { + return "" + } + return tokens[0] +} + func (s *KoolStatus) fetchServiceInfo(service string, chStatus chan *statusService, wg *sync.WaitGroup) { var isRunning bool @@ -173,12 +190,19 @@ func (s *KoolStatus) fetchServiceInfo(service string, chStatus chan *statusServi } func (s *KoolStatus) getServiceInfo(service string) (isRunning bool, status, port string, err error) { - var serviceID string - if serviceID, err = s.Shell().Exec(s.getServiceIDCmd, service); err == nil && serviceID != "" { - status, port = s.getStatusPort(serviceID) - if strings.HasPrefix(status, "Up") { - isRunning = true - } + var output, serviceID string + if output, err = s.Shell().Exec(s.getServiceIDCmd, service); err != nil { + return + } + + // docker compose may mix warnings into combined output; keep only the container id + if serviceID = firstComposeToken(output); serviceID == "" { + return + } + + status, port = s.getStatusPort(serviceID) + if strings.HasPrefix(status, "Up") { + isRunning = true } return } diff --git a/commands/status_test.go b/commands/status_test.go index af0d7351..cedc04dd 100644 --- a/commands/status_test.go +++ b/commands/status_test.go @@ -257,3 +257,17 @@ cache | Not running | | output` t.Errorf("Expected '%s', got '%s'", expected, output) } } + +func TestParseComposeServicesIgnoresWarnings(t *testing.T) { + out := "time=\"2026-08-25T17:03:52-03:00\" level=warning msg=\"the attribute `version` is obsolete\"\napp\n" + services := parseComposeServices(out) + + if len(services) != 1 || services[0] != "app" { + t.Errorf("expected only 'app', got %v", services) + } + + idOut := "time=\"2026-08-25T17:03:52-03:00\" level=warning msg=\"the attribute `version` is obsolete\"\nabc123def456\n" + if got := firstComposeToken(idOut); got != "abc123def456" { + t.Errorf("expected container id, got %q", got) + } +} diff --git a/docs/01-Getting-Started/4-Starting-new-project.md b/docs/01-Getting-Started/4-Starting-new-project.md index 238d3731..1eed6db0 100644 --- a/docs/01-Getting-Started/4-Starting-new-project.md +++ b/docs/01-Getting-Started/4-Starting-new-project.md @@ -34,7 +34,6 @@ $ touch docker-compose.yml Copy/paste into this **docker-compose.yml** file a simple, generic Docker Compose configuration for an `app` service container: ```yaml -version: "3.8" # optional since v1.27.0 services: app: image: kooldev/php:8.0-nginx @@ -174,7 +173,6 @@ scripts: Here's a more extensible, **Kool-optimized** setup for **docker-compose.yml** into which you can easily add additional services (i.e. database, cache, etc): ```yaml -version: "3.8" # optional since v1.27.0 services: app: image: kooldev/php:8.0-nginx diff --git a/docs/03-Presets/0-About-Presets.md b/docs/03-Presets/0-About-Presets.md index 7e4b2c81..51dc005e 100644 --- a/docs/03-Presets/0-About-Presets.md +++ b/docs/03-Presets/0-About-Presets.md @@ -25,6 +25,7 @@ By leveraging Kool Presets, you not only reduce the learning curve associated wi - [Next.js](/docs/03-Presets/NextJS.md) - [NuxtJS](/docs/03-Presets/NuxtJS.md) +- [Bun](/docs/03-Presets/Bun.md) ## Others diff --git a/docs/03-Presets/AdonisJs.md b/docs/03-Presets/AdonisJs.md index 6d002c30..273529bf 100644 --- a/docs/03-Presets/AdonisJs.md +++ b/docs/03-Presets/AdonisJs.md @@ -47,10 +47,13 @@ $ Preset adonis is initializing! ? Which javascript package manager do you want to use [Use arrows to move, type to filter] > npm yarn + bun $ Preset adonis initialized! ``` +> **Experimental:** if you pick **bun**, the `app` service is configured to run the oven/bun:1 image (`command: bun --bun run dev`). AdonisJs officially targets Node, so running it on the Bun runtime is experimental and may require adjustments. To use Bun only as the package manager, keep `kooldev/node:20` as the `app` image in your **docker-compose.yml**. + Now, move into your new AdonisJs project: ```bash @@ -143,11 +146,11 @@ To help get you started, **kool.yml** comes prebuilt with an initial set of scri ```yaml scripts: adonis: kool exec app adonis - npm: kool exec app npm # or yarn + npm: kool exec app npm # or yarn / bun npx: kool exec app npx setup: - - kool docker kooldev/node:20 npm install # or yarn install + - kool docker kooldev/node:20 npm install # or yarn install / bun install (kool docker oven/bun:1 bun install) - kool start ``` @@ -246,6 +249,7 @@ $ kool start We have more presets to help you start projects with **kool** in a standardized way across different frameworks. +- **[Bun](/docs/03-Presets/Bun.md)** - **[CodeIgniter](/docs/03-Presets/CodeIgniter.md)** - **[Express.js](/docs/03-Presets/ExpressJS.md)** - **[Hugo](/docs/03-Presets/Hugo.md)** diff --git a/docs/03-Presets/Bun.md b/docs/03-Presets/Bun.md new file mode 100644 index 00000000..6caa3fba --- /dev/null +++ b/docs/03-Presets/Bun.md @@ -0,0 +1,178 @@ +# Start a Bun Project with Docker in 2 Easy Steps + +1. Run `kool create bunjs my-project` +2. Run `kool run setup` + +> Yes, using **kool** + Docker to create and work on new [Bun](https://bun.sh) projects is that easy! + +## Requirements + +If you haven't done so already, you first need to [install Docker and the kool CLI](/docs/getting-started/installation). + +Also, make sure you're running the latest version of **kool**. Run the following command to compare your local version of **kool** with the latest release, and, if a newer version is available, automatically download and install it. + +```bash +$ kool self-update +``` + +> Please note that it helps to have a basic understanding of how Docker and Docker Compose work to use Kool with Docker. + +## 1. Run `kool create bunjs my-project` + +Use the [`kool create PRESET FOLDER` command](/docs/commands/kool-create) to create your new Bun project: + +```bash +$ kool create bunjs my-project +``` + +Under the hood, this command will create a "Hello World" **app.js** file (powered by `Bun.serve`) and a minimal **package.json** in the root of your new project directory, using the official oven/bun:1 Docker image. + +After creating the project, `kool create` automatically runs the `kool preset bunjs` command, which sets up the initial tech stack for your project. + +```bash +$ Preset bunjs is initializing! + +... + +Preset bunjs created successfully! +``` + +Now, move into your new Bun project: + +```bash +$ cd my-project +``` + +The [`kool preset` command](/docs/commands/kool-preset) auto-generated the following configuration files and added them to your project, which you can modify and extend. + +```bash ++docker-compose.yml ++kool.yml ++app.js ++package.json +``` + +> Now's a good time to review the services added to the **docker-compose.yml** file. The `app` service runs the oven/bun:1 image with a `command` of `bun app.js`. + +## 2. Run `kool run setup` + +> Say hello to **kool.yml**, say goodbye to custom shell scripts! + +As mentioned above, the [`kool preset` command](/docs/commands/kool-preset) added a **kool.yml** file to your project. Think of **kool.yml** as a super easy-to-use task _helper_. Instead of writing custom shell scripts, add your own scripts to **kool.yml** (under the `scripts` key), and run them with `kool run SCRIPT` (e.g. `kool run bun`). You can add your own single line commands (see `bun` below), or add a list of commands that will be executed in sequence. + +To help get you started, **kool.yml** comes prebuilt with an initial set of scripts (based on the **preset**). + +```yaml +scripts: + bun: kool exec app bun + bunx: kool exec app bunx +``` + +Go ahead and run `kool start` to start running the container: + +```bash +$ kool start +``` + +> The **docker-compose.yml** file includes a `command` to automatically run `bun app.js` when the `app` container starts. + +Once the container is up, you should be able to access your new site at [http://localhost:3000](http://localhost:3000) and see the "Hello World" page. Hooray! + +Verify your Docker container is running using the [`kool status` command](/docs/commands/kool-status): + +```bash +$ kool status ++---------+---------+-------------------------------------------+--------------+ +| SERVICE | RUNNING | PORTS | STATE | ++---------+---------+-------------------------------------------+--------------+ +| app | Running | 0.0.0.0:3000->3000/tcp, :::3000->3000/tcp | Up 4 seconds | ++---------+---------+-------------------------------------------+--------------+ +``` + +Run `kool logs app` to see the logs from the running `app` container, and confirm the Bun server was started. + +> Use `kool logs` to see the logs from all running containers. Add the `-f` option after `kool logs` to follow the logs (i.e. `kool logs -f app`). + +```bash +$ kool logs app +Attaching to my-project_app_1 +app_1 | Server running at http://localhost:3000/ +``` + +--- + +### Install dependencies with Bun + +Use the `bun` helper script to manage your dependencies. Because Bun is both the runtime and the package manager, the same `app` container is used: + +```bash +$ kool run bun add hono +$ kool run bun install +``` + +### Run Commands in Docker Containers + +Use [`kool exec`](/docs/commands/kool-exec) to execute a command inside a running service container: + +```bash +# kool exec [OPTIONS] SERVICE COMMAND [--] [ARG...] + +$ kool exec app bun --version +``` + +Try `kool run bun --help` to execute the `kool exec app bun --help` command in your running `app` container and print out information about Bun. + +### Open Sessions in Docker Containers + +Similar to SSH, if you want to open a Bash session in your `app` container, run `kool exec app bash`, where `app` is the name of the service container in **docker-compose.yml**. If you prefer, you can use `sh` instead of `bash` (`kool exec app sh`). + +```bash +$ kool exec app bash +root@app:/app# + +$ kool exec app sh +/app # +``` + +### Access Private Repos and Packages in Docker Containers + +If you need your `app` container to use your local SSH keys to pull private repositories and/or install private packages (which have been added as dependencies in your `package.json` file), you can simply add `$HOME/.ssh:/home/kool/.ssh:delegated` under the `volumes` key of the `app` service in your **docker-compose.yml** file. This maps a `.ssh` folder in the container to the `.ssh` folder on your host machine. + +```diff +volumes: + - .:/app:delegated ++ - $HOME/.ssh:/home/kool/.ssh:delegated +``` + +## Staying kool + +When it's time to stop working on the project: + +```bash +$ kool stop +``` + +And when you're ready to start work again: + +```bash +$ kool start +``` + +## Additional Presets + +We have more presets to help you start projects with **kool** in a standardized way across different frameworks. + +- **[AdonisJs](/docs/03-Presets/AdonisJs.md)** +- **[CodeIgniter](/docs/03-Presets/CodeIgniter.md)** +- **[Express.js](/docs/03-Presets/ExpressJS.md)** +- **[Hugo](/docs/03-Presets/Hugo.md)** +- **[Laravel](/docs/03-Presets/Laravel.md)** +- **[NestJS](/docs/03-Presets/NestJS.md)** +- **[Next.js](/docs/03-Presets/NextJS.md)** +- **[Node.js](/docs/03-Presets/NodeJS.md)** +- **[Nuxt.js](/docs/03-Presets/NuxtJS.md)** +- **[PHP](/docs/03-Presets/PHP.md)** +- **[Symfony](/docs/03-Presets/Symfony.md)** +- **[WordPress](/docs/03-Presets/WordPress.md)** + +Missing a preset? **[Make a request](https://github.com/kool-dev/kool/issues/new)**, or contribute by opening a Pull Request. Go to [https://github.com/kool-dev/kool/tree/main/presets](https://github.com/kool-dev/kool/tree/main/presets) and browse the code to learn more about how presets work. diff --git a/docs/03-Presets/ExpressJS.md b/docs/03-Presets/ExpressJS.md index 8b15b57f..b62c3486 100644 --- a/docs/03-Presets/ExpressJS.md +++ b/docs/03-Presets/ExpressJS.md @@ -35,10 +35,13 @@ $ Preset expressjs is initializing! ? Which javascript package manager do you want to use [Use arrows to move, type to filter] > npm yarn + bun $ Preset expressjs initialized! ``` +> If you pick **bun**, the `app` service in your **docker-compose.yml** is configured to run the oven/bun:1 image (`command: bun app.js`), so your app runs on the Bun runtime. Otherwise it uses `kooldev/node:20`. + Now, move into your new Node.js project: ```bash @@ -65,11 +68,11 @@ To help get you started, **kool.yml** comes prebuilt with an initial set of scri ```yaml scripts: node: kool exec app node - npm: kool exec app npm # or yarn + npm: kool exec app npm # or yarn / bun npx: kool exec app npx setup: - - kool docker kooldev/node:20 npm install + - kool docker kooldev/node:20 npm install # bun: kool docker oven/bun:1 bun install - kool start # - add more setup commands ``` @@ -160,6 +163,7 @@ $ kool start We have more presets to help you start projects with **kool** in a standardized way across different frameworks. - **[AdonisJs](/docs/03-Presets/AdonisJs.md)** +- **[Bun](/docs/03-Presets/Bun.md)** - **[CodeIgniter](/docs/03-Presets/CodeIgniter.md)** - **[Hugo](/docs/03-Presets/Hugo.md)** - **[Laravel](/docs/03-Presets/Laravel.md)** diff --git a/docs/03-Presets/Laravel+Octane.md b/docs/03-Presets/Laravel+Octane.md index d9f8360b..2cd44954 100644 --- a/docs/03-Presets/Laravel+Octane.md +++ b/docs/03-Presets/Laravel+Octane.md @@ -24,7 +24,9 @@ $ kool create laravel+octane my-project This command will guide you through setting up a new Laravel project, installing Laravel Octane with your preferred server engine (either Swoole or RoadRunner), and setting up all the Docker Compose configuration files to manage your dockerized development environment. -After that, you will have the option to include a database or cache service, all of which helps you easily set up the initial tech stack for your project using an interactive wizard. +After that, you will have the option to include a database or cache service, and to choose a Javascript package manager (`npm`, `yarn`, or `bun`) for building your frontend assets — all of which helps you easily set up the initial tech stack for your project using an interactive wizard. + +> The Javascript package manager (including **bun**) is used only to build your frontend assets (e.g. Vite) — it runs in a one-off `oven/bun:1` container and configures the Vite `node` service. Your Laravel Octane `app` service still runs on PHP with your chosen engine (Swoole or RoadRunner). --- @@ -188,6 +190,7 @@ $ kool start We have more presets to help you start projects with **kool** in a standardized way across different frameworks. - **[AdonisJs](/docs/03-Presets/AdonisJs.md)** +- **[Bun](/docs/03-Presets/Bun.md)** - **[CodeIgniter](/docs/03-Presets/CodeIgniter.md)** - **[Express.js](/docs/03-Presets/ExpressJS.md)** - **[Hugo](/docs/03-Presets/Hugo.md)** diff --git a/docs/03-Presets/Laravel.md b/docs/03-Presets/Laravel.md index ff17f8ab..15b9809a 100644 --- a/docs/03-Presets/Laravel.md +++ b/docs/03-Presets/Laravel.md @@ -52,10 +52,14 @@ $ Preset laravel is initializing! ? Which javascript package manager do you want to use [Use arrows to move, type to filter] > npm yarn + bun + None $ Preset laravel initialized! ``` +> The Javascript package manager (including **bun**) is used only to build your frontend assets (e.g. Vite) — it runs in a one-off `oven/bun:1` container and configures the Vite `node` service. Your Laravel `app` service still runs on PHP. + Now, move into your new Laravel project: ```bash @@ -137,7 +141,7 @@ scripts: composer: kool exec app composer mysql: kool exec -e MYSQL_PWD=$DB_PASSWORD database mysql -uroot node: kool docker kooldev/node:20 node - npm: kool docker kooldev/node:20 npm # or yarn + npm: kool docker kooldev/node:20 npm # or yarn / bun (kool docker oven/bun:1 bun) npx: kool exec app npx setup: @@ -232,6 +236,7 @@ $ kool start We have more presets to help you start projects with **kool** in a standardized way across different frameworks. - **[AdonisJs](/docs/03-Presets/AdonisJs.md)** +- **[Bun](/docs/03-Presets/Bun.md)** - **[CodeIgniter](/docs/03-Presets/CodeIgniter.md)** - **[Express.js](/docs/03-Presets/ExpressJS.md)** - **[Hugo](/docs/03-Presets/Hugo.md)** diff --git a/docs/03-Presets/NextJS.md b/docs/03-Presets/NextJS.md index 45a708ee..44bd2d60 100644 --- a/docs/03-Presets/NextJS.md +++ b/docs/03-Presets/NextJS.md @@ -25,20 +25,24 @@ Use the [`kool create PRESET FOLDER` command](/docs/commands/kool-create) to cre $ kool create nextjs my-project ``` -Under the hood, this command will run `yarn create next-app my-project` to install Next.js using a customized **kool** Docker image: kooldev/node:20. +Under the hood, this command will run `npm create next-app my-project` (or the `yarn`/`bun` equivalent, based on your choice) to install Next.js. The `npm` and `yarn` options use a customized **kool** Docker image (kooldev/node:20), while the `bun` option uses the official oven/bun:1 image. After installing Next.js, `kool create` automatically runs the `kool preset nextjs` command, which helps you easily set up the initial tech stack for your project using an interactive wizard. ```bash $ Preset nextjs is initializing! -? Which javascript package manager do you want to use [Use arrows to move, type to filter] +? Which Javascript package manager do you want to use [Use arrows to move, type to filter] > npm yarn + bun + None $ Preset nextjs initialized! ``` +> If you pick **bun**, the `app` service in your **docker-compose.yml** is configured to run the oven/bun:1 image (`command: bun --bun run dev`), so your app runs on the Bun runtime. Otherwise it uses `kooldev/node:20`. + Now, move into your new Next.js project: ```bash @@ -64,11 +68,11 @@ To help get you started, **kool.yml** comes prebuilt with an initial set of scri ```yaml scripts: - npm: kool exec app npm # or yarn + npm: kool exec app npm # or yarn / bun npx: kool exec app npx setup: - - kool docker kooldev/node:20 npm install # or yarn install + - kool docker kooldev/node:20 npm install # or yarn install / bun install (kool docker oven/bun:1 bun install) - kool start ``` @@ -164,11 +168,13 @@ $ kool start We have more presets to help you start projects with **kool** in a standardized way across different frameworks. - **[AdonisJs](/docs/03-Presets/AdonisJs.md)** +- **[Bun](/docs/03-Presets/Bun.md)** - **[CodeIgniter](/docs/03-Presets/CodeIgniter.md)** - **[Express.js](/docs/03-Presets/ExpressJS.md)** - **[Hugo](/docs/03-Presets/Hugo.md)** - **[Laravel](/docs/03-Presets/Laravel.md)** - **[NestJS](/docs/03-Presets/NestJS.md)** +- **[Node.js](/docs/03-Presets/NodeJS.md)** - **[Nuxt.js](/docs/03-Presets/NuxtJS.md)** - **[PHP](/docs/03-Presets/PHP.md)** - **[Symfony](/docs/03-Presets/Symfony.md)** diff --git a/docs/03-Presets/NodeJS.md b/docs/03-Presets/NodeJS.md index 65dc63f9..bff95ba7 100644 --- a/docs/03-Presets/NodeJS.md +++ b/docs/03-Presets/NodeJS.md @@ -166,6 +166,7 @@ $ kool start We have more presets to help you start projects with **kool** in a standardized way across different frameworks. - **[AdonisJs](/docs/03-Presets/AdonisJs.md)** +- **[Bun](/docs/03-Presets/Bun.md)** - **[CodeIgniter](/docs/03-Presets/CodeIgniter.md)** - **[Express.js](/docs/03-Presets/ExpressJS.md)** - **[Hugo](/docs/03-Presets/Hugo.md)** diff --git a/docs/03-Presets/NuxtJS.md b/docs/03-Presets/NuxtJS.md index dce0314d..5b6783a3 100644 --- a/docs/03-Presets/NuxtJS.md +++ b/docs/03-Presets/NuxtJS.md @@ -26,20 +26,24 @@ Use the [`kool create PRESET FOLDER` command](/docs/commands/kool-create) to cre $ kool create nuxtjs my-project ``` -Under the hood, this command will run `yarn create nuxt-app my-project` to install NuxtJS using a customized **kool** Docker image: kooldev/node:20. +Under the hood, this command will run `npm create nuxt-app my-project` (or the `yarn`/`bun` equivalent, based on your choice) to install NuxtJS. The `npm` and `yarn` options use a customized **kool** Docker image (kooldev/node:20), while the `bun` option uses the official oven/bun:1 image. After installing NuxtJS, `kool create` automatically runs the `kool preset nuxtjs` command, which helps you easily set up the initial tech stack for your project using an interactive wizard. ```bash $ Preset nuxtjs is initializing! -? Which package manager did you choose during NuxtJS setup [Use arrows to move, type to filter] +? Which Javascript package manager do you want to use [Use arrows to move, type to filter] > npm yarn + bun + None $ Preset nuxtjs initialized! ``` +> If you pick **bun**, the `app` service in your **docker-compose.yml** is configured to run the oven/bun:1 image (`command: bun --bun run dev`), so your app runs on the Bun runtime. Otherwise it uses `kooldev/node:20`. + Now, move into your new NuxtJS project: ```bash @@ -83,11 +87,11 @@ To help get you started, **kool.yml** comes prebuilt with an initial set of scri ```yaml scripts: - npm: kool exec app npm # or yarn + npm: kool exec app npm # or yarn / bun npx: kool exec app npx setup: - - kool docker kooldev/node:20 npm install # or yarn install + - kool docker kooldev/node:20 npm install # or yarn install / bun install (kool docker oven/bun:1 bun install) - kool start ``` @@ -191,12 +195,14 @@ $ kool start We have more presets to help you start projects with **kool** in a standardized way across different frameworks. - **[AdonisJs](/docs/03-Presets/AdonisJs.md)** +- **[Bun](/docs/03-Presets/Bun.md)** - **[CodeIgniter](/docs/03-Presets/CodeIgniter.md)** - **[Express.js](/docs/03-Presets/ExpressJS.md)** - **[Hugo](/docs/03-Presets/Hugo.md)** - **[Laravel](/docs/03-Presets/Laravel.md)** - **[NestJS](/docs/03-Presets/NestJS.md)** - **[Next.js](/docs/03-Presets/NextJS.md)** +- **[Node.js](/docs/03-Presets/NodeJS.md)** - **[PHP](/docs/03-Presets/PHP.md)** - **[Symfony](/docs/03-Presets/Symfony.md)** - **[WordPress](/docs/03-Presets/WordPress.md)** diff --git a/docs/15-Snippets/Mailhog.md b/docs/15-Snippets/Mailhog.md index 8515d49c..f236507e 100644 --- a/docs/15-Snippets/Mailhog.md +++ b/docs/15-Snippets/Mailhog.md @@ -34,7 +34,6 @@ By default, MailHog uses in-memory message storage and starts the HTTP server on ### Full Example ```diff -version: "3.7" services: app: image: kooldev/php:8.0-nginx diff --git a/presets/adonis/config.yml b/presets/adonis/config.yml index a5358cee..a361bebd 100644 --- a/presets/adonis/config.yml +++ b/presets/adonis/config.yml @@ -7,9 +7,25 @@ name: 'AdonisJS' create: - name: Creating new Adonis Application actions: - - scripts: - - docker pull -q kooldev/node:20 - - kool docker kooldev/node:20 npm init -y adonis-ts-app@latest $CREATE_DIRECTORY + - prompt: 'Which Javascript package manager do you want to use for starter kit creation?' + ref: 'javascript_package_manager' + default: 'npm' + options: + - name: 'npm' + actions: + - scripts: + - docker pull -q kooldev/node:20 + - kool docker kooldev/node:20 npm init -y adonis-ts-app@latest $CREATE_DIRECTORY + - name: 'yarn' + actions: + - scripts: + - docker pull -q kooldev/node:20 + - kool docker kooldev/node:20 yarn create adonis-ts-app $CREATE_DIRECTORY + - name: 'bun' + actions: + - scripts: + - docker pull -q oven/bun:1 + - kool docker --user $KOOL_ASUSER --env HOME=/tmp oven/bun:1 bun create adonis-ts-app $CREATE_DIRECTORY # Preset defines the workflow for installing this preset in the current working directory preset: @@ -17,8 +33,6 @@ preset: actions: - copy: docker-compose.yml - copy: kool.yml - - merge: app/node-adonis.yml - dst: docker-compose.yml - name: 'Customize your setup' actions: @@ -26,13 +40,24 @@ preset: - recipe: pick-cache # define package manager - prompt: Which javascript package manager do you want to use? + ref: 'javascript_package_manager' default: 'npm' options: - name: 'npm' actions: + - merge: app/node-adonis.yml + dst: docker-compose.yml - merge: scripts/npm-adonis.yml dst: kool.yml - name: 'yarn' actions: + - merge: app/node-adonis.yml + dst: docker-compose.yml - merge: scripts/yarn-adonis.yml dst: kool.yml + - name: 'bun' + actions: + - merge: app/bun-adonis.yml + dst: docker-compose.yml + - merge: scripts/bun-adonis.yml + dst: kool.yml diff --git a/presets/bunjs/app.js b/presets/bunjs/app.js new file mode 100644 index 00000000..7cd6648e --- /dev/null +++ b/presets/bunjs/app.js @@ -0,0 +1,12 @@ +const hostname = "0.0.0.0"; +const port = 3000; + +Bun.serve({ + hostname, + port, + fetch() { + return new Response("Hello World"); + }, +}); + +console.log("Server running at http://localhost:" + port + "/"); diff --git a/presets/bunjs/bun-scripts.yml b/presets/bunjs/bun-scripts.yml new file mode 100644 index 00000000..6648ef04 --- /dev/null +++ b/presets/bunjs/bun-scripts.yml @@ -0,0 +1,3 @@ +scripts: + bun: kool exec app bun + bunx: kool exec app bunx diff --git a/presets/bunjs/config.yml b/presets/bunjs/config.yml new file mode 100644 index 00000000..02eb3b6d --- /dev/null +++ b/presets/bunjs/config.yml @@ -0,0 +1,22 @@ +# Which tags are related to this preset; used for branching the choices on preset wizard +tags: [ 'Javascript' ] + +name: 'Vanilla Bun' + +# Create defines the workflow for creating a new Project where this preset can then be installed +create: + - name: Creating new Bun application + actions: + - scripts: + - mkdir $CREATE_DIRECTORY + +# Preset defines the workflow for installing this preset in the current working directory +preset: + - name: 'Copy basic config files' + actions: + - copy: docker-compose.yml + - copy: kool.yml + - copy: app.js + - copy: package.json + - merge: bun-scripts.yml + dst: kool.yml diff --git a/presets/bunjs/docker-compose.yml b/presets/bunjs/docker-compose.yml new file mode 100644 index 00000000..fdc16ff4 --- /dev/null +++ b/presets/bunjs/docker-compose.yml @@ -0,0 +1,22 @@ +services: + app: + image: oven/bun:1 + command: ["bun", "app.js"] + working_dir: /app + user: "${KOOL_ASUSER:-0}" + ports: + - "${KOOL_APP_PORT:-3000}:3000" + environment: + HOME: "/tmp" + UID: "${UID:-0}" + volumes: + - .:/app:delegated + networks: + - kool_local + - kool_global + +networks: + kool_local: + kool_global: + external: true + name: "${KOOL_GLOBAL_NETWORK:-kool_global}" diff --git a/presets/bunjs/package.json b/presets/bunjs/package.json new file mode 100644 index 00000000..b7aae1be --- /dev/null +++ b/presets/bunjs/package.json @@ -0,0 +1,7 @@ +{ + "name": "my-kool-bun-app", + "module": "app.js", + "scripts": { + "start": "bun app.js" + } +} diff --git a/presets/expressjs/config.yml b/presets/expressjs/config.yml index fcf2b390..a34f68b5 100644 --- a/presets/expressjs/config.yml +++ b/presets/expressjs/config.yml @@ -14,7 +14,6 @@ create: preset: - name: 'Copy basic config files' actions: - - copy: docker-compose.yml - copy: kool.yml - copy: app.js - copy: package.json @@ -23,13 +22,22 @@ preset: actions: # define package manager - prompt: Which javascript package manager do you want to use? + ref: 'javascript_package_manager' default: 'npm' options: - name: 'npm' actions: + - copy: docker-compose.yml - merge: scripts/npm-expressjs.yml dst: kool.yml - name: 'yarn' actions: + - copy: docker-compose.yml - merge: scripts/yarn-expressjs.yml dst: kool.yml + - name: 'bun' + actions: + - copy: docker-compose.bun.yml + dst: docker-compose.yml + - merge: scripts/bun-expressjs.yml + dst: kool.yml diff --git a/presets/expressjs/docker-compose.bun.yml b/presets/expressjs/docker-compose.bun.yml new file mode 100644 index 00000000..fdc16ff4 --- /dev/null +++ b/presets/expressjs/docker-compose.bun.yml @@ -0,0 +1,22 @@ +services: + app: + image: oven/bun:1 + command: ["bun", "app.js"] + working_dir: /app + user: "${KOOL_ASUSER:-0}" + ports: + - "${KOOL_APP_PORT:-3000}:3000" + environment: + HOME: "/tmp" + UID: "${UID:-0}" + volumes: + - .:/app:delegated + networks: + - kool_local + - kool_global + +networks: + kool_local: + kool_global: + external: true + name: "${KOOL_GLOBAL_NETWORK:-kool_global}" diff --git a/presets/expressjs/docker-compose.yml b/presets/expressjs/docker-compose.yml index 4a5fbd85..5d3a62a7 100644 --- a/presets/expressjs/docker-compose.yml +++ b/presets/expressjs/docker-compose.yml @@ -1,4 +1,3 @@ -version: "3.7" services: app: image: kooldev/node:20 diff --git a/presets/hugo/docker-compose.yml b/presets/hugo/docker-compose.yml index e46b6ecf..5470bca9 100644 --- a/presets/hugo/docker-compose.yml +++ b/presets/hugo/docker-compose.yml @@ -1,4 +1,3 @@ -version: "3.8" services: app: image: klakegg/hugo:ext-alpine diff --git a/presets/laravel+octane/config.yml b/presets/laravel+octane/config.yml index a450fe22..c734b1d2 100644 --- a/presets/laravel+octane/config.yml +++ b/presets/laravel+octane/config.yml @@ -48,11 +48,27 @@ preset: dst: kool.yml - recipe: php-8.2-roadrunner - - name: 'Use NPM and install dependencies' + - name: 'Set up Javascript package manager and install dependencies' actions: - - recipe: npm-laravel - - scripts: - - kool run npm install --save-dev chokidar + - prompt: 'Which Javascript package manager do you want to use' + ref: 'javascript_package_manager' + default: 'npm' + options: + - name: 'npm' + actions: + - recipe: npm-laravel + - scripts: + - kool run npm install --save-dev chokidar + - name: 'yarn' + actions: + - recipe: yarn-laravel + - scripts: + - kool run yarn add --dev chokidar + - name: 'bun' + actions: + - recipe: bun-laravel + - scripts: + - kool run bun add --dev chokidar - name: 'Customize Database and Cache' actions: diff --git a/presets/nextjs/config.yml b/presets/nextjs/config.yml index eb8c445c..112b5a36 100644 --- a/presets/nextjs/config.yml +++ b/presets/nextjs/config.yml @@ -7,17 +7,54 @@ name: 'NextJS' create: - name: Creating new NextJS Application actions: - - scripts: - - docker pull -q kooldev/node:20 - - kool docker kooldev/node:20 yarn create next-app $CREATE_DIRECTORY + - prompt: 'Which Javascript package manager do you want to use for starter kit creation?' + ref: 'javascript_package_manager' + default: 'npm' + options: + - name: 'npm' + actions: + - scripts: + - docker pull -q kooldev/node:20 + - kool docker kooldev/node:20 npm create next-app@latest $CREATE_DIRECTORY + - name: 'yarn' + actions: + - scripts: + - docker pull -q kooldev/node:20 + - kool docker kooldev/node:20 yarn create next-app $CREATE_DIRECTORY + - name: 'bun' + actions: + - scripts: + - docker pull -q oven/bun:1 + - kool docker --user $KOOL_ASUSER --env HOME=/tmp oven/bun:1 bun create next-app $CREATE_DIRECTORY # Preset defines the workflow for installing this preset in the current working directory preset: - name: 'Copy basic config files' actions: - - copy: docker-compose.yml - copy: kool.yml - name: 'Customize your setup' actions: - - recipe: pick-node-pkg-mgr + - prompt: 'Which Javascript package manager do you want to use' + ref: 'javascript_package_manager' + default: 'npm' + options: + - name: 'npm' + actions: + - copy: docker-compose.yml + - merge: scripts/npm-nextjs.yml + dst: kool.yml + - name: 'yarn' + actions: + - copy: docker-compose.yml + - merge: scripts/yarn-nextjs.yml + dst: kool.yml + - name: 'bun' + actions: + - copy: docker-compose.bun.yml + dst: docker-compose.yml + - merge: scripts/bun-nextjs.yml + dst: kool.yml + - name: 'None' + actions: + - copy: docker-compose.yml diff --git a/presets/nextjs/docker-compose.bun.yml b/presets/nextjs/docker-compose.bun.yml new file mode 100644 index 00000000..acb81d4c --- /dev/null +++ b/presets/nextjs/docker-compose.bun.yml @@ -0,0 +1,22 @@ +services: + app: + image: oven/bun:1 + command: ["bun", "--bun", "run", "dev"] + working_dir: /app + user: "${KOOL_ASUSER:-0}" + ports: + - "${KOOL_APP_PORT:-3000}:3000" + environment: + HOME: "/tmp" + UID: "${UID:-0}" + volumes: + - .:/app:delegated + networks: + - kool_local + - kool_global + +networks: + kool_local: + kool_global: + external: true + name: "${KOOL_GLOBAL_NETWORK:-kool_global}" diff --git a/presets/nextjs/docker-compose.yml b/presets/nextjs/docker-compose.yml index ac9f2968..7cd3e3c0 100644 --- a/presets/nextjs/docker-compose.yml +++ b/presets/nextjs/docker-compose.yml @@ -1,4 +1,3 @@ -version: "3.7" services: app: image: kooldev/node:20 diff --git a/presets/nodejs/docker-compose.yml b/presets/nodejs/docker-compose.yml index 4a5fbd85..5d3a62a7 100644 --- a/presets/nodejs/docker-compose.yml +++ b/presets/nodejs/docker-compose.yml @@ -1,4 +1,3 @@ -version: "3.7" services: app: image: kooldev/node:20 diff --git a/presets/nuxtjs/config.yml b/presets/nuxtjs/config.yml index d5f382c5..f9564604 100644 --- a/presets/nuxtjs/config.yml +++ b/presets/nuxtjs/config.yml @@ -7,17 +7,54 @@ name: 'NuxtJS' create: - name: Creating new Nuxt Application actions: - - scripts: - - docker pull -q kooldev/node:20 - - kool docker kooldev/node:20 yarn create nuxt-app $CREATE_DIRECTORY + - prompt: 'Which Javascript package manager do you want to use for starter kit creation?' + ref: 'javascript_package_manager' + default: 'npm' + options: + - name: 'npm' + actions: + - scripts: + - docker pull -q kooldev/node:20 + - kool docker kooldev/node:20 npm create nuxt-app $CREATE_DIRECTORY + - name: 'yarn' + actions: + - scripts: + - docker pull -q kooldev/node:20 + - kool docker kooldev/node:20 yarn create nuxt-app $CREATE_DIRECTORY + - name: 'bun' + actions: + - scripts: + - docker pull -q oven/bun:1 + - kool docker --user $KOOL_ASUSER --env HOME=/tmp oven/bun:1 bun create nuxt-app $CREATE_DIRECTORY # Preset defines the workflow for installing this preset in the current working directory preset: - name: 'Copy basic config files' actions: - - copy: docker-compose.yml - copy: kool.yml - name: 'Customize your setup' actions: - - recipe: pick-node-pkg-mgr + - prompt: 'Which Javascript package manager do you want to use' + ref: 'javascript_package_manager' + default: 'npm' + options: + - name: 'npm' + actions: + - copy: docker-compose.yml + - merge: scripts/npm-nuxtjs.yml + dst: kool.yml + - name: 'yarn' + actions: + - copy: docker-compose.yml + - merge: scripts/yarn-nuxtjs.yml + dst: kool.yml + - name: 'bun' + actions: + - copy: docker-compose.bun.yml + dst: docker-compose.yml + - merge: scripts/bun-nuxtjs.yml + dst: kool.yml + - name: 'None' + actions: + - copy: docker-compose.yml diff --git a/presets/nuxtjs/docker-compose.bun.yml b/presets/nuxtjs/docker-compose.bun.yml new file mode 100644 index 00000000..acb81d4c --- /dev/null +++ b/presets/nuxtjs/docker-compose.bun.yml @@ -0,0 +1,22 @@ +services: + app: + image: oven/bun:1 + command: ["bun", "--bun", "run", "dev"] + working_dir: /app + user: "${KOOL_ASUSER:-0}" + ports: + - "${KOOL_APP_PORT:-3000}:3000" + environment: + HOME: "/tmp" + UID: "${UID:-0}" + volumes: + - .:/app:delegated + networks: + - kool_local + - kool_global + +networks: + kool_local: + kool_global: + external: true + name: "${KOOL_GLOBAL_NETWORK:-kool_global}" diff --git a/presets/nuxtjs/docker-compose.yml b/presets/nuxtjs/docker-compose.yml index 3404331f..bbefd130 100644 --- a/presets/nuxtjs/docker-compose.yml +++ b/presets/nuxtjs/docker-compose.yml @@ -1,4 +1,3 @@ -version: "3.7" services: app: image: kooldev/node:20 diff --git a/recipes/bun-laravel.yml b/recipes/bun-laravel.yml new file mode 100644 index 00000000..65e869c2 --- /dev/null +++ b/recipes/bun-laravel.yml @@ -0,0 +1,7 @@ +title: "Bun (Laravel)" + +actions: + - merge: scripts/bun-laravel.yml + dst: kool.yml + - merge: misc/bun-vitejs.yml + dst: docker-compose.yml diff --git a/recipes/bun.yml b/recipes/bun.yml new file mode 100644 index 00000000..6efb067f --- /dev/null +++ b/recipes/bun.yml @@ -0,0 +1,5 @@ +title: "Bun" + +actions: + - merge: scripts/bun.yml + dst: kool.yml diff --git a/recipes/create-codeigniter.yml b/recipes/create-codeigniter.yml index 896a05d1..c85d0bca 100644 --- a/recipes/create-codeigniter.yml +++ b/recipes/create-codeigniter.yml @@ -5,6 +5,16 @@ actions: ref: 'php-version' default: 'PHP 8.2' options: + - name: 'PHP 8.5' + actions: + - scripts: + - docker pull -q kooldev/php:8.5 + - kool docker kooldev/php:8.5 composer create-project --no-install --no-scripts --prefer-dist codeigniter4/appstarter $CREATE_DIRECTORY + - name: 'PHP 8.4' + actions: + - scripts: + - docker pull -q kooldev/php:8.4 + - kool docker kooldev/php:8.4 composer create-project --no-install --no-scripts --prefer-dist codeigniter4/appstarter $CREATE_DIRECTORY - name: 'PHP 8.3' actions: - scripts: diff --git a/recipes/create-laravel.yml b/recipes/create-laravel.yml index e0712cfc..7f7a1443 100644 --- a/recipes/create-laravel.yml +++ b/recipes/create-laravel.yml @@ -5,6 +5,16 @@ actions: ref: 'php-version' default: 'PHP 8.2' options: + - name: 'PHP 8.5' + actions: + - scripts: + - docker pull -q kooldev/php:8.5 + - kool docker kooldev/php:8.5 composer create-project --no-install --no-scripts --prefer-dist laravel/laravel $CREATE_DIRECTORY + - name: 'PHP 8.4' + actions: + - scripts: + - docker pull -q kooldev/php:8.4 + - kool docker kooldev/php:8.4 composer create-project --no-install --no-scripts --prefer-dist laravel/laravel $CREATE_DIRECTORY - name: 'PHP 8.3' actions: - scripts: diff --git a/recipes/create-symfony.yml b/recipes/create-symfony.yml index 78b162cc..265ed21a 100644 --- a/recipes/create-symfony.yml +++ b/recipes/create-symfony.yml @@ -5,6 +5,16 @@ actions: ref: 'php-version' default: 'PHP 8.2' options: + - name: 'PHP 8.5' + actions: + - scripts: + - docker pull -q kooldev/php:8.5 + - kool docker kooldev/php:8.5 composer create-project --no-install --prefer-dist symfony/website-skeleton $CREATE_DIRECTORY + - name: 'PHP 8.4' + actions: + - scripts: + - docker pull -q kooldev/php:8.4 + - kool docker kooldev/php:8.4 composer create-project --no-install --prefer-dist symfony/website-skeleton $CREATE_DIRECTORY - name: 'PHP 8.3' actions: - scripts: diff --git a/recipes/php-8.4.yml b/recipes/php-8.4.yml new file mode 100644 index 00000000..ad518188 --- /dev/null +++ b/recipes/php-8.4.yml @@ -0,0 +1,5 @@ +title: "PHP 8.4" + +actions: + - merge: app/php84.yml + dst: docker-compose.yml diff --git a/recipes/php-8.5.yml b/recipes/php-8.5.yml new file mode 100644 index 00000000..075fca7f --- /dev/null +++ b/recipes/php-8.5.yml @@ -0,0 +1,5 @@ +title: "PHP 8.5" + +actions: + - merge: app/php85.yml + dst: docker-compose.yml diff --git a/recipes/pick-laravel-node.yml b/recipes/pick-laravel-node.yml index b4ca87d0..126f680c 100644 --- a/recipes/pick-laravel-node.yml +++ b/recipes/pick-laravel-node.yml @@ -3,6 +3,7 @@ title: "Wizard: Laravel Node" actions: # Defines which Javascript package manager to use - prompt: 'Which Javascript package manager do you want to use' + ref: 'javascript_package_manager' default: 'npm' options: - name: 'npm' @@ -11,4 +12,7 @@ actions: - name: 'yarn' actions: - recipe: yarn-laravel + - name: 'bun' + actions: + - recipe: bun-laravel - name: 'None' diff --git a/recipes/pick-node-pkg-mgr.yml b/recipes/pick-node-pkg-mgr.yml index 40ff2b78..a368e1da 100644 --- a/recipes/pick-node-pkg-mgr.yml +++ b/recipes/pick-node-pkg-mgr.yml @@ -3,6 +3,7 @@ title: "Wizard: Node package manager" actions: # Defines which Javascript package manager to use - prompt: 'Which Javascript package manager do you want to use' + ref: 'javascript_package_manager' default: 'npm' options: - name: 'npm' @@ -11,4 +12,7 @@ actions: - name: 'yarn' actions: - recipe: yarn + - name: 'bun' + actions: + - recipe: bun - name: 'None' diff --git a/recipes/pick-php.yml b/recipes/pick-php.yml index 59d48c6d..c17b1ea8 100644 --- a/recipes/pick-php.yml +++ b/recipes/pick-php.yml @@ -6,6 +6,12 @@ actions: ref: 'php-version' default: 'PHP 8.2' options: + - name: 'PHP 8.5' + actions: + - recipe: php-8.5 + - name: 'PHP 8.4' + actions: + - recipe: php-8.4 - name: 'PHP 8.3' actions: - recipe: php-8.3 diff --git a/services/compose/parser.go b/services/compose/parser.go index 72877150..d7ff32e7 100644 --- a/services/compose/parser.go +++ b/services/compose/parser.go @@ -7,7 +7,7 @@ type yamlMarshalFnType func(interface{}) ([]byte, error) // Compose represents a docker-compose file type Compose struct { - Version string `yaml:"version"` + Version string `yaml:"version,omitempty"` Services yaml.MapSlice `yaml:"services"` Volumes yaml.MapSlice `yaml:"volumes,omitempty"` Networks yaml.MapSlice `yaml:"networks,omitempty"` @@ -34,7 +34,6 @@ var ( // NewParser creates new docker-compose parser func NewParser() Parser { compose := &Compose{ - Version: "3.7", Networks: yaml.MapSlice{ yaml.MapItem{Key: "kool_local"}, yaml.MapItem{ diff --git a/services/compose/parser_test.go b/services/compose/parser_test.go index c013fdf5..d2ee4bcb 100644 --- a/services/compose/parser_test.go +++ b/services/compose/parser_test.go @@ -10,8 +10,7 @@ import ( "gopkg.in/yaml.v2" ) -const composeFile string = `version: "3.7" -services: +const composeFile string = `services: service: image: service-image volumes: diff --git a/templates/app/bun-adonis.yml b/templates/app/bun-adonis.yml new file mode 100644 index 00000000..62f8588d --- /dev/null +++ b/templates/app/bun-adonis.yml @@ -0,0 +1,16 @@ +services: + app: + image: oven/bun:1 + command: ["bun", "--bun", "run", "dev"] + working_dir: /app + user: "${KOOL_ASUSER:-0}" + ports: + - "${KOOL_APP_PORT:-3333}:3333" + environment: + HOME: "/tmp" + UID: "${UID:-0}" + volumes: + - .:/app:delegated + networks: + - kool_local + - kool_global diff --git a/templates/app/php84.yml b/templates/app/php84.yml new file mode 100644 index 00000000..ff0deffe --- /dev/null +++ b/templates/app/php84.yml @@ -0,0 +1,13 @@ +services: + app: + image: kooldev/php:8.4-nginx + ports: + - "${KOOL_APP_PORT:-80}:80" + environment: + ASUSER: "${KOOL_ASUSER:-0}" + UID: "${UID:-0}" + volumes: + - .:/app:delegated + networks: + - kool_local + - kool_global diff --git a/templates/app/php85.yml b/templates/app/php85.yml new file mode 100644 index 00000000..0f984310 --- /dev/null +++ b/templates/app/php85.yml @@ -0,0 +1,13 @@ +services: + app: + image: kooldev/php:8.5-nginx + ports: + - "${KOOL_APP_PORT:-80}:80" + environment: + ASUSER: "${KOOL_ASUSER:-0}" + UID: "${UID:-0}" + volumes: + - .:/app:delegated + networks: + - kool_local + - kool_global diff --git a/templates/docker-compose.yml b/templates/docker-compose.yml index b60ec547..79eb3492 100644 --- a/templates/docker-compose.yml +++ b/templates/docker-compose.yml @@ -1,4 +1,3 @@ -version: "3.8" # # Services definitions # diff --git a/templates/misc/bun-vitejs.yml b/templates/misc/bun-vitejs.yml new file mode 100644 index 00000000..197429bf --- /dev/null +++ b/templates/misc/bun-vitejs.yml @@ -0,0 +1,15 @@ +services: + node: + image: oven/bun:1 + command: ["bun", "--bun", "run", "dev"] + working_dir: /app + user: "${KOOL_ASUSER:-0}" + environment: + HOME: "/tmp" + ports: + - "3001:3001" + volumes: + - .:/app:delegated + networks: + - kool_local + - kool_global diff --git a/templates/scripts/bun-adonis.yml b/templates/scripts/bun-adonis.yml new file mode 100644 index 00000000..b8b7d224 --- /dev/null +++ b/templates/scripts/bun-adonis.yml @@ -0,0 +1,8 @@ +scripts: + adonis: kool exec app adonis + bun: kool exec app bun + bunx: kool exec app bunx + + setup: + - kool docker --user $KOOL_ASUSER --env HOME=/tmp oven/bun:1 bun install + - kool start diff --git a/templates/scripts/bun-expressjs.yml b/templates/scripts/bun-expressjs.yml new file mode 100644 index 00000000..4508c470 --- /dev/null +++ b/templates/scripts/bun-expressjs.yml @@ -0,0 +1,8 @@ +scripts: + node: kool exec app node + bun: kool exec app bun + bunx: kool exec app bunx + + setup: + - kool docker --user $KOOL_ASUSER --env HOME=/tmp oven/bun:1 bun install + - kool start diff --git a/templates/scripts/bun-laravel.yml b/templates/scripts/bun-laravel.yml new file mode 100644 index 00000000..267f23c5 --- /dev/null +++ b/templates/scripts/bun-laravel.yml @@ -0,0 +1,8 @@ +scripts: + # bun - helpers for JS handling + bun: kool docker --user $KOOL_ASUSER --env HOME=/tmp oven/bun:1 bun + bunx: kool docker --user $KOOL_ASUSER --env HOME=/tmp oven/bun:1 bunx + before-start: + - kool run bun install + reset: + - kool run bun install diff --git a/templates/scripts/bun-nextjs.yml b/templates/scripts/bun-nextjs.yml new file mode 100644 index 00000000..21d1c0e0 --- /dev/null +++ b/templates/scripts/bun-nextjs.yml @@ -0,0 +1,7 @@ +scripts: + bun: kool exec app bun + bunx: kool exec app bunx + + setup: + - kool docker --user $KOOL_ASUSER --env HOME=/tmp oven/bun:1 bun install + - kool start diff --git a/templates/scripts/bun-nuxtjs.yml b/templates/scripts/bun-nuxtjs.yml new file mode 100644 index 00000000..21d1c0e0 --- /dev/null +++ b/templates/scripts/bun-nuxtjs.yml @@ -0,0 +1,7 @@ +scripts: + bun: kool exec app bun + bunx: kool exec app bunx + + setup: + - kool docker --user $KOOL_ASUSER --env HOME=/tmp oven/bun:1 bun install + - kool start diff --git a/templates/scripts/bun.yml b/templates/scripts/bun.yml new file mode 100644 index 00000000..5098b30a --- /dev/null +++ b/templates/scripts/bun.yml @@ -0,0 +1,8 @@ +scripts: + # bun - helpers for JS handling + bun: kool docker --user $KOOL_ASUSER --env HOME=/tmp oven/bun:1 bun + bunx: kool docker --user $KOOL_ASUSER --env HOME=/tmp oven/bun:1 bunx + setup: + - kool run bun install + reset: + - kool run bun install