Skip to content

Commit b646d23

Browse files
authored
Merge pull request #10 from niden-code/T9-docker-compose
T9 docker compose
2 parents 382fce7 + fe1c921 commit b646d23

31 files changed

+1265
-20
lines changed

.github/workflows/main.yml

Lines changed: 131 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,142 @@
1+
2+
# This file is part of Phalcon.
3+
#
4+
# (c) Phalcon Team <[email protected]>
5+
#
6+
# For the full copyright and license information, please view
7+
# the LICENSE file that was distributed with this source code.
8+
19
name: REST API v6 CI
210
on:
311
push:
12+
paths-ignore:
13+
- '**.md'
14+
- '**.txt'
415
pull_request:
5-
types: [opened, synchronize, reopened]
16+
workflow_dispatch:
17+
18+
env:
19+
fail-fast: true
20+
21+
# PHP extensions required by Composer
22+
EXTENSIONS: json, mbstring, pdo, pdo_mysql
23+
24+
permissions: { }
625
jobs:
7-
sonarqube:
8-
name: SonarQube
9-
runs-on: ubuntu-latest
26+
27+
# PHP CodeSniffer inspection
28+
phpcs:
29+
name: "Quality gate"
30+
if: "!contains(github.event.head_commit.message, 'ci skip')"
31+
32+
permissions:
33+
contents: read
34+
35+
runs-on: ubuntu-22.04
36+
37+
strategy:
38+
fail-fast: true
39+
matrix:
40+
php:
41+
- '8.2'
42+
- '8.3'
43+
- '8.4'
1044
steps:
1145
- uses: actions/checkout@v4
46+
47+
- name: "Setup PHP"
48+
uses: shivammathur/[email protected]
1249
with:
13-
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
14-
- name: SonarQube Scan
50+
php-version: ${{ matrix.php }}
51+
extensions: ${{ env.EXTENSIONS }}
52+
tools: pecl
53+
env:
54+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
56+
- name: "Install development dependencies with Composer"
57+
uses: "ramsey/composer-install@v3"
58+
with:
59+
composer-options: "--prefer-dist"
60+
61+
- name: "PHPCS"
62+
run: |
63+
composer cs
64+
65+
# - name: "PHPStan"
66+
# run: |
67+
# composer analyze
68+
69+
unit-tests:
70+
needs: phpcs
71+
72+
permissions:
73+
contents: read # to fetch code (actions/checkout)
74+
75+
name: Unit tests / PHP-${{ matrix.php }}
76+
runs-on: ubuntu-22.04
77+
78+
strategy:
79+
matrix:
80+
php:
81+
- '8.2'
82+
- '8.3'
83+
- '8.4'
84+
85+
services:
86+
mariadb:
87+
image: mariadb:10.6
88+
ports:
89+
- "3306:3306"
90+
env:
91+
MYSQL_ROOT_PASSWORD: secret
92+
MYSQL_USER: phalcon
93+
MYSQL_DATABASE: phalcon
94+
MYSQL_PASSWORD: secret
95+
96+
steps:
97+
- uses: actions/checkout@v4
98+
99+
- name: "Setup PHP"
100+
uses: shivammathur/[email protected]
101+
with:
102+
php-version: ${{ matrix.php }}
103+
extensions: ${{ env.EXTENSIONS }}
104+
tools: pecl
105+
env:
106+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107+
108+
- name: "Install development dependencies with Composer"
109+
uses: "ramsey/composer-install@v3"
110+
with:
111+
composer-options: "--prefer-dist"
112+
113+
- name: "Setup Tests"
114+
shell: bash
115+
run: |
116+
cp config/.env.ci .env
117+
118+
- name: "Run Unit Tests"
119+
if: always()
120+
run: |
121+
composer test-unit
122+
123+
- name: "Run Migrations"
124+
if: always()
125+
run: |
126+
composer migrate
127+
128+
- name: SonarCloud Scan
15129
uses: SonarSource/sonarqube-scan-action@v5
16130
env:
131+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17132
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
133+
with:
134+
projectBaseDir: ./
135+
args: >
136+
-Dsonar.organization=${{ secrets.SONAR_ORGANIZATION }}
137+
-Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY }}
138+
-Dsonar.sources=src/
139+
-Dsonar.exclusions=vendor/**,cv/**,tests/**
140+
-Dsonar.sourceEncoding=UTF-8
141+
-Dsonar.language=php
142+
-Dsonar.tests=tests/

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
.bash_history
33
vendor
44
composer.lock
5+
.env

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# 1.0.0
2+
3+
Under development

CONTRIBUTING.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Contributing to Phalcon
2+
3+
Phalcon is an open source project and a volunteer effort. Phalcon welcomes contribution from everyone. Please take a moment to review this document in order to make the contribution process easy and effective for everyone involved.
4+
5+
Following these guidelines helps to communicate that you respect the time of the developers managing and developing this open source project. In return, they should reciprocate that respect in addressing your issue or assessing patches and features.
6+
7+
## Contributions
8+
9+
Contributions to Phalcon should be made in the form of GitHub pull requests. Each pull request will be reviewed by a core contributor (someone with permission to merge patches). Feedback can be provided and potentially changes requested or the pull request will be merged. All contributions should
10+
follow this format, even those from core contributors.
11+
12+
## Questions & Support
13+
14+
We use the GitHub issues for tracking bugs and feature requests and have limited bandwidth to address all of them. Thus we only accept bug reports, new feature requests and pull requests in GitHub. Our great community and contributors are happy to help you though! Please use these community resources for obtaining help.
15+
16+
_Please use the [Documentation](https://phalcon.io/docs) before anything else. You can also use the search feature in our documents to find what you are looking for. If your question is still not answered, there are more options below._
17+
18+
* Questions should go to [GitHub Discussions](https://phalcon.io/discussions)
19+
* Come join the Phalcon [Discord](https://phalcon.io/discord)
20+
* Our social network accounts are:
21+
* [Telegram](https://phalcon.io/telegram)
22+
* [Gab](https://phalcon.io/gab)
23+
* [MeWe](https://phalcon.io/mewe)
24+
* [Twitter](https://phalcon.io/t)
25+
* [Facebook](https://phalcon.io/fb)
26+
* If you still believe that what you found is a bug, please
27+
[open an issue](https://github.com/phalcon/cphalcon/issues/new)
28+
29+
Please report bugs when you've exhausted all of the above options.
30+
31+
## Bug Report Checklist
32+
33+
* Make sure you are using the latest released version of the composer packages.
34+
* If you have found a bug it is important to add relevant reproducibility information to your issue to allow us to reproduce the bug and fix it quicker. Add a script, small program or repository providing the necessary code to make everyone reproduce the issue reported easily.
35+
* Be sure that information such as OS, Phalcon version and PHP version are part of the bug report
36+
37+
## Pull Request Checklist
38+
39+
* Don't submit your pull requests to the `master` branch. Branch from the required branch and, if needed, rebase to the proper branch before submitting your pull request. If it doesn't merge cleanly with master you may be asked to rebase your changes
40+
* Don't put submodule updates in your pull request unless they are to landed commits
41+
* Add tests relevant to the fixed bug or new feature. Test classes should follow the [PSR-12 coding style guide](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-12-coding-style-guide.md).
42+
43+
## Requesting Features
44+
45+
If you have a change or new feature in mind, please fill out an NFR on GitHub.
46+
47+
48+
Thanks!
49+
Phalcon Team

bin/.gitkeep

Whitespace-only changes.

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"analyze": "phpstan analyse -c phpstan.neon --memory-limit=512M",
5858
"cs": "vendor/bin/phpcs --standard=phpcs.xml",
5959
"cs-fix": "vendor/bin/phpcbf --standard=phpcs.xml",
60+
"migrate": "vendor/bin/phinx migrate",
6061
"test-unit": "vendor/bin/phpunit -c phpunit.xml.dist --display-all-issues"
6162
}
6263
}

config/.env.ci

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
PROJECT_NAME="rest"
2+
3+
# Mariadb
4+
DB_HOST="127.0.0.1"
5+
DB_PORT=3306
6+
DB_USER="root"
7+
DB_PASS="secret"
8+
DB_NAME="phalcon"
9+
DB_CHARSET="utf8"
10+
11+
# Redis
12+
DATA_REDIS_HOST="app-cache"
13+
DATA_REDIS_PORT=6379
14+
DATA_REDIS_NAME="0"
15+
16+
XDEBUG_MODE=coverage

config/.env.example

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
PROJECT_NAME="rest"
2+
3+
# Mariadb
4+
DB_HOST="app-db"
5+
DB_PORT=3306
6+
DB_USER="root"
7+
DB_PASS="secret"
8+
DB_NAME="phalcon"
9+
DB_CHARSET= "utf8"
10+
11+
# Redis
12+
DATA_REDIS_HOST="app-cache"
13+
DATA_REDIS_PORT=6379
14+
DATA_REDIS_NAME="0"
15+
16+
XDEBUG_MODE=coverage

config/.gitkeep

Whitespace-only changes.

docker-compose.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
services:
2+
3+
app-8.2:
4+
build:
5+
dockerfile: ./resources/docker/Dockerfile
6+
args:
7+
PHP_VERSION: 8.2
8+
hostname: rest-api-app-8.2
9+
container_name: "${PROJECT_NAME}-api-8.2"
10+
tty: true
11+
working_dir: /app
12+
volumes:
13+
- ./:/app
14+
depends_on:
15+
- app-db
16+
- app-cache
17+
networks:
18+
- app-network
19+
environment:
20+
- APP_ENV=development
21+
- APP_ENV_ADAPTER=dotenv
22+
healthcheck:
23+
test: ["CMD", "curl", "-f", "http://localhost/fpm-ping"]
24+
interval: 30s
25+
timeout: 3s
26+
retries: 3
27+
start_period: 5s
28+
29+
app-8.3:
30+
build:
31+
dockerfile: ./resources/docker/Dockerfile
32+
args:
33+
PHP_VERSION: 8.3
34+
hostname: rest-api-app-8.3
35+
container_name: "${PROJECT_NAME}-api-8.3"
36+
tty: true
37+
working_dir: /app
38+
volumes:
39+
- ./:/app
40+
depends_on:
41+
- app-db
42+
- app-cache
43+
networks:
44+
- app-network
45+
environment:
46+
- APP_ENV=development
47+
- APP_ENV_ADAPTER=dotenv
48+
healthcheck:
49+
test: ["CMD", "curl", "-f", "http://localhost/fpm-ping"]
50+
interval: 30s
51+
timeout: 3s
52+
retries: 3
53+
start_period: 5s
54+
55+
app-8.4:
56+
build:
57+
dockerfile: ./resources/docker/Dockerfile
58+
args:
59+
PHP_VERSION: 8.4
60+
hostname: rest-api-app-8.4
61+
container_name: "${PROJECT_NAME}-api-8.4"
62+
tty: true
63+
working_dir: /app
64+
volumes:
65+
- ./:/app
66+
depends_on:
67+
- app-db
68+
- app-cache
69+
networks:
70+
- app-network
71+
environment:
72+
- APP_ENV=development
73+
- APP_ENV_ADAPTER=dotenv
74+
healthcheck:
75+
test: ["CMD", "curl", "-f", "http://localhost/fpm-ping"]
76+
interval: 30s
77+
timeout: 3s
78+
retries: 3
79+
start_period: 5s
80+
81+
app-db:
82+
container_name: "${PROJECT_NAME}-db"
83+
image: mariadb:10.6
84+
environment:
85+
- MYSQL_ROOT_PASSWORD=secret
86+
- MYSQL_USER=phalcon
87+
- MYSQL_DATABASE=phalcon
88+
- MYSQL_PASSWORD=secret
89+
networks:
90+
- app-network
91+
92+
app-cache:
93+
container_name: "${PROJECT_NAME}-cache"
94+
image: redis:5-alpine
95+
networks:
96+
- app-network
97+
98+
networks:
99+
app-network:
100+
driver: bridge

0 commit comments

Comments
 (0)