Docker app (primarily) for Symfony projects.
Comes with PHP Composer, Apache 2.4, PHP 7, MariaDB, PHPMyAdmin and SSL support.
docker build --no-cache --rm --build-arg SYMFONY_USE_SSL=off -t handmadeapps/symfony .
OR
docker build --no-cache --rm --build-arg SYMFONY_USE_SSL=on -t handmadeapps/symfony .
Depending on the ssl option Apache is setup with the appropriate default file.
Apache server is setup to run a Symfony app under /var/www/[myapp]/[public folder]
Map a local volume to /var/www and then provide values for the following vars:
SYMFONY (default: symfonyapp)
SYMFONY_APP_PUBLIC_FOLDER (default: public)
See sample.env
file, and inline comments, for all applicable variables.
If you have enabled SSL, then map a local volume with the necessary files and then provide values for the following vars:
SSL_CERT
SSL_KEY
Logs are written under /var/log
Map a local volume to this location if you want to store logs locally.
docker run --net test --rm -it -v ~/docker_data/symfony/www:/var/www handmadeapps/symfony composer install
docker run --rm -it -v ~/docker_data/symfony/www:/var/www handmadeapps/symfony composer create-project symfony/website-skeleton myapp
docker run --rm -p 127.0.0.1:8080:80 -v ~/docker_data/symfony/www:/var/www --env SYMFONY=myapp -- env SYMFONY_APP_PUBLIC_FOLDER=web handmadeapps/symfony apache2-foreground
The project contains a sample.env
file.
Copy this file into .env
and edit accordingly (see inline comments).
In development, and for conveniency, you can deploy a Symfony app using docker-compose.
docker-compose up [app | appssl]
Running these commands will, in-place, create the following folder hierarchy:
symfony database www log
Use the www sub-folder to clone your existing Symfony project in.
You can specify the port for the Symfony app by setting the SYMFONY_PORT environment variable.
git clone https://bitbucket.org/ready-labs-team/docker_symfony.git
cd docker_symfony
copy sample.env
into .env
edit .env
accordingly to fit your use (hint: the SYMFONY variable is the same as the name of your symfony project repo.)
start the app : (NOTE: you can also use the convenience script start.sh
)
docker-compose up -d app
setup a new symfony project:
docker exec symfony-app composer create-project symfony/website-skeleton [symfony app name]
in a browser, go to : http://localhost:8080/
your app is up & running
stop the app by issuing: (NOTE: you can also use the convenience script stop.sh
)
docker-compose down
at any time you can enter your symfony app container to run commands:
docker exec -it symfony-app bash
to enter the database container:
docker exec -it symfony-database bash
git clone https://bitbucket.org/ready-labs-team/docker_symfony.git
cd docker_symfony
copy sample.env
into .env
edit .env
to fit your project (hint: the SYMFONY variable is the same as the name of your symfony project repo.)
start the app : (NOTE: you can also use the convenience script start.sh
)
docker-compose up -d app
cd symfony/www
git clone [your symfony git project URL]
cd ../..
run composer install
after initial cloning
docker exec symfony-app composer --working-dir=[symfony app name] install
edit the newly generated parameters.yml
file to match the settings in the .env
file
run further setup commands, such as setting up your database. e.g.:
docker exec symfony-app php [symfony app name]/bin/console doctrine:schema:update --force
in a browser, go to : http://localhost:8080/
your app is up & running
stop the app by issuing: (NOTE: you can also use the convenience script stop.sh
)
docker-compose down
at any time you can enter your symfony app container to run commands:
docker exec -it symfony-app bash
to enter the database container:
docker exec -it symfony-database bash
You can optionally start a PHPMyAdmin by entering: docker-compose up -d phpmyadmin
- When switching between SSL config (on / off) add the
--build
argument todocker-compose up
(or at at the end ofstart.sh
) to ensure that the app image is rebuilt with the correct Apache server configuration.
hostname: symfony-database
dbname: symfony
user: symfony
password: passwd