S
S
Steely2017-07-17 13:43:53
Composer
Steely, 2017-07-17 13:43:53

How does composer work in a docker container?

Actually there are two containers, base and php with scripts.
The question is, how to work with Composer manager in docker containers? Those. I put it in a container with PHP and then I need to run the composer update command manually or write it in the Dockerfile? And where to put the ssh key to access github?
In general, I have problems with the design, help me how to properly organize the work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2017-07-17
@sergiks

For project files, make a separate container project_files, which can then be connected to php through an --volumes-from project_files
Sample Dockerfile for this container:

FROM ubuntu

RUN apt-get update  &&  apt-get install -y git

RUN mkdir /root/.ssh/

COPY id_rsa /root/.ssh/id_rsa

# Add bitbuckets key
RUN ssh-keyscan bitbucket.org >> /root/.ssh/known_hosts

# CLone repo
RUN git clone [email protected]:username/projectname.git /project_files

# Create volume
VOLUME /project_files

Put yours in your Dockerfile folder id_rsaand build docker build -t myproject/files .and create a container
docker create --name project_files myproject/files /bin/true

There is an official docker image composer : docker pull composer/composer You need to run it and install the dependencies of your project by connecting the container with the project files:
Now in your container with files, a complete set to start.
Connect the container with project files to the container with PHP using the same --volumes-from:
docker run \
  --name myproject_php \
  --volumes-from project_files \
  php:5-fpm

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question