@45air/air-local-docker 中文文档教程

发布于 3年前 浏览 27 项目主页 更新于 3年前

Air Local Docker

码头上的 Docker 存储库

基于 Docker 的本地开发环境,适用于 Mac、Windows 和 Linux。 适合 WordPress 开发,但通常任何类型的网站都应该可以使用。 使用托管在 Docker Hub 上的公共 Docker 镜像和托管在 Quay 上的我们自己的公共 Docker 镜像来为您的站点设置开发环境。

可以通过运行 airlocal auth config 配置额外的附加组件和自动化,您可以在配置身份验证后使用 airlocal auth status 检查您的登录状态以确保它仍然有效。

Prerequisites

Installation

您可以通过私有 GitLab 包注册表安装已发布的版本。

步骤记录在下面链接的 GitLab 文档中。

https://docs.gitlab.com/ee/user/packages/npm_registry/index.html< /a>

直接链接到 Gitlab 上的包注册表。

https://devops.45air.co/tmbi/cli/air-local-docker/ -/packages

Setup

按照 TMBI 文档进行设置和安装。 使用橙色的 GitLab 登录按钮登录。

https://docs.tmbi.air-cloud.app/local-development

Command Documentation

Global Commands

Clearing Shared Cache

WP CLI,作曲家,和 npm 都利用缓存来加速操作并在未来节省带宽。

airlocal cache clear 清除 WP CLI、composer 和 npm 缓存。

Updating Docker Images

airlocal image update all 将确定 Air Local Docker 使用的哪些 docker 映像存在于您的系统上,并将它们更新到可用的最新版本。

Stopping global services

AirLocal 依靠一组全球服务来正常运行。 要关闭全局服务,请运行 airlocal stop all。 这将停止所有环境,然后停止全局服务。

Environments

Create an Environment

airlocal create 将向您显示一系列提示以配置您的环境以满足您的需要。

建议您为本地环境使用 .test 顶级域 (TLD),因为此 TLD 保留用于软件测试,并不打算安装到全球域名中系统。 此外,AirLocal 配置为将 .test TLD 的任何容器到容器的流量直接发送到网关容器,这样 WP Cron 和 REST API 之类的东西就可以在开箱即用的环境之间工作。

Delete an Environment

airlocal delete 将删除具有给定主机名的环境。 与环境相关的任何本地文件、docker 卷和数据库都将被永久删除。

一个特殊的主机名 all 可用,它将删除所有环境。 系统将要求您确认删除每个环境。

Stop an Environment

airlocal stop 将停止环境运行,同时保留与该环境相关的所有文件、docker 卷和数据库。

一个特殊的主机名 all 可用,它将停止所有正在运行的环境以及全局服务。

Start an Environment

airlocal start 将启动一个预先存在的环境。

一个特殊的主机名 all 可用,它将启动所有环境以及全局服务。

Restart an Environment

airlocal restart 将重新启动与预先存在的环境关联的所有服务。

一个特殊的主机名 all 可用,它将重新启动所有环境以及全局服务。

Running WP CLI Commands

针对环境运行 WP CLI 命令很容易。 首先,确保您在环境目录中的某个位置(默认情况下,这是在 ~/air-local-docker-sites// 中的某个位置)。 一旦进入环境目录,只需运行 airlocal wp 可以是您将直接传递给 WP CLI 的任何有效命令。

示例:

  • airlocal wp search-replace mysite.com mysite.test
  • airlocal wp site list

Shell

您可以使用 airlocal shell [] 命令在您环境中的任何容器中获取一个 shell。 如果未提供服务,则默认使用 phpfpm 容器。 其他可用服务可能会根据在创建环境期间选择的选项而有所不同,但可能包括:

  • phpfpm
  • nginx
  • redis

Logs

使用 airlocal logs [] 命令可以获得实时容器日志。 如果未提供服务,则会显示当前环境中所有容器的日志。 要停止日志,请键入 ctrl+c。 可用服务可能因环境创建期间选择的选项而异,但可能包括:

  • phpfpm
  • nginx
  • redis

Tools

phpMyAdmin

phpMyAdmin 作为全球服务堆栈的一部分提供部署以支持所有环境。

通过导航到 http://localhost:8092 访问 phpMyAdmin。

  • Username: root
  • Password: password

MailCatcher

MailCatcher 作为全球服务堆栈的一部分提供,该堆栈已部署以支持所有环境。 它预先配置为捕获从 Air Local Docker 创建的任何环境发送的邮件。

通过导航到 http://localhost:1080 访问 MailCatcher。

Xdebug

Xdebug 包含在 php 映像中,几乎可以开箱即用。 确保您的 IDE 正在侦听 PHP 调试连接,并设置路径映射到本地环境的 web/wp-content/ 目录到 /var/www/web/wp-content/< /代码> 在容器中。

Visual Studio Code
  1. Install the PHP Debug extension.
  2. In your project, go to the Debug view, click "Add Configuration…" and choose PHP environment. A new launch configuration will be created for you.
  3. Set the pathMappings parameter to your local web/wp-content/ directory. Example:
"configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000,
            "pathMappings": {
                "/var/www/web/wp-content": "${workspaceFolder}/web/wp-content",
            }
        }
]

