Skip to content

Commit 0047e96

Browse files
committed
feat: add Docker support (FrankenPHP) and Swagger UI support
1 parent ab50ca8 commit 0047e96

7 files changed

Lines changed: 197 additions & 0 deletions

File tree

.dockerignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.git
2+
.github
3+
.idea
4+
vendor
5+
tests
6+
_output
7+
.php-cs-fixer.cache
8+
.phpunit.result.cache
9+
Dockerfile
10+
compose.yml
11+
.env
12+
*.md

.releaserc

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"tagFormat": "${version}",
3+
"branches": ["main"],
4+
"plugins": [
5+
[
6+
"@semantic-release/commit-analyzer", {
7+
"preset": "conventionalcommits",
8+
}
9+
],
10+
[
11+
"@semantic-release/release-notes-generator", {
12+
"preset": "conventionalcommits",
13+
}
14+
],
15+
[
16+
"@semantic-release/github",
17+
{
18+
"labels": "semantic-release,bot"
19+
}
20+
],
21+
[
22+
"@semantic-release/changelog",
23+
{
24+
"changelogTitle": "# Changelog\n\nAll notable changes to this project will be documented in this file. See\n[Conventional Commits](https://conventionalcommits.org) for commit guidelines."
25+
}
26+
],
27+
[
28+
"@semantic-release/git",
29+
{
30+
"message": "chore(release): version ${nextRelease.version} \n\n${nextRelease.notes}"
31+
}
32+
]
33+
]
34+
}

Dockerfile

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Stage 1: Install dependencies
2+
FROM composer:2 AS composer_build
3+
4+
WORKDIR /app
5+
6+
# Copy only composer files first to leverage Docker cache
7+
COPY composer.json ./
8+
9+
# Install production dependencies
10+
# We ignore platform reqs here because we know they are met in the final image
11+
RUN composer install \
12+
--no-dev \
13+
--optimize-autoloader \
14+
--no-interaction \
15+
--no-progress \
16+
--no-scripts \
17+
--ignore-platform-reqs
18+
19+
# Stage 2: Final image
20+
FROM dunglas/frankenphp:latest
21+
22+
# Disable HTTPS by default for the container
23+
ENV SERVER_NAME=:80
24+
25+
# Enable production PHP settings
26+
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
27+
28+
# Install additional PHP extensions
29+
RUN install-php-extensions \
30+
bcmath \
31+
curl \
32+
intl \
33+
zip \
34+
opcache \
35+
sodium
36+
37+
# Set the working directory
38+
WORKDIR /app
39+
40+
# Copy vendor from builder
41+
COPY --from=composer_build /app/vendor /app/vendor
42+
43+
# Copy application code
44+
COPY . /app
45+
46+
# Set default environment variables
47+
ENV OPENAPI_SPEC=data/openapi.yaml
48+
49+
# Expose port 80
50+
EXPOSE 80

compose.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
services:
2+
mock-server:
3+
build:
4+
context: .
5+
dockerfile: Dockerfile
6+
image: webproject/php-openapi-mock-server:latest
7+
container_name: openapi-mock-server
8+
restart: unless-stopped
9+
ports:
10+
- "8080:80"
11+
environment:
12+
# Path or URL to the OpenAPI specification
13+
- OPENAPI_SPEC=${OPENAPI_SPEC:-data/openapi.yaml}
14+
# Enable FrankenPHP watcher for hot-reload
15+
- FRANKENPHP_WATCHER=1
16+
volumes:
17+
# Mount source code for hot-reload
18+
- .:/app
19+
# Map data if you want to use local spec files
20+
- ./data:/app/data:ro

grumphp.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
grumphp:
2+
process_timeout: 120
3+
fixer:
4+
enabled: false
5+
fix_by_default: false
6+
parallel:
7+
enabled: true
8+
max_workers: 8
9+
tasks:
10+
phpcsfixer:
11+
config: .php-cs-fixer.php
12+
allow_risky: true
13+
phpstan:
14+
configuration: phpstan.neon
15+
level: 8
16+
use_grumphp_paths: false
17+
# rector:
18+
# config: rector.php
19+
# no_diffs: false
20+
# triggered_by: ['php']
21+
codeception:
22+
config_file: codeception.yml
23+
fail_fast: true

phpbench.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "./vendor/phpbench/phpbench/phpbench.schema.json",
3+
"runner.bootstrap": "vendor/autoload.php",
4+
"runner.path": "tests/Benchmark",
5+
"runner.php_config": {
6+
"opcache.enable_cli": "1",
7+
"opcache.jit": "tracing",
8+
"opcache.jit_buffer_size": "128M"
9+
}
10+
}

rector.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\Set\ValueObject\SetList;
7+
use Rector\ValueObject\PhpVersion;
8+
9+
return RectorConfig::configure()
10+
->withPaths([
11+
__DIR__ . '/config',
12+
__DIR__ . '/public',
13+
__DIR__ . '/src',
14+
__DIR__ . '/tests',
15+
])
16+
// Target PHP version
17+
->withPhpVersion(PhpVersion::PHP_83)
18+
->withPhpSets(php83: true)
19+
->withPreparedSets(
20+
deadCode: true,
21+
codeQuality: true,
22+
typeDeclarations: true,
23+
privatization: true,
24+
earlyReturn: true,
25+
naming: true,
26+
)
27+
->withSets([
28+
SetList::CODING_STYLE,
29+
SetList::INSTANCEOF,
30+
])
31+
// Import settings
32+
->withImportNames(
33+
importNames: true,
34+
removeUnusedImports: true,
35+
)
36+
// PHPStan config for better type inference
37+
->withPHPStanConfigs([
38+
__DIR__ . '/phpstan.neon',
39+
__DIR__ . '/vendor/slam/phpstan-laminas-framework/extension.neon',
40+
])
41+
// Parallel processing
42+
->withParallel(
43+
timeoutSeconds: 120,
44+
maxNumberOfProcess: 8,
45+
)
46+
->withSkip([
47+
__DIR__ . '/tests/Support/_generated',
48+
]);

0 commit comments

Comments
 (0)