Y
Y
Yuri Kravchuk2020-05-06 07:32:52
Continuous Integration
Yuri Kravchuk, 2020-05-06 07:32:52

How to build nginx, front, back bundle with docker-compose?

Hello!

There are two projects: front on Vue.js and back on Nest.js. Each project, of course, lies in its own repository on Gitlab. I use Gitlab CI/CD to build and deliver to VPS. Nginx is configured in a front-end project. The backend project knows nothing about nginx.

I tried to keep nginx with docker-compose in a separate project, it's convenient, but ... you have to deploy manually, because. this project knows nothing about front and back.

Actually the question itself: how to tie this whole thing to docker-compose in order to have one config for the whole bunch?
I believe silver on Gitlab solves this problem with Multi-project pipelines . What other options might there be?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladimir Kuts, 2020-05-07
@fox_12

And what exactly is the problem?
Gitlab CI/CD downloads a new version of the repository - to ./local-back or ./local-front, and restarts docker-compose
docker-compose.yml which is in the folder above looks something like this:

nginx:
   ...
   volumes:
   - ./local-back:/container/back
   - ./local-front:/container/front
  ...

back:
  ...
  volumes:
  -./local-back:/container/back
  command: тут скрипт который конфигурит бэк и запускает его

front:
  ...
  volumes:
  -./local-front:/container/front
  command: тут скрипт который конфигурит фронт, собирает статику, или что он там делает..

nginx sees the back as back - accordingly addresses requests to it, sees the folder with the back to take files from there if necessary (downloadable media, etc.)
nginx also sees the folder with the front from where it takes statics, etc.

V
Vitaly Karasik, 2020-05-06
@vitaly_il1

The backend project knows nothing about nginx.

He shouldn't be like? Does the front only need the backend URL?
About the main question: I have not worked with Gitlab CI, but in Jenkins I would just take the code from different repos, build images and run in docker-compose. Like this:
https://stackoverflow.com/questions/59712578/multi...

N
noremorse_ru, 2020-05-06
@noremorse_ru

And why one config for different projects?

I tried to keep nginx with docker-compose in a separate project, it's convenient, but ... you have to deploy manually, because. this project knows nothing about front and back.

What do you mean he doesn't know anything? You need to stick to a microservice architecture where the service doesn't need to know anything other than where to fire the http request. Let your balancer proxy / to the front, and /api/ to the back, or whatever your urls are built and that's it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question