GithubHelp home page GithubHelp logo

Comments (8)

RobLoach avatar RobLoach commented on June 30, 2024 25
  1. Add a Composer service, mounting the volumes:

    composer:
        image: composer/composer
        volumes_from: php-fpm
        working_dir: /var/www/html
  2. Run Composer through docker-compose:

    docker-compose run composer install
    

from docker-composer.

RobLoach avatar RobLoach commented on June 30, 2024

Do you have either a Dockerfile or docker-compose.yml that you could send over to test? The idea is here is that you mount the volumes across the containers, and then run Composer through the Composer container.

from docker-composer.

meotimdihia avatar meotimdihia commented on June 30, 2024

I am using this docker-compose.yml:

version: '2'
services:
    php-fpm:
        build:
            context: ./php-fpm
        image: plf_php-fpm:5.6
        links:
            - mysql:mysql
            - redis:redis
        environment:
            - MYSQL_HOST=mysql
            - MYSQL_USER=platform-admin
            - MYSQL_PASSWORD=platform123
            - MYSQL_DATABASE=platform
            - REDIS_HOST=redis            
        depends_on:
            - redis
            - mysql
        volumes:
            - ../src/:/var/www/html/
            - ./php-fpm/www.conf:/usr/local/etc/php-fpm.d/www.conf
    nginx:
        image: nginx:1.7.10
        ports:
            - 8080:80
        links:
            - php-fpm:php-fpm
        volumes_from:
            - php-fpm
        volumes:
            - ./nginx/conf.d/:/etc/nginx/conf.d/
        depends_on:
            - php-fpm
    mysql:
        build:
            context: ./mysql
        image: meotimdihia/plf_mysql:5.7
        volumes:
            - ./mysql/data:/var/lib/mysql
            - ./mysql/import/dump.sql:/tmp/dump.sql
        environment:
            - MYSQL_ROOT_PASSWORD=admin
            - MYSQL_USER=platform-admin
            - MYSQL_PASSWORD=platform123
            - MYSQL_DATABASE=platform
    redis:
        image: redis:3-alpine
    jenkins:
        image: jenkins:2.3
        ports:
            - 8060:8080
            - 50000:50000
        volumes:
            - ./jenkins/home:/var/jenkins_home
            - ../src/:/var/www/html/

My workflow is like this:

  • Push my code to github repository
  • Github webhook request to my Jenkins container URL
  • Jenkins container pull github repository
    -run Composer install at here .
  • Build test and deploy code

But how to execute composer install container here ?
Now i recognize this problem should be at docker groups. But if you can suggest me , its a big help. :)

from docker-composer.

meotimdihia avatar meotimdihia commented on June 30, 2024

We can run docker-composer on host machine , but i wonder we can execute composer install in Jenkins container , because i need to execute automatically composer install.

In real my case i am trying to setup on kubernetes (google container engine) and docker-compose on localhost.

from docker-composer.

RobLoach avatar RobLoach commented on June 30, 2024

Another solution is to change the entrypoint and command and make your own script to run Composer install when the service starts.

from docker-composer.

meotimdihia avatar meotimdihia commented on June 30, 2024

thx for your answer, after some research in docker's documention, i see docker remote API :
https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/exec-create
And
kubernetes API :
http://kubernetes.io/kubernetes/third_party/swagger-ui/#!/api%2Fv1/connectPostNamespacedPodExec

i will try to follow this direction: Jenkin's container will call remote API to execute a command in Composer's container.

I close this issue, thank you once again.

from docker-composer.

delmicio avatar delmicio commented on June 30, 2024

@RobLoach I've been trying the past two days to include auto composer commands in my docker-compose file and failing.
Could you share with us your solution if you have got one.

version: "3"

services:
  composer:
    image: composer/composer:php5-alpine
    volumes:
      - ./app/:/app
    command: ["install --ignore-platform-reqs", "dump-autoload --optimize"]

from docker-composer.

harriswong avatar harriswong commented on June 30, 2024

@delmicio

  1. Make sure your /app folder has a composer.json.
  2. Try the working_dir as per #88 (comment).

from docker-composer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.