Skip to content

Issue 82 response envelope#89

Merged
Kinin-Code-Offical merged 2 commits intomainfrom
issue-82-response-envelope
Dec 22, 2025
Merged

Issue 82 response envelope#89
Kinin-Code-Offical merged 2 commits intomainfrom
issue-82-response-envelope

Conversation

@Kinin-Code-Offical
Copy link
Owner

@Kinin-Code-Offical Kinin-Code-Offical commented Dec 22, 2025

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
  • Test B

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Summary by Sourcery

Introduce a Docker-based local development environment for the PHP/MySQL backend and document its usage.

New Features:

  • Add a Docker Compose setup for PHP and MySQL services to run the backend locally.
  • Provide a sample environment configuration file for local development settings.

Build:

  • Add Dockerfile for the PHP/Apache container used in local development.

Documentation:

  • Update README to describe the recommended Docker-based local development workflow and adjust the manual setup section accordingly.

Fixes #41

Introduces a local development environment using Docker Compose.

- Adds a docker-compose.yml with db (MySQL 8) and php (PHP 8.1-Apache) services.
- Adds a Dockerfile for the PHP service to install the mysqli extension.
- Creates an .env.example file to document necessary environment variables.
- Updates README.md with instructions for setting up and running the project via Docker.
Copilot AI review requested due to automatic review settings December 22, 2025 07:36
@sourcery-ai
Copy link

sourcery-ai bot commented Dec 22, 2025

Reviewer's Guide

Adds a Docker-based local development environment for the PHP/MySQL backend and documents how to use it, including environment variable scaffolding and minor workflow metadata cleanup.

Flow diagram for Docker-based backend setup and initialization

flowchart TD
  dev[Developer] --> step_env[Copy_.env.example_to_.env]
  step_env --> step_edit[Edit_env_values_if_needed]
  step_edit --> step_up[Run_docker_compose_up_d_build]
  step_up --> step_running[php_and_mysql_containers_running]

  step_running --> step_composer[Run_docker_compose_exec_php_composer_install]
  step_composer --> step_migrate[Run_docker_compose_exec_php_vendor_bin_phinx_migrate]
  step_migrate --> step_seed[Run_docker_compose_exec_php_vendor_bin_phinx_seed_run_UserSeeder]
  step_seed --> step_ready[Backend_API_available_at_http_localhost]
Loading

File-Level Changes

Change Details Files
Introduce Docker-based local development stack for PHP backend and MySQL database.
  • Add docker-compose configuration defining MySQL (db) and PHP (apache) services with networked environment variables and volume mounts.
  • Wire database and application secrets into the PHP container via environment variables for DB and JWT configuration.
  • Persist MySQL data across container restarts using a named volume.
docker-compose.yml
Provide PHP Apache Docker image configuration for running the backend API inside a container.
  • Create a PHP 8.1 Apache-based Dockerfile under docker/php for the backend runtime.
  • Install and enable mysqli extension required for MySQL connectivity.
  • Install git, zip, and unzip to support composer and VCS-based dependencies inside the container.
docker/php/Dockerfile
Document Docker-based setup as the primary local development method.
  • Replace the original backend setup section with a new recommended Docker-based local development section, including env file creation, container startup, dependency installation, and database migration/seed commands.
  • Move the existing non-Docker backend setup under a new manual local development section.
README.md
Add example environment configuration for Docker-based setup.
  • Introduce an .env.example file containing placeholder values for database credentials, PHP password, and JWT secret key for local use.
.env.example
Minor cleanup in GitHub Actions release workflow metadata.
  • Normalize or adjust the workflow name line in the release workflow configuration.
