简体   繁体   中英

Integrate Grunt in docker-compose?

I have two docker compose files that I start with docker-compose f- docker-compose.yml -f docker-compose-osx.yml up

The file contents is:

docker-compose.yml:

version: '2'
services:
    fpm:
        image: sbusso/php-fpm-ion
    nginx:
        image: nginx:stable
        ports:
            - "80:80"
        links:
            - fpm
            - db
    db:
        image: orchardup/mysql
        ports:
            - 3306:3306
        environment:
            MYSQL_ROOT_PASSWORD: root
            MYSQL_DATABASE: myproject

and

docker-compose-osx.yml

version: '2'
services:
    fpm:
        links:
            - sync
        volumes_from:
            - sync
    db:
        links:
            - sync
        volumes_from:
            - sync
    nginx:
        links:
            - sync
        volumes_from:
            - sync
    sync:
        image: zeroboh/lsyncd
        volumes:
            - /var/www/html
            - ./src:/src:Z
            - ./docker-config/nginx:/etc/nginx/conf.d
            - /var/lib/php/session
            - ./docker-config/lrsync/lrsync.lua:/etc/lrsync/lrsync.lua
            - ./sync:/sync

Usually when I connect to my fpm container I need to run grunt, but grunt and npm are not known to my docker container.

How can I integrate grunt here in my docker-compose files?

Thanks!

You fpm container ( sbusso/php-fpm-ion ) doesn't have grunt and npm installed (neither its base image). You can see that by reading the Dockerfile here .

sbusso/php-fpm-ion is based on sbusso/php-fpm which is based on debian:jessie . You can install npm and grunt as if you were on any Debian system. The npm version available in debian packages is quite old, you should see their installation guide on the website and then install grunt with npm install -g grunt-cli

Keep in mind that containers are isolated from the host, they cannot share neither file nor binaries. Even if you have npm and grunt installed on your host, your container cannot launch them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM