Skip to content

Commit

Permalink
Merge branch 'release/v2.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
ambroisemaupate committed May 15, 2024
2 parents c4f89cb + 31a351f commit 03fa65a
Show file tree
Hide file tree
Showing 59 changed files with 1,096 additions and 1,082 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ project_env.sh
!docker/solr/managed-schema.xml
!docker/php-fpm-alpine/crontab.txt
!docker/php-fpm-alpine/docker-php-entrypoint
!docker/php-fpm-alpine/docker-cron-entrypoint
!docker/php-fpm-alpine/php.ini
!docker/php-fpm-alpine/php.prod.ini
!docker/php-fpm-alpine/wait-for-it.sh
Expand Down
9 changes: 7 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ PUBLIC_SMTP_PORT=1025
TRUSTED_PROXIES=172.18.0.1,172.18.0.2,REMOTE_ADDR,varnish
#TRUSTED_HOSTS=roadiz-skeleton.test,varnish.roadiz-skeleton.test
# Docker networking
DEFAULT_GATEWAY=172.144.0.1
DEFAULT_GATEWAY=172.144.0.0

SOLR_HOST=solr
SOLR_PORT=8983
Expand All @@ -38,6 +38,7 @@ VARNISH_URL=http://varnish
VARNISH_SIZE=256M
HTTP_CACHE_MAX_AGE=60
HTTP_CACHE_SHARED_MAX_AGE=600
HTTP_CACHE_STALE_WHILE_REVALIDATE=60

# To use with Traefik and your local dev environment
# On linux you can use dnsmasq to redirect all DNS for *.test TLD to your machine.
Expand Down Expand Up @@ -130,7 +131,7 @@ IR_DRIVER=gd
###< rezozero/intervention-request-bundle ###

###> nelmio/cors-bundle ###
CORS_ALLOW_ORIGIN=^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$
CORS_ALLOW_ORIGIN=^https?://(localhost|127\.0\.0\.1|192\.168\.[0-9]+\.[0-9]+)(:[0-9]+)?$
###< nelmio/cors-bundle ###

###> symfony/framework-bundle ###
Expand Down Expand Up @@ -169,3 +170,7 @@ DATABASE_URL="mysql://roadiz:roadiz@db:3306/roadiz?serverVersion=8&charset=utf8m
#RESTIC_PASSWORD=
RESTIC_REPOSITORY=
MYSQL_DUMP_FILENAME=api_database_dump.sql

###> sentry/sentry-symfony ###
SENTRY_DSN=
###< sentry/sentry-symfony ###
2 changes: 1 addition & 1 deletion .github/workflows/run-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.1', '8.2', '8.3']
php-version: ['8.2', '8.3']
steps:
- uses: shivammathur/setup-php@v2
with:
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
###> symfony/phpunit-bridge ###
.phpunit.result.cache
/phpunit.xml
/coverage
###< symfony/phpunit-bridge ###

###> phpunit/phpunit ###
/phpunit.xml
.phpunit.result.cache
/phpunit.xml.dist
###< phpunit/phpunit ###

