You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Kool**works with Docker and Docker Compose under the hood to power up small, fast and reproducible local development environments. **Kool** provides simple, no-brainer ease-of-use while keeping all the power and flexibility of Docker and Docker Compose. **Kool** makes using Docker super easy without losing any control, ensuring you remain fully in charge of every detail related to your Docker environments.
1
+
**Kool**is a suite of open source dev tools that level up the way you build and deploy modern, cloud native web applications. By using Kool, you'll get a better development environment and a better development workflow, which adds up to **a better developer experience**.
2
2
3
-
### Presets
3
+
<aname="better-development-environment"></a>
4
+
## A Better Development Environment
4
5
5
-
Out of the box, **kool** ships with a collection of presets to help you quickly kickstart local development using some popular frameworks and stacks. Check out the [Laravel preset](https://kool.dev/docs/presets/laravel) as an example of the developer experience **kool** offers.
6
+
### Kool CLI
6
7
7
-
### docker-compose.yml
8
+
The `kool` CLI is the "command center" of Kool's suite of dev tools. If you haven't done so already, you first need to [install Docker and the Kool CLI](https://kool.dev/docs/getting-started/installation). And then, when you have time, get up-to-speed with the [Kool CLI commands](https://kool.dev/docs/commands/kool).
8
9
9
-
This is the Docker Compose configuration file, and it should be placed inside your project and committed to version control. This file defines all the service containers needed to run your application (the Docker images to use, ports, volume mounts, etc). It follows the [Docker Compose implementation of the Compose format](https://docs.docker.com/compose/compose-file/). Over time, you'll probably make tweaks and improvements to this file according to the specific needs of your project.
10
+
> If you already have `kool` installed, make sure you're running the latest version with `kool self-update`.
11
+
12
+
### Kool Presets
13
+
14
+
Out of the box, Kool ships with a collection of Presets that will help you quickly kickstart local development environments for new and existing projects using popular frameworks and tech stacks.
15
+
16
+
> As an example of the Preset developer experience, check out the [Laravel preset](https://kool.dev/docs/presets/laravel).
17
+
18
+
-[AdonisJs](/docs/2-Presets/AdonisJs.md)
19
+
-[Hugo](/docs/2-Presets/Hugo.md)
20
+
-[Laravel](/docs/2-Presets/Laravel.md)
21
+
-[NestJS](/docs/2-Presets/NestJS.md)
22
+
-[Next.js](/docs/2-Presets/NextJS.md)
23
+
-[Node.js](/docs/2-Presets/NodeJS.md)
24
+
-[Nuxt.js](/docs/2-Presets/NuxtJS.md)
25
+
-[PHP](/docs/2-Presets/PHP.md)
26
+
-[Symfony](/docs/2-Presets/Symfony.md)
27
+
-[WordPress](/docs/2-Presets/WordPress.md)
28
+
29
+
### Docker and Docker Compose
30
+
31
+
Kool works with Docker and Docker Compose under the hood to spin up small, fast and reproducible local development environments. Kool provides a super easy, hassle-free way to handle the Docker basics and immediately start using containers for development, while simultaneously guaranteeing no loss of control over fully customizing and extending more specialized Docker environments. You always remain fully in charge of every detail of your Docker environments.
32
+
33
+
#### docker-compose.yml
34
+
35
+
This is your Docker Compose configuration file. It should be placed inside your project and committed to version control. This file defines all the service containers needed to run your application (Docker images, ports, volume mounts, networks, etc), and follows the [Docker Compose implementation of the Compose format](https://docs.docker.com/compose/compose-file/). Over time, you'll probably make changes to this file according to the evolving needs of your project.
36
+
37
+
#### Kool Docker Images
38
+
39
+
When you start developing in containers, you quickly realize the official Docker images are built for deployment, and not for the special considerations (and nuances) of local development. One of the most common and recurring problems we see are permission issues with mapped volumes, due to host users being different from container users. Kool fixes this problem, and many others, by creating custom Docker images optimized for local development environments. [Learn more about how Kool optimizes its Docker images](https://kool.dev/docs/docker-images/introduction).
10
40
11
41
### Environment Variables
12
42
13
-
**Kool** loads environment variables from a **.env** file. If there's a **.env.local** file, it will take precedence and get loaded first, overriding variables in the **.env** file which use the exact same name. This helps define host-specific settings that are only applicable to your local machine.
43
+
Kool loads environment variables from a **.env** file. If there's a **.env.local** file, it will take precedence and get loaded first, overriding variables in the **.env** file which use the exact same name. This helps define host-specific settings that are only applicable to your local machine.
44
+
45
+
> It's important to keep in mind that **real** environment variables defined inline as `VAR=value kool ...` or via `export VAR=value` will take precedence over the same variables in your **.env** files.
14
46
15
-
> It's important to keep in mind that **real** environment variables win (take precedence) over variables defined in your **.env** files.
47
+
### Kool Snippets
48
+
49
+
Add services to your development environment by copying and pasting code snippets into your project's **docker-compose.yml** file. We just have a couple at the moment, but we'll be adding more soon.
This is the **kool** configuration file, and it should be placed inside your project and committed to version control. This file defines scripts (commands) that you execute in your local environment or CI/CDs. 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:` root key), and run them with `kool run <script-name>`. You can add your own single line commands, or add a list of commands that will be executed in sequence.
56
+
This is your Kool configuration file. It defines scripts (commands) that you execute in your local environment or CI/CD workflows. It should be placed inside your project and committed to version control. Think of **kool.yml** as a super easy-to-use task helper. Instead of writing custom shell scripts, you can add your own scripts to **kool.yml** (under the scriptskey), and run them with `kool run SCRIPT`. You can add single line commands (`kool run artisan`), or add a list of commands that will be executed in sequence (`kool run setup`).
20
57
21
58
> Use **environment variables** within your scripts to **parameterize** them, and give them an extra bit of power and flexibility.
22
59
23
-
Every **preset**includes a **kool.yml** file with prebuilt scripts for that stack. Of course, you can add your own custom scripts to facilitate your development process and share knowledge across the team.
60
+
Every **Kool Preset**auto-generates a **kool.yml** file with prebuilt scripts customized for that framework and/or stack. You can then modify this file and add your own custom scripts to facilitate your development process and share knowledge across your team. For example, add scripts to run database migrations, reset local environments, run static analysis tools, and so on. Think about how much easier it will be to onboard a teammate or new developer :)
24
61
25
62
```yaml
26
-
# ./kool.yml for Laravel preset
63
+
# ./kool.yml for the Laravel preset
27
64
28
65
scripts:
29
66
artisan: kool exec app php artisan
67
+
composer: kool exec app composer
68
+
mysql: kool exec -e MYSQL_PWD=$DB_PASSWORD database mysql -uroot
69
+
node: kool docker kooldev/node:14 node
70
+
npm: kool docker kooldev/node:14 npm # or yarn
71
+
npx: kool exec app npx
72
+
73
+
node-setup:
74
+
- kool run npm install # or yarn install
75
+
- kool run npm run dev # or yarn dev
76
+
77
+
reset:
78
+
- kool run composer install
79
+
- kool run artisan migrate:fresh --seed
80
+
- kool run node-setup
30
81
31
82
setup:
83
+
- cp .env.example .env
32
84
- kool start
85
+
- kool run composer install
33
86
- kool run artisan key:generate
87
+
- kool run node-setup
34
88
```
35
89
36
-
Using the `artisan` command:
90
+
For example, use the `artisan` script in Laravel's **kool.yml** as follows:
37
91
38
92
```bash
39
93
kool run artisan tinker
40
94
```
41
95
42
96
#### Types of Commands
43
97
44
-
The **kool.yml** file is not just for **kool** commands. You can add any type of command you usually run in your shell, such as `cat`, `cp`, `mv`, etc.
98
+
The **kool.yml** file is not just for **kool** commands. You can add any type of command that you usually run in your shell, such as `cat`, `cp`, `mv`, etc.
45
99
46
-
However, there is one important caveat - the commands you add to **kool.yml** are parsed and executed by the **kool** binary, and not in a general **bash** context. This means you **cannot** directly use **bash** control structures like `if []; then fi`, or redirection with pipes (`cmd | cmd2`). With that said, **we do support** input and output redirection (see below). W00t!
100
+
However, there's one important caveat – the commands you add to **kool.yml** are parsed and executed by the **kool** binary, and not in a general **bash** context. This means you **cannot** directly use **bash** control structures like `if []; then fi`, or redirection with pipes (`cmd | cmd2`). With that said, **we do support** input and output redirection (see below).
47
101
48
102
> If you need to add a more complex shell command, you can use something like `kool docker <some bash image> bash -c ""`, which will parse any bash script you need.
49
103
50
104
#### Adding Arguments
51
105
52
-
At the end of single line scripts like `kool run <script-name>`, you can also add arguments you want to pass down to the encapsulated command. Single line commands, such as `artisan`, are like aliases, whereby additional arguments are forwarded to the actual command. For example, `kool run artisan key:generate` basically becomes `kool exec app php artisan key:generate`.
106
+
At the end of single line scripts like `kool run SCRIPT`, you can also add arguments you want to pass down to the encapsulated command. Single line commands, such as `artisan`, are like aliases, whereby additional arguments are forwarded to the actual command. For example, `kool run artisan key:generate` basically becomes `kool exec app php artisan key:generate`.
53
107
54
-
At this time, adding arguments is **only supported** by **single line** commands. **Multi-line** commands (like `setup`) will return an error if an extra argument is added to the end (i.e. `kool run setup something`).
108
+
At this time, adding arguments is **only supported** by **single line** scripts. **Multi-line** scripts (like `setup`) will return an error if an extra argument is added to the end (i.e. `kool run setup some-argument`).
55
109
56
110
#### Input and Output Redirects
57
111
@@ -76,11 +130,103 @@ scripts:
76
130
77
131
Of course, the syntax is not as flexible as you would get directly in **bash**.
78
132
79
-
- The redirect key **must be a single argument** (not glued to other arguments)
80
-
- Correct: `write: echo "something" > output.txt`
81
-
- Wrong: `write: echo "something">output.txt`
82
-
- When performing an output redirect, the last argument after the redirect key **must be a single file destination**
133
+
The redirect key **must be a single argument** (not glued to other arguments):
134
+
- Correct: `write: echo "something" > output.txt`
135
+
- Wrong: `write: echo "something">output.txt`
136
+
137
+
When performing an output redirect, the last argument after the redirect key **must be a single file destination**.
83
138
84
139
#### Learn More
85
140
86
-
Learn more by taking a closer look at the **kool.yml** files in our [presets](https://kool.dev/docs/presets/introduction). They contain good examples of prebuilt commands that are ready to use in a handful of different stacks. If you need help creating custom scripts based on your own unique needs, don't hesitate to ask on GitHub.
141
+
Learn more by taking a closer look at the **kool.yml** files in our [Presets](https://github.com/kool-dev/kool/tree/master/presets). They contain good examples of prebuilt commands that are ready to use in a handful of different stacks. If you need help creating custom scripts based on your own unique needs, don't hesitate to [ask us on Slack](https://kool.dev/slack).
142
+
143
+
<a name="better-development-workflow"></a>
144
+
## A Better Development Workflow
145
+
146
+
Start work on a project by moving into the project directory and using `kool start` to spin up your local Docker environment. Once you're up and running, use the `kool` CLI to level up your development workflow.
147
+
148
+
### Run Commands
149
+
150
+
Use the [`kool exec` command](https://kool.dev/docs/commands/kool-exec) to execute a command inside a running service container.
151
+
152
+
```bash
153
+
# kool exec [OPTIONS] SERVICE COMMAND [--] [ARG...]
154
+
155
+
$ kool exec app ls
156
+
```
157
+
158
+
Look at the **kool.yml** files in the [Presets](https://github.com/kool-dev/kool/tree/master/presets) to see other examples of `kool exec` commands used in scripts.
159
+
160
+
### Open Sessions
161
+
162
+
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 your **docker-compose.yml**. If you prefer, you can use `sh` instead of `bash` (`kool exec app sh`).
163
+
164
+
```bash
165
+
$ kool exec app bash
166
+
bash-5.1#
167
+
168
+
$ kool exec app sh
169
+
/app #
170
+
```
171
+
172
+
### Connect to the Database
173
+
174
+
If you added a database service, start a new SQL client session inside your running `database` container by executing `kool run mysql` (MySQL) or `kool run psql` (PostgreSQL). This runs the `mysql` or `psql` script in your **kool.yml**.
175
+
176
+
### Add Dependencies
177
+
178
+
If you're working on a Node-based project, and you add more dependencies to `package.json`, use the [`kool restart` command](https://kool.dev/docs/commands/kool-restart) to restart your `app` container and load the new packages.
179
+
180
+
```console
181
+
$ kool restart app
182
+
183
+
Stopping my-project_app_1 ... done
184
+
Going to remove my-project_app_1
185
+
Removing my-project_app_1 ... done
186
+
Creating my-project_app_1 ... done
187
+
```
188
+
189
+
### Access Private Repos and Packages
190
+
191
+
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 `composer.json` or `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.
192
+
193
+
```diff
194
+
volumes:
195
+
- .:/app:delegated
196
+
+ - $HOME/.ssh:/home/kool/.ssh:delegated
197
+
```
198
+
199
+
### View the Logs
200
+
201
+
View container logs using the [`kool logs` command](https://kool.dev/docs/commands/kool-logs). Run `kool logs` to see the logs for all running containers, or `kool logs app` to specify a service and only see the logs for the `app` container. Add the `-f` option after `kool logs` to follow the logs (i.e. `kool logs -f app`).
202
+
203
+
### Share Your Work
204
+
205
+
When you need to quickly share local changes with your team, use the [`kool share` command](https://kool.dev/docs/commands/kool-share) to share your local environment over the Internet via an HTTP tunnel. Specify your own subdomain using the `--subdomain` flag. Since the default port is `80`, you'll also need to use the `--port` option for Node apps (i.e. `kool share --port=3000`).
206
+
207
+
```console
208
+
$ kool share
209
+
210
+
Thank you for using expose.
211
+
Local-URL: app
212
+
Dashboard-URL: http://127.0.0.1:4040
213
+
Expose-URL: https://eeskzijcbe.kool.live
214
+
215
+
Remaining time: 00:59:59
216
+
Remaining time: 00:59:58
217
+
Remaining time: 00:59:57
218
+
```
219
+
220
+
### Switch Projects
221
+
222
+
Kool supports any language or framework, so you can standardize the way you work across all your tech stacks. When it's time to stop working on your current app and switch to a different project, you can easily change local Docker environments by running `kool stop`, moving into the other project directory, and running `kool start`.
223
+
224
+
```console
225
+
$ kool stop
226
+
$ cd ~/my-other-project
227
+
$ kool start
228
+
```
229
+
230
+
Pretty _kool_, right?
231
+
232
+
> If you like what we're doing, show your support for this new open source project by [**starring us on GitHub**](https://github.com/kool-dev/kool)!
0 commit comments