'How to use docker-compose from another person?

I'm pretty new to the world of Docker, so I have the following scenario:

  • Spring Boot application which depends to..
  • PostgreSQL

and frontend requesting data from them.

The Dockerfile in the Spring Boot app is:

EXPOSE 8080
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]

And the content of the docker-compose.yaml is:

version: '3'

services:
  app:
    image: <user>/<repo>
    build: .
    ports:
      - "8080:8080"
    container_name: app_test
    depends_on:
      - db
    environment:
      - SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/test
      - SPRING_DATASOURCE_USERNAME=test
      - SPRING_DATASOURCE_PASSWORD=test

  db:
    image: 'postgres:13.1-alpine'
    restart: always
    expose:
      - 5432
    ports:
      - "5433:5432"
    container_name: db_test
    environment:
      - POSTGRES_DB=test
      - POSTGRES_USER=test
      - POSTGRES_PASSWORD=test
    volumes:
      - db:/var/lib/postgresql/data
      - ./create-tables.sql:/docker-entrypoint-initdb.d/create-tables.sql
      - ./fill_tables.sql:/docker-entrypoint-initdb.d/fill_tables.sql
volumes:
    db:
      driver: local

As far as I understand in order to run the whole thing is required just to type docker-compose up and voila, it works. It pulls the image for the app from the docker-hub repo and same does for the image for the database.

Here comes the thing. I'm working with another guy (front end), whose goal is to make requests to this API. So is it enough for him to just copy-paste this docker-compose.yaml file and write docker-compose up or there is another thing to be done?

How should docker-compose be used in teamwork?

Thanks in advance, if I have to make it more clear leave a comment!



Solution 1:[1]

Because of the build: . keyword in your docker-compose in api service, running docker-compose up will search for the backend Dockerfile and build the image. So, your teammate needs to get all the files you wrote.
Another solution, which in my point of view is better, would be building the image by you and pushing it to docker.hub, so your teammate can just pull the image from there and run it on his/her system. For this solution, this could be useful.
In case your not familiar with docker hub, read this quick start

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mohammad hosein bahmani