feat: allow to install the website skeleton (#152)
* feat: allow to install the website skeleton * wip * wip * cleanup * revert rename in docs * cleanup
This commit is contained in:
parent
a0192fdac4
commit
c99c188211
@ -18,7 +18,6 @@ RUN apk add --no-cache \
|
|||||||
gettext \
|
gettext \
|
||||||
git \
|
git \
|
||||||
gnu-libiconv \
|
gnu-libiconv \
|
||||||
jq \
|
|
||||||
;
|
;
|
||||||
|
|
||||||
# install gnu-libiconv and set LD_PRELOAD env to make iconv work fully on Alpine image.
|
# install gnu-libiconv and set LD_PRELOAD env to make iconv work fully on Alpine image.
|
||||||
@ -82,12 +81,17 @@ ENV PATH="${PATH}:/root/.composer/vendor/bin"
|
|||||||
|
|
||||||
WORKDIR /srv/app
|
WORKDIR /srv/app
|
||||||
|
|
||||||
|
# Allow to choose skeleton
|
||||||
|
ARG SKELETON="symfony/skeleton"
|
||||||
|
ENV SKELETON ${SKELETON}
|
||||||
|
|
||||||
# Allow to use development versions of Symfony
|
# Allow to use development versions of Symfony
|
||||||
ARG STABILITY="stable"
|
ARG STABILITY="stable"
|
||||||
ENV STABILITY ${STABILITY:-stable}
|
ENV STABILITY ${STABILITY}
|
||||||
|
|
||||||
# Allow to select skeleton version
|
# Allow to select skeleton version
|
||||||
ARG SYMFONY_VERSION=""
|
ARG SYMFONY_VERSION=""
|
||||||
|
ENV SYMFONY_VERSION ${SYMFONY_VERSION}
|
||||||
|
|
||||||
# Download the Symfony skeleton and leverage Docker cache layers
|
# Download the Symfony skeleton and leverage Docker cache layers
|
||||||
RUN composer create-project "symfony/skeleton ${SYMFONY_VERSION}" . --stability=$STABILITY --prefer-dist --no-dev --no-progress --no-interaction; \
|
RUN composer create-project "symfony/skeleton ${SYMFONY_VERSION}" . --stability=$STABILITY --prefer-dist --no-dev --no-progress --no-interaction; \
|
||||||
|
@ -7,6 +7,7 @@ services:
|
|||||||
target: symfony_php
|
target: symfony_php
|
||||||
args:
|
args:
|
||||||
SYMFONY_VERSION: ${SYMFONY_VERSION:-}
|
SYMFONY_VERSION: ${SYMFONY_VERSION:-}
|
||||||
|
SKELETON: ${SKELETON:-symfony/skeleton}
|
||||||
STABILITY: ${STABILITY:-stable}
|
STABILITY: ${STABILITY:-stable}
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
@ -23,7 +24,6 @@ services:
|
|||||||
MERCURE_URL: ${CADDY_MERCURE_URL:-http://caddy/.well-known/mercure}
|
MERCURE_URL: ${CADDY_MERCURE_URL:-http://caddy/.well-known/mercure}
|
||||||
MERCURE_PUBLIC_URL: https://${SERVER_NAME:-localhost}/.well-known/mercure
|
MERCURE_PUBLIC_URL: https://${SERVER_NAME:-localhost}/.well-known/mercure
|
||||||
MERCURE_JWT_SECRET: ${CADDY_MERCURE_JWT_SECRET:-!ChangeMe!}
|
MERCURE_JWT_SECRET: ${CADDY_MERCURE_JWT_SECRET:-!ChangeMe!}
|
||||||
SYMFONY_VERSION:
|
|
||||||
|
|
||||||
caddy:
|
caddy:
|
||||||
build:
|
build:
|
||||||
|
@ -17,19 +17,27 @@ if [ "$1" = 'php-fpm' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then
|
|||||||
|
|
||||||
# The first time volumes are mounted, the project needs to be recreated
|
# The first time volumes are mounted, the project needs to be recreated
|
||||||
if [ ! -f composer.json ]; then
|
if [ ! -f composer.json ]; then
|
||||||
composer create-project "symfony/skeleton $SYMFONY_VERSION" tmp --stability=$STABILITY --prefer-dist --no-progress --no-interaction
|
CREATION=1
|
||||||
jq '.extra.symfony.docker=true' tmp/composer.json >tmp/composer.tmp.json
|
composer create-project "$SKELETON $SYMFONY_VERSION" tmp --stability="$STABILITY" --prefer-dist --no-progress --no-interaction --no-install
|
||||||
rm tmp/composer.json
|
|
||||||
mv tmp/composer.tmp.json tmp/composer.json
|
cd tmp
|
||||||
|
composer config --json extra.symfony.docker 'true'
|
||||||
|
cp -Rp . ..
|
||||||
|
cd -
|
||||||
|
|
||||||
cp -Rp tmp/. .
|
|
||||||
rm -Rf tmp/
|
rm -Rf tmp/
|
||||||
elif [ "$APP_ENV" != 'prod' ]; then
|
elif [ "$APP_ENV" != 'prod' ]; then
|
||||||
rm -f .env.local.php
|
rm -f .env.local.php
|
||||||
composer install --prefer-dist --no-progress --no-interaction
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
composer install --prefer-dist --no-progress --no-interaction
|
||||||
|
|
||||||
if grep -q ^DATABASE_URL= .env; then
|
if grep -q ^DATABASE_URL= .env; then
|
||||||
|
if [ "$CREATION" = "1" ]; then
|
||||||
|
echo "To finish the installation please press Ctrl+C to stop Docker Compose and run: docker-compose up --build"
|
||||||
|
sleep infinity
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Waiting for db to be ready..."
|
echo "Waiting for db to be ready..."
|
||||||
ATTEMPTS_LEFT_TO_REACH_DATABASE=60
|
ATTEMPTS_LEFT_TO_REACH_DATABASE=60
|
||||||
until [ $ATTEMPTS_LEFT_TO_REACH_DATABASE -eq 0 ] || DATABASE_ERROR=$(bin/console dbal:run-sql "SELECT 1" 2>&1); do
|
until [ $ATTEMPTS_LEFT_TO_REACH_DATABASE -eq 0 ] || DATABASE_ERROR=$(bin/console dbal:run-sql "SELECT 1" 2>&1); do
|
||||||
|
@ -1,24 +1,33 @@
|
|||||||
# Build Options
|
# Build Options
|
||||||
|
|
||||||
|
## Selecting a Symfony Skeleton
|
||||||
|
|
||||||
|
By default, Symfony Docker will install the minimalist skeleton.
|
||||||
|
To install the ["website skeleton"](https://symfony.com/doc/current/setup.html#creating-symfony-applications), use the following command:
|
||||||
|
|
||||||
|
SKELETON=symfony/website-skeleton docker-compose up --build
|
||||||
|
|
||||||
## Selecting a Specific Symfony Version
|
## Selecting a Specific Symfony Version
|
||||||
|
|
||||||
Use the `SYMFONY_VERSION` environment variable to select a specific Symfony version.
|
Use the `SYMFONY_VERSION` environment variable to select a specific Symfony version.
|
||||||
|
|
||||||
For instance, use the following command to install Symfony 4.4:
|
For instance, use the following command to install Symfony 4.4:
|
||||||
|
|
||||||
$ SYMFONY_VERSION=4.4.* docker-compose up --build
|
SYMFONY_VERSION=4.4.* docker-compose up --build
|
||||||
|
|
||||||
|
## Installing Development Versions of Symfony
|
||||||
|
|
||||||
To install a non-stable version of Symfony, use the `STABILITY` environment variable during the build.
|
To install a non-stable version of Symfony, use the `STABILITY` environment variable during the build.
|
||||||
The value must be [a valid Composer stability option](https://getcomposer.org/doc/04-schema.md#minimum-stability)) .
|
The value must be [a valid Composer stability option](https://getcomposer.org/doc/04-schema.md#minimum-stability)) .
|
||||||
|
|
||||||
For instance, use the following command to use the `master` branch of Symfony:
|
For instance, use the following command to use the `master` branch of Symfony:
|
||||||
|
|
||||||
$ STABILITY=dev docker-compose up --build
|
STABILITY=dev docker-compose up --build
|
||||||
|
|
||||||
## Customizing the Server Name
|
## Customizing the Server Name
|
||||||
|
|
||||||
Use the `SERVER_NAME` environment variable to define your custom server name(s).
|
Use the `SERVER_NAME` environment variable to define your custom server name(s).
|
||||||
|
|
||||||
$ SERVER_NAME="symfony.wip, caddy:80" docker-compose up --build
|
SERVER_NAME="symfony.wip, caddy:80" docker-compose up --build
|
||||||
|
|
||||||
If you use Mercure, keep `caddy:80` in the list to allow the PHP container to request the caddy service.
|
If you use Mercure, keep `caddy:80` in the list to allow the PHP container to request the caddy service.
|
||||||
|
@ -82,7 +82,7 @@ Alternatively, if you don't want to expose an HTTPS server but only an HTTP one,
|
|||||||
SERVER_NAME=:80 \
|
SERVER_NAME=:80 \
|
||||||
APP_SECRET=ChangeMe \
|
APP_SECRET=ChangeMe \
|
||||||
CADDY_MERCURE_JWT_SECRET=ChangeMe \
|
CADDY_MERCURE_JWT_SECRET=ChangeMe \
|
||||||
-docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
|
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
## Deploying on Multiple Nodes
|
## Deploying on Multiple Nodes
|
||||||
|
@ -51,13 +51,17 @@ services:
|
|||||||
|
|
||||||
Then run:
|
Then run:
|
||||||
|
|
||||||
$ docker-compose -f docker-compose.yml -f docker-compose.debug.yml up -d
|
```console
|
||||||
|
docker-compose -f docker-compose.yml -f docker-compose.debug.yml up -d
|
||||||
|
```
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
Inspect the installation with the following command. The requested Xdebug version should be displayed in the output.
|
Inspect the installation with the following command. The requested Xdebug version should be displayed in the output.
|
||||||
|
|
||||||
|
```console
|
||||||
$ docker-compose exec php php --version
|
$ docker-compose exec php php --version
|
||||||
|
|
||||||
PHP ...
|
PHP ...
|
||||||
with Xdebug v3.0.4 ...
|
with Xdebug v3.0.4 ...
|
||||||
|
```
|
||||||
|
Loading…
x
Reference in New Issue
Block a user