Access project files from another project in GitLab server

Hello,
A website consists of several microservices as follows:

The names of the projects are something like the following:

Project-1/admin
Project-2/Banner
Project-3/Contractor
Project-4/Core

There is a Dockerfile in each project.

I want to create a project called Final and put the docker-compose.yml file in it. The content of the file is something like the following:

version: '3'

services:
  Project-1:
    container_name: Admin
    build:
      context: ./Project-1/admin
      dockerfile: Dockerfile
    ports:
      - "3000:3000"
    environment:
      - PORT=3000
      - MESSAGE_BUS=amqp://rabbitmq
    links:
      - rabbitmq
  
  Project-2:
    container_name: Banner
    build:
      context: ./Project-2/Banner
      dockerfile: Dockerfile
    ports:
      - "3001:3000"
    environment:
      - PORT=3000
      - MESSAGE_BUS=amqp://rabbitmq
    links:
      - rabbitmq
...

My question is, can projects see each other’s files? Can the Final project see the Dockerfile in Project-1 through context: ./Project-1/admin line?

Thank you.

If you check them all out locally, sure you can. It’s just files, if the paths from one project to another is correct it can see it.

Hello,
Thank you so much for your reply.
For testing, I created two projects called Test and Test1. In the Test project, I have a docker-compose.yml file as follows:

services:
  test:
    container_name: test
    build:
      context: ./test
      dockerfile: Dockerfile
    ports:
      - "3000:3000"
    environment:
      - PORT=3000
      - MESSAGE_BUS=amqp://rabbitmq
    links:
      - rabbitmq
  test1:
    container_name: test1
    build:
      context: ./test1
      dockerfile: Dockerfile
    ports:
      - "3001:3000"
    environment:
      - PORT=3000
      - MESSAGE_BUS=amqp://rabbitmq
    links:
      - rabbitmq

When I run the runner, I get the following error message:

unable to prepare context: path "/home/gitlab-runner/builds/xVRvcJHhY/0/hack3rcon/test/test1" not found
ERROR: Job failed: exit status 1

This means that the Test project cannot see the Test1 project.

That’s why I said

If you want to do this in a runner you’d have to check out other repositories as well.

Though I’m not sure what a docker compose file is doing in a runner. What are you trying to do?

1 Like

Hi,
Thanks again.
I want to have all projects files in a directory at the destination.

What destination? Again, a Gitlab runner is not (I repeat, NOT) meant to host your website. It is meant to run automated tests on your code, create docker images, and deploy those docker images.

Once more with feeling: a Github runner is not meant to host your website.

1 Like

And only to make it complete.

A Gitlab server is also not meant to host your website….

2 Likes

I feel a song coming on :grin:

1 Like

Hi,
Thanks again.
I have two servers:

GitLab Server : Hosting codes
GitLab Runner : Runner + Docker 

Destination == A directory in the GitLab Runner Server

But why do you need it there? What are you trying to do?

Hello,
Because I want to run those codes through the Node.js container on the GitLab Runner server.

Another try.

You cannot run code on the gitlab runner server. Even if it is called runner it is not running your code.

You need a third server which is hosting the code you want to run.

Maybe you should start with a little bit more basics like installing node on a server and run one single nodeJS project on it before trying to build multiple docker container with separated microservices…

For me it looks like you are trying change the cylinder head gasket of your car but do not even know how to open the engine hood.

1 Like

Hi,
Thank you so much for your reply.
Docker has been installed on the GitLab Runner server and the Node.js image has been downloaded. I meant the container running on the GitLab Runner server to run those codes. Is this clear?