Docker
based project with
Traefik
used as a reverse proxy for
Symfony
📖 Contents
🧰 Tech stack
Stack | Technology |
---|---|
🛠️ Environment | Docker |
💻 Backend | Symfony using PHP-FPM 8.1.1 (with OPcache & JIT compiler) |
🌐 Frontend | React using TypeScript |
🛢 Database | MySQL |
🗄️ Server | Traefik (Reverse Proxy) Nginx (serving static files and bridging fastCGI protocols) |
💾 Installation
To get started, make sure you have Docker & Docker compose installed on your system, and then clone this repository.
-
Update hosts:
127.0.0.1 mysite.local 127.0.0.1 www.mysite.local 127.0.0.1 api.mysite.local 127.0.0.1 traefik.mysite.local 127.0.0.1 portainer.mysite.local
-
Run
./scripts/install.sh
to install the project
That's it! The website is up and running:
- http://mysite.local
- http://www.mysite.local
- http://api.mysite.local
- http://traefik.mysite.local
- http://portainer.mysite.local
🔧 Configuration
The configuration is mostly controlled through environment variables. There are the usual env variables used by Symfony and some used to configure Docker and PHP. More info on each of the variables and their roles can be found in the default env file - .env.default.
Also, there are 2 docker-compose files, the docker-compose.dev.yml file is used for local development, whilst the other one is used for prod environment.
🚨 The frontend part is built with create-react-app, so for the dev environment, a frontend development server is started automatically(with the command yarn start), so no need to run "watch" or anything, just make your changes and save the file, the page will automatically refresh for you to see the changes.
📦 Packages:
- The frontend only has the create-react-app(typescript) installation dependencies.
- The backend is has two additional packages besides the installation dependencies: doctrine and a health check bundle for the backend API.
📁 Folder structure
.docker
Configuration filesbackend
Symfony PHP framework + everything related to backendfrontend
React JS framework + everything related to frontendscripts
to ease development or any script that can be used for the projectstorage
used to store docker volumes data such as MySQL data or Portainer data
📜 Scripts
- ./scripts/install.sh (in project root): Installs the project (can be used for dev & PROD)
- ./scripts/bin [and the command you want to run] (in project root):
./scripts/bin make:controller TestController ./scripts/bin doctrine:migrations:migrate
- ./scripts/yarn [and the command you want to run] (in project root):
./scripts/yarn build ./scripts/yarn test
🍪 You could also create some aliases to further shorten these commands
📄 License
This project is licensed under the MIT License.