M
M
midia212021-11-22 09:19:23
Continuous Integration
midia21, 2021-11-22 09:19:23

How to implement gitlab ci using docker-compose?

Not dev-ops, but the task was to write a system for continuous integration of the project with Gitlab. The project is built using docker-compose. The purpose of the task is to automatically build docker images at the output that can be deployed on the server, so far without testing and even without cd (manually update running containers on the server).

I'm not very sure about the strategy for implementing this task. Are all images stored in the gitlab docker registry? After all, docker-compose can have several dependent containers: database, backend, web socket server, etc.
How to connect them with each other in the gitlab registry so that you can run them on the server with one command. Or is it impossible to do without an automatic cd?

I would be very glad if you share how these tasks are usually done in general. Also would be glad for useful links. I myself will google more, but I asked for help. time is running out.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Zubkov, 2021-11-22
@midia21

In short, something like this.
1. Take DB images from off repository, upload only configuration files if required via docker-compose.
2. Collect the application image either on shared runners or on your own runner.
3. Push the assembled image to the gitlab repository.
4. On the server where to deploy the gitlab runner, attach a tag to it.
5. Specify gitlab repository/imagename:tag as image in docker compose
6. Add 2 stages in gitlab ci. 1 is building and pushing docker images, 2 is running on installed runner docker-compose up -d

A
Artyom Brykin, 2021-12-02
@MindPhaser34

as an example, you can take something here.
https://github.com/MindPhaser34/my-portfolio/tree/...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question