R
R
Romi2021-03-28 21:43:09
Docker
Romi, 2021-03-28 21:43:09

How do I add Composer (which is PHP) to a Docker Compose container (in a docker-compose.yml file)?

I cloned the Docker Compose container, but the problem is that to start the project I need to run

composer install

and I don’t have it installed locally (100500 PHP extensions need to be configured there).

Is there any way to add it to the container? How exactly?

Here is docker-compose.yml

version: '3.2'

networks:
  movies:
    driver: bridge

services:
  api:
    build:
      context: .
      dockerfile: Dockerfile
      args:
        - WITH_XDEBUG=true
    networks:
      - movies
    volumes:
      - .:/opt/project
    depends_on:
      - neo4j
    restart: always
    expose:
      - 9000
    environment:
      - NEO4J_USER=neo4j
      - NEO4J_PASSWORD=abcde
      - NEO4J_DATABASE=neo4j
  proxy:
    build:
      context: .
      dockerfile: proxy/Dockerfile
    networks:
      - movies
    ports:
      - "80:80"
      - "8080:8080"
    depends_on:
      - api
    restart: always
  neo4j:
    networks:
      - movies
    image: neo4j:latest
    volumes:
      - neo4j:/data
      - .:/opt/project
    environment:
      - NEO4J_AUTH=neo4j/abcde
    restart: always
    expose:
      - 7474
      - 7687
      - 6362
    ports:
      - "7474:7474"
      - "7687:7687"

volumes:
  neo4j:


Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Loli E1ON, 2021-03-28
@E1ON

You need to add it to the Dockerfile:

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

And after starting the container, go into it and run composer install

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question