Yii2: Create an "official" Yii2 Docker image

Created on 7 Mar 2017  Â·  12Comments  Â·  Source: yiisoft/yii2

What steps will reproduce the problem?

Go on Docker Hub and search for yiisoft/yi2...

What is the expected result?

Find an "official" image.

What do you get instead?

Nothing ;)

Additional info

| Q | A
| ---------------- | ---
| Yii version | any
| PHP version | any
| Operating system | Docker

For details, see https://github.com/codemix/yii2-dockerbase/issues/6


We need to define which extensions should be on that (PHP)-image and also which tests would have to run and which PHP versions we might support; it should also be used for the dockerized tests.

enhancement

Most helpful comment

I'd build it with nginx + php-fpm instead of Apache.

All 12 comments

To give a rough summary:

We think there should be a minimalistic PHP docker image, that mainly fullfills the yii2 requirements - not much more. The images would include:

  • PHP extensions required by yii
  • minimal webserver config where it makes sense, e.g. for apache based images
  • arguably: opcache and APC

We should not even include a DB driver, as we can't know which DBMS will be used and we don't want to bloat the image with unused features.

I'd suggest to have a simple image name like yii2-php or php-yii2 (docker-yii2-php or docker-php-yii2 on github respectively). We'd then have a yiisoft/yii2-php image for each official PHP image (e.g. yiisoft/yii2-php:7.1.2-alpine). They would be the basis for:

  • Project specific yii2 images
  • More "full-featured" yii2-base images, published by others
  • Tests?

There should be instructions for how to extend from the images to

  • Add more PHP extensions
  • Override PHP configuration
  • Override Webserver configuration (if included)

We could maintain such a project but it should happen under the yiisoft namespace, both on github and docker hub.

sounds good. Having it minimalistic will also save maintenance

I'd build it with nginx + php-fpm instead of Apache.

OpCache enabled — yes. APC — no since it will be PHP 7.1.

Bundling DB drivers is OK. It's not bloating image much as far as I know.

I can allocate a separate repository within yiisoft for that. @mikehaertl, @schmunk42 do you want to work on it there?

Bundling DB drivers is OK. It's not bloating image much as far as I know.

It depends a bit on the driver, but basically yes. Stuff like XML or Intl weights much more.

SQLite is already on the image I think - it's a PHP default since a while. But people should be careful, when using it with Docker.

I'd also add MySQL and PostGre drivers, because of the "80/20" rule.

I can allocate a separate repository within yiisoft for that. @mikehaertl, @schmunk42 do you want to work on it there?

Would make sense I think, but just to have it said now - we do not add the framework code itself to the image - it's merely a preconfigured PHP.

I'd build it with nginx + php-fpm instead of Apache.

We'd have images for all official PHP images. So it's up to the developer which one you choose. php-fpm is one option.

Bundling DB drivers is OK. It's not bloating image much as far as I know.

I'm not so sure about this. There's a reason why those are not included in the official PHP images either. Less included code also means less things that can possibly break. I'd still vote to keep them out.

I also think, that almost any reasonable project will build another base image on top of what we have here anyway - adding extra extensions. At least I never had a project so far where this was not necessary.

I can allocate a separate repository within yiisoft for that. @mikehaertl, @schmunk42 do you want to work on it there?

Yes, we could also continue discussion there and already commit the parts we agree on.

OpCache enabled — yes. APC — no since it will be PHP 7.1.

As we'd also provide images for PHP < 7.1 we should at least add it there.

One more note, why php-fpm is problematic with docker is this stupid issue: https://github.com/docker-library/php/issues/207

https://github.com/yiisoft/docker. You both are invited.

Let's continue discussion there.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AstRonin picture AstRonin  Â·  3Comments

indicalabs picture indicalabs  Â·  3Comments

MUTOgen picture MUTOgen  Â·  3Comments

psfpro picture psfpro  Â·  3Comments

sobit picture sobit  Â·  3Comments