Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run backend and frontend as separate services #118

Open
mehiX opened this issue Jun 7, 2023 · 3 comments
Open

Run backend and frontend as separate services #118

mehiX opened this issue Jun 7, 2023 · 3 comments

Comments

@mehiX
Copy link

mehiX commented Jun 7, 2023

At the moment both backend and frontend are running in the same container.

It would be great to have them separated. For example, docker-compose.yml would look like:

version: "3.8"
services:
  backend: 
    build: ./server
    depends_on:
    - db
    ports:
    - 8082:80
    environment:
      profile: prod
  
  frontend:
    build: 
      context: ./webapp
      args:
        profile: prod
        REACT_APP_API_URL: http://localhost:8082
    depends_on:
    - backend
    ports:
    - 8080:80
      
  db:
    image: mongo:6.0.3
    container_name: db
    environment:
      MONGO_INITDB_DATABASE: tech
    volumes:
      - ./init-db.js:/docker-entrypoint-initdb.d/init.js

Backend and frontend have their own Dockerfile and can be built and restarted independently.

@mehiX
Copy link
Author

mehiX commented Jun 7, 2023

Also I already made the changes for mongo+react in a different branch. I can push it if you want to have a look.

@Shpota
Copy link
Owner

Shpota commented Jun 13, 2023

Hi @mehiX. Thank you for the suggestion. Static resources are served by the backend container because there is no server-side rendering in the frontend templates that would require its own server. In the current setup, there isn't much difference in who serves the static content, so I kept it as simple as possible. Why do you need them separated?

@mehiX
Copy link
Author

mehiX commented Jun 15, 2023

@Shpota I understood you wanted to keep it simple. So you I. However I've never worked on a project (let alone one that runs in production) that mixes fronend and backend in the same container. there are lots of benefits to have them separated. I agree with you that in this setup it doesn't really matter who serves that static content. If the project is not meant to be extended and used in real project, you are right it can stay as it is.
For me it's not usible and that's why I changed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants