Create a Docker image and deploy it
This commit is contained in:
36
.dockerignore
Normal file
36
.dockerignore
Normal file
@@ -0,0 +1,36 @@
|
||||
**/*.log
|
||||
**/*.md
|
||||
**/*.php~
|
||||
**/*.dist.php
|
||||
**/*.dist
|
||||
**/*.cache
|
||||
**/._*
|
||||
**/.dockerignore
|
||||
**/.DS_Store
|
||||
**/.git/
|
||||
**/.gitattributes
|
||||
**/.gitignore
|
||||
**/.gitmodules
|
||||
**/compose.*.yaml
|
||||
**/compose.*.yml
|
||||
**/compose.yaml
|
||||
**/compose.yml
|
||||
**/docker-compose.*.yaml
|
||||
**/docker-compose.*.yml
|
||||
**/docker-compose.yaml
|
||||
**/docker-compose.yml
|
||||
**/Dockerfile
|
||||
**/Thumbs.db
|
||||
.drone.yml
|
||||
.github/
|
||||
.gitea/
|
||||
docs/
|
||||
public/bundles/
|
||||
tests/
|
||||
var/
|
||||
vendor/
|
||||
.editorconfig
|
||||
.env.*.local
|
||||
.env.local
|
||||
.env.local.php
|
||||
.env.test
|
37
.drone.yml
37
.drone.yml
@@ -28,3 +28,40 @@ steps:
|
||||
- php bin/phpunit
|
||||
depends_on:
|
||||
- install
|
||||
|
||||
- name: docker-image
|
||||
image: plugins/docker
|
||||
settings:
|
||||
registry: hub.codefirst.iut.uca.fr
|
||||
repo: hub.codefirst.iut.uca.fr/clement.freville2/herbarium
|
||||
username:
|
||||
from_secret: REGISTRY_USER
|
||||
password:
|
||||
from_secret: REGISTRY_PASSWORD
|
||||
cache_from:
|
||||
- hub.codefirst.iut.uca.fr/clement.freville2/herbarium:latest
|
||||
depends_on:
|
||||
- lint
|
||||
- test
|
||||
when:
|
||||
branch:
|
||||
- main
|
||||
- ci/*
|
||||
|
||||
- name: deploy
|
||||
image: hub.codefirst.iut.uca.fr/clement.freville2/codefirst-dockerproxy-clientdrone:latest
|
||||
settings:
|
||||
image: hub.codefirst.iut.uca.fr/clement.freville2/herbarium:latest
|
||||
container: herbarium
|
||||
command: create
|
||||
overwrite: true
|
||||
admins: clementfreville2
|
||||
environment:
|
||||
# Disable HTTPS redirection as it served by a reverse proxy
|
||||
CODEFIRST_CLIENTDRONE_ENV_SERVER_NAME: http://codefirst.iut.uca.fr
|
||||
depends_on:
|
||||
- docker-image
|
||||
when:
|
||||
branch:
|
||||
- main
|
||||
- ci/*
|
||||
|
32
Dockerfile
Normal file
32
Dockerfile
Normal file
@@ -0,0 +1,32 @@
|
||||
FROM docker.io/dunglas/frankenphp:1-php8.3
|
||||
|
||||
RUN install-php-extensions \
|
||||
@composer \
|
||||
apcu \
|
||||
intl \
|
||||
opcache \
|
||||
zip \
|
||||
;
|
||||
|
||||
ENV APP_ENV=prod
|
||||
ENV FRANKENPHP_CONFIG="import worker.Caddyfile"
|
||||
ENV COMPOSER_ALLOW_SUPERUSER=1
|
||||
|
||||
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
|
||||
|
||||
COPY frankenphp/conf.d/app.ini frankenphp/conf.d/app.prod.ini $PHP_INI_DIR/conf.d/
|
||||
COPY frankenphp/Caddyfile /etc/caddy/Caddyfile
|
||||
COPY frankenphp/worker.Caddyfile /etc/caddy/worker.Caddyfile
|
||||
COPY frankenphp/start.sh .
|
||||
|
||||
COPY composer.json composer.lock symfony.lock ./
|
||||
RUN composer install --no-cache --no-dev --no-autoloader --no-scripts --no-progress
|
||||
|
||||
COPY . .
|
||||
RUN composer dump-autoload --classmap-authoritative --no-dev \
|
||||
&& composer dump-env prod \
|
||||
&& composer run-script --no-dev post-install-cmd \
|
||||
;
|
||||
RUN rm -Rf frankenphp/
|
||||
|
||||
ENTRYPOINT [ "/app/start.sh" ]
|
@@ -13,6 +13,7 @@
|
||||
"doctrine/orm": "^3.1",
|
||||
"phpdocumentor/reflection-docblock": "^5.4",
|
||||
"phpstan/phpdoc-parser": "^1.29",
|
||||
"runtime/frankenphp-symfony": "^0.2.0",
|
||||
"symfony/asset": "7.0.*",
|
||||
"symfony/asset-mapper": "7.0.*",
|
||||
"symfony/console": "7.0.*",
|
||||
|
54
composer.lock
generated
54
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "963e7a72ac289ff9f4ad3c719ed70956",
|
||||
"content-hash": "888e1953f86d0f1fe9b271b85aab0ed0",
|
||||
"packages": [
|
||||
{
|
||||
"name": "composer/semver",
|
||||
@@ -2006,6 +2006,58 @@
|
||||
},
|
||||
"time": "2021-07-14T16:46:02+00:00"
|
||||
},
|
||||
{
|
||||
"name": "runtime/frankenphp-symfony",
|
||||
"version": "0.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-runtime/frankenphp-symfony.git",
|
||||
"reference": "56822c3631d9522a3136a4c33082d006bdfe4bad"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-runtime/frankenphp-symfony/zipball/56822c3631d9522a3136a4c33082d006bdfe4bad",
|
||||
"reference": "56822c3631d9522a3136a4c33082d006bdfe4bad",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.1",
|
||||
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
|
||||
"symfony/http-kernel": "^5.4 || ^6.0 || ^7.0",
|
||||
"symfony/runtime": "^5.4 || ^6.0 || ^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.5"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Runtime\\FrankenPhpSymfony\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kévin Dunglas",
|
||||
"email": "kevin@dunglas.dev"
|
||||
}
|
||||
],
|
||||
"description": "FrankenPHP runtime for Symfony",
|
||||
"support": {
|
||||
"issues": "https://github.com/php-runtime/frankenphp-symfony/issues",
|
||||
"source": "https://github.com/php-runtime/frankenphp-symfony/tree/0.2.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/nyholm",
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2023-12-12T12:06:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/asset",
|
||||
"version": "v7.0.7",
|
||||
|
55
frankenphp/Caddyfile
Normal file
55
frankenphp/Caddyfile
Normal file
@@ -0,0 +1,55 @@
|
||||
{
|
||||
{$CADDY_GLOBAL_OPTIONS}
|
||||
|
||||
frankenphp {
|
||||
#worker /path/to/your/worker.php
|
||||
{$FRANKENPHP_CONFIG}
|
||||
}
|
||||
|
||||
# https://caddyserver.com/docs/caddyfile/directives#sorting-algorithm
|
||||
order mercure after encode
|
||||
order vulcain after reverse_proxy
|
||||
order php_server before file_server
|
||||
order php before file_server
|
||||
}
|
||||
|
||||
{$CADDY_EXTRA_CONFIG}
|
||||
|
||||
{$SERVER_NAME:localhost} {
|
||||
log {
|
||||
# # Redact the authorization query parameter that can be set by Mercure
|
||||
# format filter {
|
||||
# wrap console
|
||||
# fields {
|
||||
# uri query {
|
||||
# replace authorization REDACTED
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
output stdout
|
||||
}
|
||||
|
||||
root * public/
|
||||
encode zstd br gzip
|
||||
|
||||
# Uncomment the following lines to enable Mercure and Vulcain modules
|
||||
#mercure {
|
||||
# # Transport to use (default to Bolt)
|
||||
# transport_url {$MERCURE_TRANSPORT_URL:bolt:///data/mercure.db}
|
||||
# # Publisher JWT key
|
||||
# publisher_jwt {env.MERCURE_PUBLISHER_JWT_KEY} {env.MERCURE_PUBLISHER_JWT_ALG}
|
||||
# # Subscriber JWT key
|
||||
# subscriber_jwt {env.MERCURE_SUBSCRIBER_JWT_KEY} {env.MERCURE_SUBSCRIBER_JWT_ALG}
|
||||
# # Allow anonymous subscribers (double-check that it's what you want)
|
||||
# anonymous
|
||||
# # Enable the subscription API (double-check that it's what you want)
|
||||
# subscriptions
|
||||
# # Extra directives
|
||||
# {$MERCURE_EXTRA_DIRECTIVES}
|
||||
#}
|
||||
#vulcain
|
||||
|
||||
{$CADDY_SERVER_EXTRA_DIRECTIVES}
|
||||
|
||||
php_server
|
||||
}
|
13
frankenphp/conf.d/app.ini
Normal file
13
frankenphp/conf.d/app.ini
Normal file
@@ -0,0 +1,13 @@
|
||||
expose_php = 0
|
||||
date.timezone = UTC
|
||||
apc.enable_cli = 1
|
||||
session.use_strict_mode = 1
|
||||
zend.detect_unicode = 0
|
||||
|
||||
; https://symfony.com/doc/current/performance.html
|
||||
realpath_cache_size = 4096K
|
||||
realpath_cache_ttl = 600
|
||||
opcache.interned_strings_buffer = 16
|
||||
opcache.max_accelerated_files = 20000
|
||||
opcache.memory_consumption = 256
|
||||
opcache.enable_file_override = 1
|
2
frankenphp/conf.d/app.prod.ini
Normal file
2
frankenphp/conf.d/app.prod.ini
Normal file
@@ -0,0 +1,2 @@
|
||||
opcache.preload_user = root
|
||||
opcache.preload = /app/config/preload.php
|
4
frankenphp/start.sh
Executable file
4
frankenphp/start.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
php bin/console doctrine:migrations:migrate --no-interaction
|
||||
exec frankenphp run --config /etc/caddy/Caddyfile
|
4
frankenphp/worker.Caddyfile
Normal file
4
frankenphp/worker.Caddyfile
Normal file
@@ -0,0 +1,4 @@
|
||||
worker {
|
||||
file ./public/index.php
|
||||
env APP_RUNTIME Runtime\FrankenPhpSymfony\Runtime
|
||||
}
|
20
src/Controller/PostController.php
Normal file
20
src/Controller/PostController.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Repository\PostRepository;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
class PostController extends AbstractController
|
||||
{
|
||||
#[Route('/', name: 'app_posts')]
|
||||
public function index(PostRepository $repository): Response
|
||||
{
|
||||
$posts = $repository->findAll();
|
||||
return $this->render('post/index.html.twig', [
|
||||
'posts' => $posts,
|
||||
]);
|
||||
}
|
||||
}
|
@@ -8,7 +8,7 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block javascripts %}
|
||||
{% block importmap %}{{ importmap('app') }}{% endblock %}
|
||||
{% block importmap %}{% endblock %}
|
||||
{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
|
11
templates/post/index.html.twig
Normal file
11
templates/post/index.html.twig
Normal file
@@ -0,0 +1,11 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Posts!{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
{% for post in posts %}
|
||||
<div class="card">
|
||||
#{{ post.id }} trouvé le {{ post.foundDate | date("d/m/Y \\à H \\h") }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
Reference in New Issue
Block a user