###> lexik/jwt-authentication-bundle ###
Expand All @@ -37,7 +37,6 @@ report.txt
/phpcs.xml
###< squizlabs/php_codesniffer ###
openapi.json
composer.lock
/*.sql
/*.zip
/*.tar
Expand Down
14 changes: 13 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Gitlab CI
# Replace “roadiz_skeleton” with your project slug
image: roadiz/php81-runner
image: roadiz/php83-runner

stages:
- test
Expand Down Expand Up @@ -29,6 +29,17 @@ roadiz_skeleton_test:
key: ${CI_COMMIT_REF_SLUG}
paths:
- vendor/
variables:
XDEBUG_MODE: "coverage"
artifacts:
expire_in: 1 day
paths:
- coverage
reports:
junit: coverage/report.xml
coverage_report:
coverage_format: cobertura
path: coverage/cobertura.xml
#before_script:
#- eval "$(ssh-agent -s)"
#- echo "$COMPOSER_SERVER_PRIVATE_KEY" | tr -d '\r' | ssh-add -
Expand All @@ -44,6 +55,7 @@ roadiz_skeleton_test:
- composer install
- php -d memory_limit=-1 vendor/bin/phpcs -p ./src
- php -d memory_limit=-1 vendor/bin/phpstan analyse -c phpstan.neon
- php -d memory_limit=-1 vendor/bin/phpunit --colors=never

roadiz_skeleton_build:
stage: build
Expand Down
356 changes: 228 additions & 128 deletions CHANGELOG.md

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
FROM roadiz/php82-fpm-alpine:latest
MAINTAINER Ambroise Maupate <ambroise@rezo-zero.com>
FROM roadiz/php83-fpm-alpine:latest
LABEL org.opencontainers.image.authors="ambroise@rezo-zero.com"

ARG USER_UID=1000
ENV APP_ENV=prod
ENV APP_DEBUG=0
ENV APP_FFMPEG_PATH=/usr/bin/ffmpeg
ENV MYSQL_HOST=db
ENV MYSQL_PORT=3306

HEALTHCHECK --start-period=30s --interval=1m --timeout=6s CMD bin/console monitor:health -q

# Added ffmpeg to extract video files thumbnails
RUN apk add --no-cache ffmpeg

Expand All @@ -26,12 +29,14 @@ COPY docker/php-fpm-alpine/php.prod.ini /usr/local/etc/php/php.ini
COPY docker/php-fpm-alpine/crontab.txt /crontab.txt
COPY docker/php-fpm-alpine/wait-for-it.sh /wait-for-it.sh
COPY docker/php-fpm-alpine/docker-php-entrypoint /usr/local/bin/docker-php-entrypoint
COPY docker/php-fpm-alpine/docker-cron-entrypoint /usr/local/bin/docker-cron-entrypoint
COPY --chown=www-data:www-data . /var/www/html/

RUN ln -s /var/www/html/bin/console /usr/local/bin/console \
&& /usr/bin/crontab -u www-data /crontab.txt \
&& chmod +x /wait-for-it.sh \
&& chmod +x /usr/local/bin/docker-php-entrypoint \
&& chmod +x /usr/local/bin/docker-cron-entrypoint \
&& chown -R www-data:www-data /var/www/html/

VOLUME /var/www/html/config/jwt \
Expand All @@ -45,5 +50,4 @@ VOLUME /var/www/html/config/jwt \
#/var/www/html/src/GeneratedEntity \
/var/www/html/public/files \
/var/www/html/public/assets \
/var/www/html/var/files \
/var/www/html/var/secret
/var/www/html/var/files
31 changes: 29 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,41 @@ cache:
test:
docker compose exec -u www-data app php -d "memory_limit=-1" vendor/bin/phpcbf --report=full --report-file=./report.txt -p ./src
docker compose exec -u www-data app php -d "memory_limit=-1" vendor/bin/phpstan analyse -c phpstan.neon
XDEBUG_MODE=coverage php -d "memory_limit=-1" vendor/bin/phpunit

update:
docker compose exec -u www-data app php bin/console doctrine:migrations:migrate -n
# Do not perform files changes just apply existing migrations and import data
docker compose exec -u www-data app php bin/console app:install -n
make cache;

migrate:
docker compose exec -u www-data app php bin/console doctrine:migrations:migrate
docker compose exec -u www-data app php bin/console doctrine:migrations:migrate -n
# Apply files changes and create new Doctrine migrations if necessary
docker compose exec -u www-data app php bin/console app:migrate
# Stop workers to force restart them (Supervisord)
docker compose exec -u www-data app php bin/console messenger:stop-workers

install:
make migrate;
docker compose exec -u www-data app php bin/console doctrine:migrations:migrate -n
# Do not perform files changes on the database
docker compose exec -u www-data app php bin/console app:install -n
docker compose exec -u www-data app bin/console install;
make cache;

changelog:
git-cliff -o CHANGELOG.md

bump:
git-cliff --bump -o CHANGELOG.md

##
## Start the development environment using Symfony server and Docker
##
dev:
docker compose -f docker-compose.symfony.yml up -d
symfony serve -d

stop:
symfony server:stop
docker compose -f docker-compose.symfony.yml down
112 changes: 81 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,36 @@ When you're ready you can check that *Symfony* console responds through your Doc
docker compose exec -u www-data app bin/console
```

### Using `symfony server:start` instead of Docker

If you are working on a *macOS* environment, you may prefer using `symfony` binary to start a local webserver instead of using
a full _Docker_ stack. You will need to install `symfony` binary first:

```shell
curl -sS https://get.symfony.com/cli/installer | bash
```

And make sure your local PHP environment is configured with php-intl, php-redis, php-gd extensions.
You will need to use at least *MySQL* and *Redis* (and *Solr* if needed) services from Docker stack in order to run your application.

```shell
docker compose -f docker-compose.symfony.yml up -d
```

- Configure your `.env.local` variables to use your local MySQL and Redis services. Replacing `db`, `redis`, `mailer` and `solr` hostnames with `127.0.0.1`. Make sure to use `127.0.0.1` and not `localhost` on *macOS* as it will not work with Docker.
- Remove `docker compose exec -u www-data app ` prefix from all commands in `Makefile` to execute recipes locally.
- Remove cache invalidation Varnish configuration from `config/packages/api_platform.yaml` and `config/packages/roadiz_core.yaml` file.

Then you can start your local webserver:

```shell
symfony serve -d
```

Perform all installation steps described above, without using `docker compose exec` command.

Then your Roadiz backoffice will be available at `https://127.0.0.1:8000/rz-admin`

### Generate [Symfony secrets](https://symfony.com/doc/current/configuration/secrets.html)

When you run `composer create-project` first time, following command should have been executed automatically:
Expand Down Expand Up @@ -92,6 +122,34 @@ docker compose exec -u www-data app bin/console cache:clear
docker compose exec -u www-data app bin/console users:create -m username@roadiz.io -b -s username
```

### Manage Node-types

Node-types can be managed through back-office interface or by editing JSON files in `src/Resources/node-types` directory.
If you edit JSON files manually you need to synchronize your database with these files and generate Doctrine Migrations
if this leads to database schema changes.

#### Migrate node-types

When you direct update the `node-types` JSON files, you need to add them into `src/Resources/config.yml`
and run the following command to update the database:

```bash
make migrate
```

This command will **update PHP entities** and **create a Doctrine migration** file if necessary.

#### Apply node-type migration

When you pull the project and just want to sync your local node-types, you need to apply the migration:

```bash
make update
```

This will **only load node-types** that are not already in the database. But it won't create any migration.
This is the same script that is executed when you run `make install` and in your docker image entrypoint.

### Features

- Configured to be used in headless mode with *API Platform*
Expand Down Expand Up @@ -173,37 +231,7 @@ You can fetch this endpoint once in your website frontend, instead of embedding

Make sure your `.env` file does not contain any sensitive data as it must be added to your repository: `git add --force .env`
in order to be overridden by `.env.local` file.
Sensitive and local data must be filled in `.env.local` which is git-ignored.

### Using `symfony server:start` instead of Docker

If you are working on a *macOS* environment, you may prefer using `symfony` binary to start a local webserver instead of using
a full _Docker_ stack. You will need to install `symfony` binary first:

```shell
curl -sS https://get.symfony.com/cli/installer | bash
```

And make sure your local PHP environment is configured with php-intl, php-redis, php-gd extensions.
You will need to use at least *MySQL* and *Redis* (and *Solr* if needed) services from Docker stack in order to run your application.

```shell
docker compose -f docker-compose.symfony.yml up -d
```

- Configure your `.env` variables to use your local MySQL and Redis services. Replacing `db`, `redis`, `mailer` and `solr` hostnames with `127.0.0.1`. Make sure to use `127.0.0.1` and not `localhost` on *macOS* as it will not work with Docker.
- Remove `docker compose exec -u www-data app ` prefix from all commands in `Makefile` to execute recipes locally.
- Remove cache invalidation Varnish configuration from `config/packages/api_platform.yaml` and `config/packages/roadiz_core.yaml` file.

Then you can start your local webserver:

```shell
symfony server:start
```

Perform all installation steps described above, without using `docker compose exec` command.

Then your Roadiz backoffice will be available at `https://127.0.0.1:8000/rz-admin`
Sensitive and local data must be filled in `.env.local` which is git-ignored.

### Make node-types editable on production environment

Expand All @@ -221,6 +249,28 @@ a local environment.
**We do not recommend this workflow on complex applications** in which you will need to control and version your node-types
schema. This is only recommended for small and basic websites.

### Conventional commits

This project uses conventional commits to automate the release process and
*changelog* generation with [git-cliff](https://github.com/orhun/git-cliff).
A `cliff.toml` configuration file is already provided in this skeleton.

#### Generate a CHANGELOG file
```bash
git-cliff -o CHANGELOG.md
```

#### Before releasing

- With a known tag
```bash
git-cliff -o CHANGELOG.md --tag 1.0.0
```
- Without knowing tag, let `git-cliff` find the right version
```bash
git-cliff -o CHANGELOG.md --bump
```

### Credits

This skeleton uses https://github.com/vishnubob/wait-for-it script to wait for MySQL readiness before launching app entrypoint.
Loading

0 comments on commit 03fa65a

Please sign in to comment.