-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4cdf21c
Showing
53 changed files
with
3,863 additions
and
0 deletions.
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,24 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.{yml,yaml}] | ||
indent_size = 2 | ||
|
||
[docker-compose.yml] | ||
indent_size = 4 | ||
|
||
[*.{js,ts,css,scss}] | ||
indent_size = 2 | ||
|
||
[*.blade.php] | ||
indent_size = 2 |
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,2 @@ | ||
vendor | ||
.idea |
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,16 @@ | ||
MIT License | ||
|
||
Copyright (c) Tiknil srl | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the | ||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit | ||
persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the | ||
Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | ||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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,137 @@ | ||
[Skipper](https://github.com/tiknil/skipper) is a tool for managing multiple local Laravel docker-compose deployment. | ||
|
||
It is strongly opinionated towards the patterns used by [Tiknil](https://www.tiknil.com) while building a laravel | ||
application. | ||
|
||
- [Install & Update](#installation) | ||
- [Usage](#usage) | ||
- [Architecture](#architecture) | ||
- [Mailpit for local emails](#mailpit) | ||
- [Docker compose commands](#docker-compose-commands) | ||
- [Project fields](#project) | ||
|
||
### Installation | ||
|
||
``` | ||
composer global require tiknil/skipper | ||
``` | ||
|
||
Make sure that the composer binaries directory is in your `$PATH` | ||
|
||
You can update Skipper to the latest version by running | ||
|
||
``` | ||
composer global update tiknil/skipper | ||
``` | ||
|
||
### Usage | ||
|
||
Register the current path as a skipper project: | ||
|
||
```bash | ||
# No options, sane defaults will be used and you will be asked to confirm the main fields | ||
skipper init | ||
|
||
# All fields can also be set via command line options | ||
skipper init --host=[host] --name=[name] \ | ||
--compose-file=docker/docker-compose.yml \ | ||
--env-file=docker/.env \ | ||
--http-container=nginx | ||
--php-container=php-fpm | ||
``` | ||
|
||
You will be asked to automatically install the default | ||
[laravel docker compose](https://github.com/tiknil/laravel-docker-compose) files. | ||
|
||
See [Project](#project) for details about each field. | ||
|
||
---- | ||
Start the project containers | ||
|
||
```bash | ||
skipper sail | ||
``` | ||
|
||
---- | ||
|
||
Stops the project containers | ||
|
||
```bash | ||
skipper dock | ||
``` | ||
|
||
---- | ||
|
||
Install caddy root certificate | ||
|
||
```bash | ||
skipper proxy:certs | ||
``` | ||
|
||
---- | ||
Once a project is running, skipper provides some useful commands to directly interact with it. | ||
|
||
```bash | ||
skipper bash # Start a new bash shell inside the PHP container | ||
skipper composer [command...] # Run a composer command (use instead of composer [command] | ||
skipper artisan [command...] # Run an artisan command (use instead of php artisan [command] | ||
skipper tinker # Start a new Laravel Tinker shell | ||
skipper backup # Create a new MySQL backup | ||
skipper restore --file [file] # Restore a MySQL backup | ||
``` | ||
|
||
Run `skipper` without arguments for a complete list of available commands | ||
|
||
### Architecture | ||
|
||
Skipper runs a [Caddy](https://caddyserver.com/) container, running as reverse proxy and forwarding | ||
requests to the corresponding project instance. Caddy is also able to generate HTTPS certificates for local domains, | ||
enabling a local environment very similar to a production deployment. | ||
|
||
Skipper install its files inside the `~/.skipper` directory. | ||
|
||
### Mailpit | ||
|
||
Skipper also runs a [Mailpit](https://github.com/axllent/mailpit) container by default. You can see the web | ||
dashboard at [localhost:8025](http://localhost:8025) | ||
|
||
Laravel should use the host `host.docker.internal` and port `1025` with driver SMTP: | ||
|
||
``` | ||
MAIL_MAILER=smtp | ||
MAIL_HOST=host.docker.internal | ||
MAIL_PORT=1025 | ||
``` | ||
|
||
This avoids running a separate mailpit/mailhog instance for each project. | ||
|
||
### Docker compose commands | ||
|
||
You may need to run custom docker compose command for a project, e.g. `ps` to see running containers. | ||
|
||
You can use the `compose` command: | ||
|
||
``` | ||
skipper compose [command] | ||
``` | ||
|
||
Basically, replace each `docker-compose [command]` with `skipper compose [command]`. | ||
This is *required* because skipper attaches some options to the docker-compose command that are required, such as the | ||
name or the env file path. | ||
|
||
### Project | ||
|
||
For the reverse proxy to work, skipper need to know about a project and update the caddy configuration file. | ||
A new project is registered using the `init` command. | ||
|
||
> All available projects are registered inside the `~/.skipper/config.yaml` configuration file. | ||
- **name**: The project name is used as the docker compose prefix for each container, volume or network related to the | ||
project. As a consequence, it must be unique and an update can result in data loss (new docker volumes will be used). | ||
- **host**: The domain to register in the reverse proxy | ||
- **path**: The path to the project root | ||
- **composeFile**: relative path to the docker-compose file. | ||
- **envFile**: relative path to the .env file for the docker-compose file | ||
- **httpContainer**: name of the http container, where caddy should forward the requests | ||
- **phpContainer**: name of the php container, where the utility commands should be run. | ||
|
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,6 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
include $_composer_autoload_path ?? __DIR__.'/../vendor/autoload.php'; | ||
|
||
include __DIR__.'/../src/index.php'; |
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,38 @@ | ||
{ | ||
"name": "tiknil/skipper", | ||
"description": "CLI application to manage multiple instances of local web applications", | ||
"keywords": [ "laravel", "docker", "cli" ], | ||
"type": "library", | ||
"license": "MIT", | ||
"version": "0.1.0", | ||
"bin": [ | ||
"bin/skipper" | ||
], | ||
"authors": [ | ||
{ | ||
"name": "Giorgio Balduzzi", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"ext-posix": "*", | ||
"php": "^8.0", | ||
"symfony/console": "^6.2", | ||
"symfony/process": "^6.2", | ||
"symfony/yaml": "^6.2" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Tiknil\\Skipper\\": "src/" | ||
}, | ||
"files": ["src/Helpers.php"] | ||
}, | ||
"config": { | ||
"sort-packages": true | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"require-dev": { | ||
"laravel/pint": "^1.10" | ||
} | ||
} |
Oops, something went wrong.