Skip to content

Commit 5370423

Browse files
dunglasLucasHospice
authored andcommitted
feat: allow to install the website skeleton (dunglas#152)
* feat: allow to install the website skeleton * wip * wip * cleanup * revert rename in docs * cleanup
1 parent 7096d6f commit 5370423

File tree

6 files changed

+43
-18
lines changed

6 files changed

+43
-18
lines changed

Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ RUN apk add --no-cache \
1818
gettext \
1919
git \
2020
gnu-libiconv \
21-
jq \
2221
;
2322

2423
# 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"
8281

8382
WORKDIR /srv/app
8483

84+
# Allow to choose skeleton
85+
ARG SKELETON="symfony/skeleton"
86+
ENV SKELETON ${SKELETON}
87+
8588
# Allow to use development versions of Symfony
8689
ARG STABILITY="stable"
87-
ENV STABILITY ${STABILITY:-stable}
90+
ENV STABILITY ${STABILITY}
8891

8992
# Allow to select skeleton version
9093
ARG SYMFONY_VERSION=""
94+
ENV SYMFONY_VERSION ${SYMFONY_VERSION}
9195

9296
# Download the Symfony skeleton and leverage Docker cache layers
9397
RUN composer create-project "symfony/skeleton ${SYMFONY_VERSION}" . --stability=$STABILITY --prefer-dist --no-dev --no-progress --no-interaction; \

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ services:
77
target: symfony_php
88
args:
99
SYMFONY_VERSION: ${SYMFONY_VERSION:-}
10+
SKELETON: ${SKELETON:-symfony/skeleton}
1011
STABILITY: ${STABILITY:-stable}
1112
restart: unless-stopped
1213
volumes:
@@ -23,7 +24,6 @@ services:
2324
MERCURE_URL: ${CADDY_MERCURE_URL:-http://caddy/.well-known/mercure}
2425
MERCURE_PUBLIC_URL: https://${SERVER_NAME:-localhost}/.well-known/mercure
2526
MERCURE_JWT_SECRET: ${CADDY_MERCURE_JWT_SECRET:-!ChangeMe!}
26-
SYMFONY_VERSION:
2727

2828
caddy:
2929
build:

docker/php/docker-entrypoint.sh

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,27 @@ if [ "$1" = 'php-fpm' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then
1717

1818
# The first time volumes are mounted, the project needs to be recreated
1919
if [ ! -f composer.json ]; then
20-
composer create-project "symfony/skeleton $SYMFONY_VERSION" tmp --stability=$STABILITY --prefer-dist --no-progress --no-interaction
21-
jq '.extra.symfony.docker=true' tmp/composer.json >tmp/composer.tmp.json
22-
rm tmp/composer.json
23-
mv tmp/composer.tmp.json tmp/composer.json
20+
CREATION=1
21+
composer create-project "$SKELETON $SYMFONY_VERSION" tmp --stability="$STABILITY" --prefer-dist --no-progress --no-interaction --no-install
22+
23+
cd tmp
24+
composer config --json extra.symfony.docker 'true'
25+
cp -Rp . ..
26+
cd -
2427

25-
cp -Rp tmp/. .
2628
rm -Rf tmp/
2729
elif [ "$APP_ENV" != 'prod' ]; then
2830
rm -f .env.local.php
29-
composer install --prefer-dist --no-progress --no-interaction
3031
fi
3132

33+
composer install --prefer-dist --no-progress --no-interaction
34+
3235
if grep -q ^DATABASE_URL= .env; then
36+
if [ "$CREATION" = "1" ]; then
37+
echo "To finish the installation please press Ctrl+C to stop Docker Compose and run: docker-compose up --build"
38+
sleep infinity
39+
fi
40+
3341
echo "Waiting for db to be ready..."
3442
ATTEMPTS_LEFT_TO_REACH_DATABASE=60
3543
until [ $ATTEMPTS_LEFT_TO_REACH_DATABASE -eq 0 ] || DATABASE_ERROR=$(bin/console dbal:run-sql "SELECT 1" 2>&1); do

docs/build.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,33 @@
11
# Build Options
22

3+
## Selecting a Symfony Skeleton
4+
5+
By default, Symfony Docker will install the minimalist skeleton.
6+
To install the ["website skeleton"](https://symfony.com/doc/current/setup.html#creating-symfony-applications), use the following command:
7+
8+
SKELETON=symfony/website-skeleton docker-compose up --build
9+
310
## Selecting a Specific Symfony Version
411

512
Use the `SYMFONY_VERSION` environment variable to select a specific Symfony version.
613

714
For instance, use the following command to install Symfony 4.4:
815

9-
$ SYMFONY_VERSION=4.4.* docker-compose up --build
16+
SYMFONY_VERSION=4.4.* docker-compose up --build
17+
18+
## Installing Development Versions of Symfony
1019

1120
To install a non-stable version of Symfony, use the `STABILITY` environment variable during the build.
1221
The value must be [a valid Composer stability option](https://getcomposer.org/doc/04-schema.md#minimum-stability)) .
1322

1423
For instance, use the following command to use the `master` branch of Symfony:
1524

16-
$ STABILITY=dev docker-compose up --build
25+
STABILITY=dev docker-compose up --build
1726

1827
## Customizing the Server Name
1928

2029
Use the `SERVER_NAME` environment variable to define your custom server name(s).
2130

22-
$ SERVER_NAME="symfony.wip, caddy:80" docker-compose up --build
31+
SERVER_NAME="symfony.wip, caddy:80" docker-compose up --build
2332

2433
If you use Mercure, keep `caddy:80` in the list to allow the PHP container to request the caddy service.

docs/production.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Alternatively, if you don't want to expose an HTTPS server but only an HTTP one,
8282
SERVER_NAME=:80 \
8383
APP_SECRET=ChangeMe \
8484
CADDY_MERCURE_JWT_SECRET=ChangeMe \
85-
-docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
85+
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
8686
```
8787

8888
## Deploying on Multiple Nodes

docs/xdebug.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,17 @@ services:
5151
5252
Then run:
5353
54-
$ docker-compose -f docker-compose.yml -f docker-compose.debug.yml up -d
54+
```console
55+
docker-compose -f docker-compose.yml -f docker-compose.debug.yml up -d
56+
```
5557

5658
## Troubleshooting
5759

5860
Inspect the installation with the following command. The requested Xdebug version should be displayed in the output.
5961

60-
$ docker-compose exec php php --version
61-
62-
PHP ...
63-
with Xdebug v3.0.4 ...
62+
```console
63+
$ docker-compose exec php php --version
64+
65+
PHP ...
66+
with Xdebug v3.0.4 ...
67+
```

0 commit comments

Comments
 (0)