Skip to content

Add Docker setup guide for application templates#394

Merged
samdark merged 6 commits intomasterfrom
copilot/create-docker-setup-guide
Apr 7, 2026
Merged

Add Docker setup guide for application templates#394
samdark merged 6 commits intomasterfrom
copilot/create-docker-setup-guide

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 18, 2026

  • Create src/guide/tutorial/docker.md - the Docker guide page covering all 5 required topics
  • Update src/.vitepress/config.js to add the page to the Tutorial sidebar section
  • Update src/guide/index.md to add a link in the Special topics section
  • Update src/guide/tutorial/docker.md to document the new root .env.example for non-Docker development and the Docker env priority (yiisoft/app@a75636d)
  • Update src/guide/start/creating-project.md to use the new .env.example.env workflow, correct URL/port note, and name the .env.example file explicitly in prose
Original prompt

This section details on the original issue you should resolve

<issue_title>Create a guide page about Docker setup in application templates</issue_title>
<issue_description>### Description

Create a user guide for Docker in https://github.com/yiisoft/app and https://github.com/yiisoft/app-api

Things to note especially:

  1. make commands usage.
  2. Contents of /docker overview.
  3. Each .env purpose and examples.
  4. compose.yml.
  5. The idea of multi-stage builds.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Co-authored-by: samdark <47294+samdark@users.noreply.github.com>
Copilot AI changed the title [WIP] Add guide page about Docker setup in application templates Add Docker setup guide for application templates Mar 18, 2026
Copilot AI requested a review from samdark March 18, 2026 21:21
@samdark
Copy link
Copy Markdown
Member

samdark commented Apr 6, 2026

@copilot update it considering yiisoft/app@a75636d

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 6, 2026

@copilot update it considering yiisoft/app@a75636d

Done in 811b9cd. The guide now documents the new root-level .env.example / .env mechanism introduced by that commit:

  • docker.md — Added a new ".env.example (project root)" subsection explaining it's for non-Docker local development, how src/bootstrap.php loads it via phpdotenv only when APP_ENV isn't already set in the process environment, and that Docker env vars always take precedence so both workflows coexist safely. Also notes phpdotenv is a dev dependency absent from production containers.
  • creating-project.md — Updated the non-Docker run instructions to use cp .env.example .env && ./yii serve instead of the old APP_ENV=dev ./yii serve --port=80 prefix, and fixed the URL/port note to distinguish between the built-in server (:8080) and Docker (:80).

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 10e278b1-e9ae-4e6e-95a4-e91136d15e41

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch copilot/create-docker-setup-guide

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI requested a review from samdark April 7, 2026 16:34
@samdark samdark marked this pull request as ready for review April 7, 2026 16:34
Copilot AI review requested due to automatic review settings April 7, 2026 16:34
@samdark samdark merged commit 4869996 into master Apr 7, 2026
5 of 6 checks passed
@samdark samdark deleted the copilot/create-docker-setup-guide branch April 7, 2026 16:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new tutorial page documenting the Docker setup used by Yii application templates, and wires it into the guide navigation while updating the project creation workflow to reference .env.example.

Changes:

  • Added a new Docker tutorial page covering directory layout, env files, Compose setup, multi-stage builds, and make targets.
  • Added navigation entries for the new page (Guide index + VitePress sidebar).
  • Updated “Creating a project” to reference the .env.example.env workflow and clarified port configuration notes.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/guide/tutorial/docker.md New Docker setup guide for yiisoft/app and yiisoft/app-api, including env/compose/multi-stage build and make command docs.
src/guide/start/creating-project.md Updates local setup instructions to mention .env.example and improves the port-change note.
src/guide/index.md Adds a “Docker in application templates” link under Special topics.
src/.vitepress/config.js Adds the Docker guide page to the Tutorial sidebar section.
Comments suppressed due to low confidence (1)

src/guide/start/creating-project.md:48

  • The instructions say to copy .env.example to .env, but the following shell snippet only shows ./yii serve. Add the cp .env.example .env step to the code block (or adjust the prose) so readers can follow the workflow without guessing.
Go into the newly created directory, copy `.env.example` to `.env`, and run:

```sh
./yii serve --port=80
</details>


FROM base AS prod-builder
COPY --from=composer /composer /usr/bin/composer
COPY .. /app
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the documented Dockerfile snippet, COPY .. /app will fail when the build context is the project root (as shown in the Compose example with context: ..) because Docker cannot copy files from outside the build context. Update the snippet to copy from within the build context (for example, COPY . /app) or adjust the documented build context accordingly.

Suggested change
COPY .. /app
COPY . /app

Copilot uses AI. Check for mistakes.
Comment on lines +365 to +373
The Dockerfile defines four stages:

| Stage | Purpose |
|----------------|--------------------------------------------------------------------------------------------------|
| `composer` | Copies the Composer binary from the official image to avoid installing it in other stages. |
| `base` | Installs FrankenPHP, common PHP extensions, and system packages shared by all environments. |
| `dev` | Extends `base` with Xdebug and Composer. Creates a non-root user matching the host user's UID/GID to prevent permission issues with mounted volumes. |
| `prod-builder` | Extends `base`, copies the application source, and runs `composer install --no-dev` using a build cache. Removes `composer.lock` and `composer.json` afterwards to keep the final image clean. |
| `prod` | Copies only the built application from `prod-builder` into a clean `base` image. This produces a small final image because the Composer binary and intermediate files are not included. |
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence says the Dockerfile defines four stages, but the table lists five (composer, base, dev, prod-builder, prod). Update the count (or clarify that composer is a helper stage) to avoid confusion.

Copilot uses AI. Check for mistakes.
```

Instead of building an image, the production file references a pre-built image (`${IMAGE}:${IMAGE_TAG}`).
The `deploy` block configures Docker Swarm behaviour: two replicas with a rolling `start-first` update
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling inconsistency: the docs elsewhere use American English "behavior"; this line uses "behaviour". Consider changing to "behavior" to keep wording consistent (and to avoid potential Vale style failures).

Suggested change
The `deploy` block configures Docker Swarm behaviour: two replicas with a rolling `start-first` update
The `deploy` block configures Docker Swarm behavior: two replicas with a rolling `start-first` update

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a guide page about Docker setup in application templates

3 participants