-
Notifications
You must be signed in to change notification settings - Fork 51
7. FAQ
docker-compose run --rm web yii migrate
docker-compose run --rm web yii mycommand/myaction
Composer packages are installed inside the container under /var/www/vendor
.
So they live outside of the app directory. This is because during development we
usually mount the local app directory into the /var/www/html
directory of the
container. This would override any vendor packages we have there. So you would
either have to locally install all the packages in vendor/
or somehow
make sure, that the composer packages are updated after the local dir was shared.
By keeping the directory outside, we circumvent this issue. The docker images will always contain all required composer dependencies and use those at runtime.
To update or install new packages you first need an updated local composer.lock
file.
Then the next time you issue docker-compose build
it will pick up the changed
file and create a new docker image with the updated packages inside:
docker-compose run --rm web composer update my/package
docker-compose build
Note: If you face the nasty API rate limit issue with github, you can create a personal API token and expose it in your
docker-compose.yml
file asAPI_TOKEN
env var.
Some IDE's may require a copy of the vendor directory somewhere on your local host for autocompleting commands or providing inline help. You can therefore copy the vendor directory to your local directory:
docker-compose run --rm web cp -r /var/www/vendor .
The default log configuration follows the Docker convention to log to STDOUT
and STDERR
. You should better not change this for production. But you can
use a local configuration file as explained above and configure a log route
as usual. If you log to the default directory, you should find the logfiles
in your local runtime/logs/
directory. Note, that this directory will never
be copied into the container, so there's no risk, that you end up with a
bloated image.
Since the codemix/yii2-base image extends from the official php
image, you can use docker-php-ext-install
in your Dockerfile. Here's an example:
RUN apt-get update \
&& apt-get -y install \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng12-dev \
--no-install-recommends \
&& rm -r /var/lib/apt/lists/* \
&& docker-php-ext-install iconv mcrypt \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install gd
For HHVM extension please check the hhvm base image for details.