How to access the files of a project from another project?

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.

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.

Accessing files from one project in GitLab from another project typically involves either directly referencing the files from the other project’s repository or utilizing GitLab’s features such as submodules or pipelines.

1 Like