Attribution

https://github.com/10up/wp-local-docker-v2

Air Local Docker

Docker Repository on Quay

Docker based local development environment that works on Mac, Windows, and Linux. Geared to WordPress development but generally any type of site should work. Uses public Docker images hosted on Docker Hub and our own public Docker images hosted on Quay for setting up the development enviroment for your sites.

Extra add ons and automation which can be configured by running airlocal auth config, you can check your logged in status with airlocal auth status as well after configuring your authentication to make sure it is still valid.

Prerequisites

Installation

You can install released versions through the private GitLab Package Registry.

Steps are documented in the GitLab docs linked below.

https://docs.gitlab.com/ee/user/packages/npm_registry/index.html

Direct link to the package registry on Gitlab.

https://devops.45air.co/tmbi/cli/air-local-docker/-/packages

Setup

Follow the TMBI docs for setup and install. Log in using the orange GitLab login button.

https://docs.tmbi.air-cloud.app/local-development

Command Documentation

Global Commands

Clearing Shared Cache

WP CLI, Composer, and npm all utilize cache to speed up operations and save on bandwidth in the future.

airlocal cache clear Clears the WP CLI, composer, and npm caches.

Updating Docker Images

airlocal image update all Will determine which of the docker images utilized by Air Local Docker are present on your system and update them to the latest version available.

Stopping global services

AirLocal relies on a set of global services to function properly. To turn off global services, run airlocal stop all. This will stop all environments and then the global services.

Environments

Create an Environment

airlocal create will present you with a series of prompts to configure your environment to suit your needs.

It is recommended that you use the .test top level domain (TLD) for your local environments, as this TLD is reserved for the testing of software and is not intended to ever be installed into the global Domain Name System. Additionally, AirLocal is configured to send any container to container traffic for .test TLDs directly to the gateway container, so that things like WP Cron and the REST API can work between environments out of the box.

Delete an Environment

airlocal delete <hostname> will delete an environment with the given hostname. Any local files, docker volumes, and databases related to the environment will be deleted permanently.

A special hostname all is available that will delete all environments. You will be asked to confirm deletion of each environment.

Stop an Environment

airlocal stop <hostname> will stop an environment from running while retaining all files, docker volumes, and databases related to the environment.

A special hostname all is available that will stop all running environments as well as the global services.

Start an Environment

airlocal start <hostname> will start a preexisting environment.

A special hostname all is available that will start all environments as well as the global services.

Restart an Environment

airlocal restart <hostname> will restart all services associated with a preexisting environment.

A special hostname all is available that will restart all environments as well as the global services.

Running WP CLI Commands

Running WP CLI commands against an environment is easy. First, make sure you are somewhere within your environment directory (by default, this is somewhere within ~/air-local-docker-sites/<environment>/). Once within the environment directory, simply run airlocal wp <command>. <command> can be any valid command you would otherwise pass directly to WP CLI.

Examples:

  • airlocal wp search-replace mysite.com mysite.test
  • airlocal wp site list

Shell

You can get a shell inside of any container in your environment using the airlocal shell [<service>] command. If a service is not provided, the phpfpm container will be used by default. Other available services can vary depending on the options selected during creation of the environment, but may include:

  • phpfpm
  • nginx
  • redis

Logs

Real time container logs are available using the airlocal logs [<service>] command. If a service is not provided, logs from all containers in the current environment will be shown. To stop logs, type ctrl+c. Available services can vary depending on the options selected during creation of the environment, but may include:

  • phpfpm
  • nginx
  • redis

Tools

phpMyAdmin

phpMyAdmin is available as part of the global services stack that is deployed to support all of the environments.

Access phpMyAdmin by navigating to http://localhost:8092.

  • Username: root
  • Password: password

MailCatcher

MailCatcher is available as part of the global services stack that is deployed to support all of the environments. It is preconfigured to catch mail sent from any of the environments created by Air Local Docker.

Access MailCatcher by navigating to http://localhost:1080.

Xdebug

Xdebug is included in the php images and is nearly ready to go out of the box. Make sure your IDE is listening for PHP debug connections and set up a path mapping to your local environment's web/wp-content/ directory to /var/www/web/wp-content/ in the container.

Visual Studio Code
  1. Install the PHP Debug extension.
  2. In your project, go to the Debug view, click "Add Configuration…" and choose PHP environment. A new launch configuration will be created for you.
  3. Set the pathMappings parameter to your local web/wp-content/ directory. Example:
"configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000,
            "pathMappings": {
                "/var/www/web/wp-content": "${workspaceFolder}/web/wp-content",
            }
        }
]

Attribution

https://github.com/10up/wp-local-docker-v2

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文