.github/workflows/release.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@Kinin-Code-Offical Kinin-Code-Offical merged commit 353c51c into main Dec 22, 2025
8 of 10 checks passed
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 2 issues, and left some high level feedback:

  • The docker-compose.yml uses DB_HOST/DB_NAME/DB_USER/DB_PASS for the PHP service and MYSQL_* variables for the DB service, but there’s no visible mapping or defaults; consider aligning these names and adding corresponding entries in .env.example (e.g. DB_HOST=db) so the containers can connect reliably out of the box.
  • The README instructs running docker-compose exec php composer install, but the php:8.1-apache image doesn’t include Composer; you likely need to install Composer in the Dockerfile or adjust the docs to use a different image/installation method.
  • The change in .github/workflows/release.yml appears to add a BOM/hidden character before name: Create Release (note the ); it’s better to remove this to avoid subtle tooling or parsing issues.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `docker-compose.yml` uses `DB_HOST/DB_NAME/DB_USER/DB_PASS` for the PHP service and `MYSQL_*` variables for the DB service, but there’s no visible mapping or defaults; consider aligning these names and adding corresponding entries in `.env.example` (e.g. `DB_HOST=db`) so the containers can connect reliably out of the box.
- The README instructs running `docker-compose exec php composer install`, but the `php:8.1-apache` image doesn’t include Composer; you likely need to install Composer in the Dockerfile or adjust the docs to use a different image/installation method.
- The change in `.github/workflows/release.yml` appears to add a BOM/hidden character before `name: Create Release` (note the ``); it’s better to remove this to avoid subtle tooling or parsing issues.

## Individual Comments

### Comment 1
<location> `.github/workflows/release.yml:1` </location>
<code_context>
-name: Create Release
+name: Create Release

 on:
</code_context>

<issue_to_address>
**issue (bug_risk):** Remove the BOM character before `name` to avoid potential YAML/parsing issues in the workflow file.

There’s a leading BOM/invisible character before `name` (`+name: ...`). Some parsers and tools can mis-handle this and it also leads to noisy diffs. Please remove the BOM so the line is just `name: Create Release`.
</issue_to_address>

### Comment 2
<location> `docker/php/Dockerfile:8` </location>
<code_context>
+RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
+
+# Optional: Install git for composer dependencies from VCS
+RUN apt-get update && apt-get install -y git zip unzip
</code_context>

<issue_to_address>
**suggestion (performance):** Clean up apt artifacts and consider `--no-install-recommends` to keep the image smaller and more secure.

The current `apt-get` command keeps package lists and installs all recommended packages. To shrink the image and reduce the attack surface, you can use:

```dockerfile
RUN apt-get update \
    && apt-get install -y --no-install-recommends git zip unzip \
    && rm -rf /var/lib/apt/lists/*
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@@ -1,4 +1,4 @@
name: Create Release
name: Create Release
Copy link

Choose a reason for hiding this comment

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

issue (bug_risk): Remove the BOM character before name to avoid potential YAML/parsing issues in the workflow file.

There’s a leading BOM/invisible character before name (+name: ...). Some parsers and tools can mis-handle this and it also leads to noisy diffs. Please remove the BOM so the line is just name: Create Release.

RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli

# Optional: Install git for composer dependencies from VCS
RUN apt-get update && apt-get install -y git zip unzip
Copy link

Choose a reason for hiding this comment

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

suggestion (performance): Clean up apt artifacts and consider --no-install-recommends to keep the image smaller and more secure.

The current apt-get command keeps package lists and installs all recommended packages. To shrink the image and reduce the attack surface, you can use:

RUN apt-get update \
    && apt-get install -y --no-install-recommends git zip unzip \
    && rm -rf /var/lib/apt/lists/*

Copy link

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

This PR adds Docker support to the project to streamline local development by providing a containerized environment for PHP and MySQL services. The change addresses issue 82 (response envelope) by improving the development setup infrastructure.

  • Adds Docker Compose configuration with PHP and MySQL services
  • Provides environment variable templates for local development
  • Updates documentation with Docker-based setup instructions

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
docker/php/Dockerfile Defines PHP 8.1 Apache container with mysqli extension and development tools
docker-compose.yml Configures MySQL 8.0 and PHP services with environment variables and volume mappings
.env.example Provides template for local development environment variables including database and JWT configuration
README.md Adds comprehensive Docker setup instructions as the recommended development method
.github/workflows/release.yml Unintended BOM character added to the file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +11 to +13
DB_NAME=${MYSQL_DATABASE}
DB_USER=${MYSQL_USER}
DB_PASS=${MYSQL_PASSWORD}
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

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

The variables DB_USER and DB_PASS reference ${MYSQL_USER} and ${MYSQL_PASSWORD} respectively, which will not be expanded within the .env file itself. Environment variable substitution like this is not standard .env behavior and will likely be interpreted as literal strings rather than the actual values. Either use the literal values directly ("user" and "password"), or ensure your environment loading mechanism supports this substitution pattern.

Suggested change
DB_NAME=${MYSQL_DATABASE}
DB_USER=${MYSQL_USER}
DB_PASS=${MYSQL_PASSWORD}
DB_NAME=sigortacudb
DB_USER=user
DB_PASS=password

Copilot uses AI. Check for mistakes.
Comment on lines +15 to +19
# This is used by the legacy phpPassword check, which should be deprecated
PHP_PASSWORD=your_password

# This is used for signing JWTs
JWT_SECRET_KEY=your-super-secret-and-long-jwt-key
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

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

The default values "your_password" and "your-super-secret-and-long-jwt-key" are insecure placeholders that could be accidentally used in production or committed by developers. Consider using randomly generated default values or adding prominent warnings in comments that these MUST be changed before use.

Suggested change
# This is used by the legacy phpPassword check, which should be deprecated
PHP_PASSWORD=your_password
# This is used for signing JWTs
JWT_SECRET_KEY=your-super-secret-and-long-jwt-key
# This is used by the legacy phpPassword check, which should be deprecated.
# WARNING: This value MUST be changed before use in any non-local or production environment.
PHP_PASSWORD=CHANGE_THIS_PHP_PASSWORD_BEFORE_PRODUCTION
# This is used for signing JWTs.
# WARNING: This secret key MUST be changed before use in any non-local or production environment.
# Example of a strong random key (64 hex chars); generate your own:
JWT_SECRET_KEY=8c13f3b9e2a64c5fa8d6d4f1c9b0e7ad4f2e6c7b1a3d9f0c5b8e2d4a7c1f3e9

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +2
version: '3.8'

Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

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

The Docker Compose version '3.8' is outdated. Current Docker Compose specification recommends omitting the version field entirely for new projects, as it's no longer required and the latest Compose specification is used by default.

Suggested change
version: '3.8'

Copilot uses AI. Check for mistakes.
Comment on lines +13 to +14
ports:
- "3306:3306"
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

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

Exposing MySQL port 3306 to the host is unnecessary for typical development workflows where the PHP container connects internally, and creates a potential security risk. Unless external database access is specifically required for debugging, consider removing this port mapping to follow the principle of least exposure.

Suggested change
ports:
- "3306:3306"

Copilot uses AI. Check for mistakes.
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli

# Optional: Install git for composer dependencies from VCS
RUN apt-get update && apt-get install -y git zip unzip
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

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

The Dockerfile installs system packages (git, zip, unzip) but doesn't clean up apt cache afterward, which increases the image size unnecessarily. Add '&& rm -rf /var/lib/apt/lists/*' to the end of the RUN command to reduce the final image size.

Suggested change
RUN apt-get update && apt-get install -y git zip unzip
RUN apt-get update && apt-get install -y git zip unzip && rm -rf /var/lib/apt/lists/*

Copilot uses AI. Check for mistakes.
@@ -1,4 +1,4 @@
name: Create Release
name: Create Release
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

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

A UTF-8 BOM (Byte Order Mark) character has been added at the beginning of the file. This is typically unnecessary for UTF-8 files and can cause issues with some tools and parsers. The BOM should be removed to maintain clean UTF-8 encoding without BOM.

Suggested change
name: Create Release
name: Create Release

Copilot uses AI. Check for mistakes.

# Backend Settings (for Phinx and PHP)
DB_HOST=db
DB_NAME=${MYSQL_DATABASE}
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

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

The variable DB_NAME references ${MYSQL_DATABASE} which will not be expanded within the .env file itself. Environment variable substitution like this is not standard .env behavior and will likely be interpreted as the literal string "${MYSQL_DATABASE}" rather than the value "sigortacudb". Either use the literal value "sigortacudb" directly, or ensure your environment loading mechanism supports this substitution pattern.

Suggested change
DB_NAME=${MYSQL_DATABASE}
DB_NAME=sigortacudb

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.

2 participants