Skip to content

feat: allow to install the website skeleton #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ RUN apk add --no-cache \
gettext \
git \
gnu-libiconv \
jq \
;

# install gnu-libiconv and set LD_PRELOAD env to make iconv work fully on Alpine image.
Expand Down Expand Up @@ -82,12 +81,17 @@ ENV PATH="${PATH}:/root/.composer/vendor/bin"

WORKDIR /srv/app

# Allow to choose skeleton
ARG SKELETON="symfony/skeleton"
ENV SKELETON ${SKELETON}

# Allow to use development versions of Symfony
ARG STABILITY="stable"
ENV STABILITY ${STABILITY:-stable}
ENV STABILITY ${STABILITY}

# Allow to select skeleton version
ARG SYMFONY_VERSION=""
ENV SYMFONY_VERSION ${SYMFONY_VERSION}

# 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; \
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ services:
target: symfony_php
args:
SYMFONY_VERSION: ${SYMFONY_VERSION:-}
SKELETON: ${SKELETON:-symfony/skeleton}
STABILITY: ${STABILITY:-stable}
restart: unless-stopped
volumes:
Expand All @@ -23,7 +24,6 @@ services:
MERCURE_URL: ${CADDY_MERCURE_URL:-http://caddy/.well-known/mercure}
MERCURE_PUBLIC_URL: https://${SERVER_NAME:-localhost}/.well-known/mercure
MERCURE_JWT_SECRET: ${CADDY_MERCURE_JWT_SECRET:-!ChangeMe!}
SYMFONY_VERSION:

caddy:
build:
Expand Down
20 changes: 14 additions & 6 deletions docker/php/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
if [ ! -f composer.json ]; then
composer create-project "symfony/skeleton $SYMFONY_VERSION" tmp --stability=$STABILITY --prefer-dist --no-progress --no-interaction
jq '.extra.symfony.docker=true' tmp/composer.json >tmp/composer.tmp.json
rm tmp/composer.json
mv tmp/composer.tmp.json tmp/composer.json
CREATION=1
composer create-project "$SKELETON $SYMFONY_VERSION" tmp --stability="$STABILITY" --prefer-dist --no-progress --no-interaction --no-install

cd tmp
composer config --json extra.symfony.docker 'true'
cp -Rp . ..
cd -

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

composer install --prefer-dist --no-progress --no-interaction

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..."
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
Expand Down
15 changes: 12 additions & 3 deletions docs/build.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
# 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

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

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.
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:

$ STABILITY=dev docker-compose up --build
STABILITY=dev docker-compose up --build

## Customizing the Server Name

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.
2 changes: 1 addition & 1 deletion docs/production.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Alternatively, if you don't want to expose an HTTPS server but only an HTTP one,
SERVER_NAME=:80 \
APP_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
Expand Down
14 changes: 9 additions & 5 deletions docs/xdebug.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,17 @@ services:

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

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

$ docker-compose exec php php --version

PHP ...
with Xdebug v3.0.4 ...
```console
$ docker-compose exec php php --version

PHP ...
with Xdebug v3.0.4 ...
```