The repo provides a complete React, Symfony, Nginx and MongoDb or MySQL environment in Docker. SyNDReXX stands for:
- Symfony
- Nginx
- Docker
- React
- X is a variable and stands for the database MongoDb or MySQL
Feel free to use the repo. I always try to keep the repo up to date. Please bear with me as I don't have much experience with Git and Docker yet.
The installation works for Linux. I do not know, if the installation works for the Windows subsystem. You are welcome to clone the repo and run it in Windows. I will gladly extend the description with a Windows chapter.
Make sure which Docker version you are using. make sure which Docker version you are using.
If your version is greater than 2.0, then start the containers with docker compose up <parameters>
.
If it is smaller than 2.0, then the command goes as follows: docker-compose up <parameters>
. Note the hyphen!
git clone https://github.com/One-Type-Man/SyNDReX.git
cd SyNDReX
docker-compose build
or docker compose build
.
But before you start the containers, the line "command: npm start" in the docker-compose.yml, is commented out. This is important for the beginning, otherwise the React container will not start! The command will start the React project, but will immediately print an error message, because there is no package.json. Therefore we have to comment out the line first. Start the container:
- Version less 2.0:
docker-compose up -d
- Version greather 2.0:
docker compose up -d
.
With docker ps
you will have the following output:
> $ docker-compose ps
Image ... Ports Names
--------------------------------------------------------------------------------------------------
syndrex_react 0.0.0.0:3000->3000/tcp, :::3000->3000/tcp react
syndrex_nginx 0.0.0.0:80->80/tcp, :::80->80/tcp, 9001/tcp nginx
syndrex_symfony 0.0.0.0:9001->9001/tcp, :::9001->9001/tcp symfony
mongo 0.0.0.0:8081->8081/tcp, :::8081->8081/tcp, 27017/tcp mongo_database
The recommended working directory is /var/www/frontend of the react container. Now, create the react project with following command:
docker exec -it react sh /usr/share/scripts/initReactProject.sh
The working directory is declared as :cached, so you will find (after restarting all container in chapter 1.7) the new initialized project in ./workdir/frontend/.
To create the Symfony project you need the initSymfonyProject.sh script. You start it with the command:
docker exec -it symfony sh /usr/share/scripts/initSymfonyProject.sh <symfony_project_name>
Open the docker-compose.yml file and enable the line command: npm start. Then restart the containers with docker-compose up -d
or docker compose up -d
.
Open your browser and make sure everything worked.
The React container can be accessed via the URL http://react.localhost
and the Symfony container via http://symfony.localhost
.
If you need MySQl, comment out the section after "db", and enable the lines needed for the MySQL container. In the Symfony section, you would then also have to activate the correct lines under "links". Of course you can also create a MongoDB and MySQL container.
The logs are cached and you will find them in project folder workDir/logs.
- Shows all running containers:
docker ps
- If you want to use the shell from the container itself:
docker exec -it <container_name> sh
- Command:
sudo chown -R $USER ./workDir/*
.
- Please make yourself familiar with the commands of Docker. Use the respective "Dockerfile" for changes. But be careful! If you change the working directory, then you must also do it in the respective configuration files of the Nginx. The react.conf contains the working directory where Nginx will look for the React project!
Legally, I don't know if I can declare the repo with a GPL3 license.
But definitely feel free to copy, modify or even improve the repo. I have one request: If you have any improvements, please let me know. Would love to include them too :)