5ergiu / docker-traefik-portainer-nginx-symfony-react

Docker based project with Traefik as a reverse proxy for Symfony ♥️ React

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Docker based project with Traefik used as a reverse proxy for Symfony ♥️ React

Issues open Last commit Latest version

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

  1. 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
    
  2. Run ./scripts/install.sh to install the project

That's it! The website is up and running:

-----------------------------------------------------

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

⚠️These share the same services, so you need to specify the correct file when building images/containers, you don't have to specify a file for running docker-compose commands on backend or frontend containers.

🚨 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 files
  • backend Symfony PHP framework + everything related to backend
  • frontend React JS framework + everything related to frontend
  • scripts to ease development or any script that can be used for the project
  • storage 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.

About

Docker based project with Traefik as a reverse proxy for Symfony ♥️ React

License:MIT License


Languages

Language:Shell 34.5%Language:TypeScript 17.9%Language:PHP 17.8%Language:HTML 15.4%Language:CSS 8.3%Language:Dockerfile 6.1%