- DO NOT FORK THIS REPO
- DO NOT OPEN A PULL REQUEST
This project contains a basic Docker configuration to run:
- A minimal installation of Symfony5 running under PHP8.0, to serve as a RESTful API for a blogging CMS;
- A CreateReactApp starter instantiated with Typescript;
- A Mysql8 server with and Adminer web interface.
It is very important that you do these tasks before the beginning of the test. We don't want you to spend some time struggling with your development environment. You will need all the time you can have to go as far as possible in the instructions.
- Install Docker engine and Docker Compose to their latest versions for your OS. (see Install Docker)
- Clone the project in your local environment.
- Build the Docker containers by running
docker compose build(ordocker-compose.exe buildfor Windows from theDocker Quickstart terminal) in the root folder of the project - Launch the containers by running
docker compose up(ordocker-compose.exe upfrom theDocker Quickstart terminalfor Windows) in the root folder of the project - Install backend dependencies by running
composer installin the backend container (You can connect to the backend container by runningdocker exec -it remote-test-php-1 /bin/bash). - Make sure the project is running correctly :
GET localhost:8001/helloshould return this JSON :
{ "message":"It works!" }- Running
docker compose exec php /usr/src/backend/vendor/bin/phpunitshould show 1 successful test
If you are running Docker under Windows, the address your site will be accessible is not localhost, but an IP you can find in the first lines of the
Docker Quickstart Terminalwhen you open it.
By default, the apps are available at:
- http://localhost:8001 for the Symfony App;
- http://localhost:3001 for the React App;
- http://localhost:8081 for the Adminer interface.
And the MySQL installation comes with the user root, password root, and mysql as a server host.
If you know what you're doing, and want to modify the ports defined, you can update the values in the .env file at the root of the repo.
- Push your code to a private repositoy you own whitout forking this repo
- Invite
@sylfabreto this private repository
To run a command (like a Symfony or Composer command), you will need to execute it via docker compose, prefixing it with docker compose exec php.
For example, to create a database with the MySQL connection, you will have to run docker compose exec php php bin/console doctrine:database:create.
To add a package to Composer, you will have to run docker compose exec php composer require <your-package>
The connection to your database URL is managed throught the DATABASE_URL set in the apps/backend/.env file. Because we are in a Docker environment, with our services running in distinct containers, you have to reference the MySQL container for the connection :
DATABASE_URL=mysql://root:root@mysql:3306/db_name
Note the mysql@3306 referencing the port 3306 from the mysql container.
If you have an error looking like:
ERROR: The Compose file './../docker-compose.override.yml' is invalid because:
...
...Check that you are running your command from the root folder of the Docker installation and not a subfolder.
If you're facing "Couln'd connect to Docker Daemon at http+docker://localunixsocket — is it running?" error, refer to this help)
If you have a recent enough Windows, you can download and install Docker Desktop for Windows. We recommend using WSL2 for the best performances.
You can follow this good tutorial for installing Docker and Docker Composer.
Follow this link to avoid using sudo in the docker context if it's not already the case.