hoangstark/vessel

支持 Traefik 代理的简单 Docker 开发环境

维护者

详细信息

github.com/hoangstark/vessel

源代码

安装: 13

依赖项: 0

建议者: 0

安全: 0

星星: 0

关注者: 2

分支: 105

语言:Shell

v5.0.0 2019-04-22 05:14 UTC

README

使用小型 Docker 开发环境启动和运行。

文档

完整文档可以在 https://vessel.shippingdocker.com 找到。

安装后

分别启动 traefik 和 mariadb

安装

Vessel 只是一组用于在每个项目中设置本地 Docker 基础开发环境的文件。除了 Docker 本身之外,无需全局安装任何东西!

这就是使用它的全部内容

composer require shipping-docker/vessel
php artisan vendor:publish --provider="Vessel\VesselServiceProvider"

# Run this once to initialize project
# Must run with "bash" until initialized
bash vessel init

./vessel start

在浏览器中转到 https:// 并查看您的 Laravel 网站!

Lumen

如果您正在使用 Lumen,则需要手动复制 Vessel 文件,而不是使用 php artisan vendor:publish。您可以使用以下命令完成此操作

cp -R vendor/shipping-docker/vessel/docker-files/{vessel,docker-compose.yml,docker} .

然后您就可以正常安装并继续使用了。

多个环境

Vessel 尝试在您的计算机上绑定端口 80 和 3306,因此您只需在浏览器中转到 https:// 即可。

但是,如果您运行了多个 Vessel 实例,则在启动时会遇到错误;每个端口只能使用一次。要解决这个问题,您可以通过设置 APP_PORTMYSQL_PORT 环境变量以两种方式之一为每个项目使用不同的端口

.env 文件中

APP_PORT=8080
MYSQL_PORT=33060

或者在启动 Vessel 时

APP_PORT=8080 MYSQL_PORT=33060 ./vessel start

然后您可以在 https://:8080 中查看您的项目,并从端口 33060 本地访问您的数据库;

Sequel Pro

由于我们已将 MySQL 绑定到端口 3306,因此 SequelPro 可以直接访问数据库。

sequel pro access

用户 root 的密码由 .env 文件中的环境变量 DB_PASSWORD 设置。

端口号设置必须与 MYSQL_PORT 环境变量匹配,该变量的默认值为 3306

常用命令

以下是可以使用的内置助手列表。任何未在 vessel 脚本中定义的命令都将默认传递给 docker-compose 命令。如果没有使用命令,它将运行 docker-compose ps 以列出此环境的运行容器。

显示 Vessel 版本或帮助

# shows vessel current version
$ vessel --version # or [ -v | version ]

# shows vessel help
$ vessel --help # or [ -H | help ]

启动和停止 Vessel

# Start the environment
./vessel start

## This is equivalent to
./vessel up -d

# Stop the environment
./vessel stop

## This is equivalent to
./vessel down

开发

# Use composer
./vessel composer <cmd>
./vessel comp <cmd> # "comp" is a shortcut to "composer"

# Use artisan
./vessel artisan <cmd>
./vessel art <cmd> # "art" is a shortcut to "artisan"

# Run tinker REPL
./vessel tinker # "tinker" is a shortcut for "artisan tinker"

# Run phpunit tests
./vessel test

## Example: You can pass anything you would to phpunit to this as well
./vessel test --filter=some.phpunit.filter
./vessel test tests/Unit/SpecificTest.php


# Run npm
./vessel npm <cmd>

## Example: install deps
./vessel npm install

# Run yarn

./vessel yarn <cmd>

## Example: install deps
./vessel yarn install

# Run gulp
./vessel gulp <cmd>

Docker 命令

如前所述,任何未识别为内置命令的任何内容都将用作 docker-compose 命令的参数。这里有一些实用的技巧

# Both will list currently running containers and their status
./vessel
./vessel ps

# Check log output of a container service
./vessel logs # all container logs
./vessel logs app # nginx | php logs
./vessel logs mysql # mysql logs
./vessel logs redis # redis logs

## Tail the logs to see output as it's generated
./vessel logs -f # all logs
./vessel logs -f app # nginx | php logs

## Tail Laravel Logs
./vessel exec app tail -f /var/www/html/storage/logs/laravel.log

# Start a bash shell inside of a container
# This is just like SSH'ing into a server
# Note that changes to a container made this way will **NOT**
#   survive through stopping and starting the vessel environment
#   To install software or change server configuration, you'll need to
#     edit the Dockerfile and run: ./vessel build
./vessel exec app bash

# Example: mysqldump database "homestead" to local file system
#          We must add the password in the command line this way
#          This creates files "homestead.sql" on your local file system, not
#          inside of the container
# @link https://serversforhackers.com/c/mysql-in-dev-docker
./vessel exec mysql mysqldump -u root -psecret homestead > homestead.sql

包括哪些内容?

此项目的目标是简单性。它包括

它是如何工作的?

如果您对 Docker 不太熟悉,请尝试这个 Docker 开发 课程,该课程解释了构建此项目时的重要主题。

如果您想了解此工作流程是如何开发的,请查看 Shipping Docker 并注册免费课程模块,该模块解释了构建此 Docker 工作流程的方法。

支持的系统

Vessel 需要 Docker,并且目前仅支持 Windows、Mac 和 Linux。

Windows 需要运行 Hyper-V。支持使用 Git Bash (MINGW64) 和 WSL。原生 Windows 仍在开发中。