Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added minimal Docker setup #347

Merged
merged 5 commits into from Jan 15, 2019
Merged

Conversation

schmunk42
Copy link
Contributor

@schmunk42 schmunk42 commented Mar 7, 2018

Q A
Is bugfix? yes/no
New feature? yes
Breaks BC? no
Tests pass? there are none
Fixed issues #214, #244

Related: yiisoft/yii2-docker#28 (comment), #250

@sazo
Copy link

sazo commented Mar 7, 2018

Its simple and achieves the same as #250 👍

What is the reason the db is not included and only in the guide?

IMO the jwilder/nginx-proxy:alpine container is really nice - because when redirecting between frontend and backend i dont think it will redirect to the right port? correct me if im wrong.

Otherwise looks good and simple 👍

@schmunk42
Copy link
Contributor Author

What is the reason the db is not included and only in the guide?

You could choose MySQL (Percona/MariaDB) or PostGres or SQLite or another one Yii supports; although docs could be more detailed how to use different ones; but the guide also does not cover MySQL installation and setup ie.

IMO the jwilder/nginx-proxy:alpine container is really nice - because when redirecting between frontend and backend i dont think it will redirect to the right port? correct me if im wrong.

It serves as a proxy so it would not redirect. But there are other things to consider:

  1. you need to set up hostnames or wildcard DNS (or use .localhost)
  2. for the reverse proxy to make sense you should only have one for your Docker machine, which means it should be moved out of the project, which leads to a special setup for configuring Docker networks, this can be painful and error-prone. The best working out-of-the-box solution for local development (not CI) are fixed ports (a different set per project) IMHO

@samdark samdark mentioned this pull request Mar 7, 2018
@samdark samdark added the type:enhancement Enhancement label Mar 7, 2018
@samdark samdark added this to the 2.0.14.1 milestone Mar 7, 2018
@schmunk42
Copy link
Contributor Author

How should we proceed with this? I think there should be some more info about db setup.

Should we add MySQL by default or PostGres or both, or something to the docs how to do that?

Here or in the guide?

@samdark
Copy link
Member

samdark commented Mar 22, 2018

I think there should be some more info about db setup.

Definitely.

@samdark
Copy link
Member

samdark commented Mar 22, 2018

Should we add MySQL by default or PostGres or both, or something to the docs how to do that?

MySQL by default + docs about PostgreSQL

1 similar comment
@samdark
Copy link
Member

samdark commented Mar 22, 2018

Should we add MySQL by default or PostGres or both, or something to the docs how to do that?

MySQL by default + docs about PostgreSQL

@samdark
Copy link
Member

samdark commented Mar 22, 2018

Here or in the guide?

Here commented out in config?

@schmunk42
Copy link
Contributor Author

Done.

@cebe cebe modified the milestones: 2.0.14.1, 2.0.15 Apr 11, 2018
@machour
Copy link
Member

machour commented Jan 15, 2019

@schmunk42 is there anything missing for this PR to get merged?

@schmunk42
Copy link
Contributor Author

@machour nothing missing that I could remember...

@samdark samdark merged commit fa751a3 into yiisoft:master Jan 15, 2019
@samdark
Copy link
Member

samdark commented Jan 15, 2019

Merged. Thanks!

@creep3r
Copy link

creep3r commented Jan 29, 2019

Hi, I managed getting advanced template working via docker. But I had to do two more steps next to those documented in start-installation.md, to get apache environment working properly.

  1. change mount point to /app/web as in yii2-docker package
  2. run apache as UID 1000 to fix asset publishing

Is this supposed to work out of the box? Maybe it's MacOS related issue?
(Tested on fresh docker installation + macos 10.13.6, will check on other systems later)

@schmunk42
Copy link
Contributor Author

@creep3r Do you run DockerForMac, a VM with docker-machine or something else?

@creep3r
Copy link

creep3r commented Jan 29, 2019

@schmunk42 Oh yes, Im running docker-machine on virtualbox instance.

@schmunk42
Copy link
Contributor Author

Would it work for you to give permissions to the asset-folder on the host?

@creep3r
Copy link

creep3r commented Jan 30, 2019

I did test also on native DockerForMac fresh installation.

  1. this persist, because of default yii2-docker apache vhost config
  2. it seems to be issue related to docker-machine + virtualbox setup. perhaps could be mentioned in docs?

@billyshen26
Copy link

hi @schmunk42 ,
any advice to write a Dockerfile for console service, i want to run schedule in docker, thanks in advance.

Billy

@schmunk42
Copy link
Contributor Author

My advice would be to run to scheduler in the same container as your web-server, eg. with supervisord - see https://github.com/dmstr/docker-php-yii2/blob/release/6.x/nginx/Dockerfile-fpm-nginx for an example.

Although this is not 100% Docker-one-service-per-container, we found this to be less error-prone than a separate container - which might be useful for very CPU and/or IO-heavy jobs.

Also keep in mind that you need to export your ENVs for scheduler, see https://github.com/dmstr/phd5-app/blob/master/image-files/usr/local/bin/export-env.sh for an example (it's ugly, but we haven't found anything better yet).

We are running one cronjob once per minute which triggers the scheduler, see also https://github.com/dmstr/phd5-app/blob/master/src/config/schedule.php

@phdabel
Copy link

phdabel commented May 31, 2021

Hi, I worked on a docker solution for Yii2 advanced template some time ago.
I needed to work with SSL, thus the script generates self-signed certificates for testing.

Yii2, php7.4-fpm + nginx + postgresql

A problem with my approach is that it requires building the container using a bash script build.sh to generate the certificate and other configurations instead of using docker-compose directly.

Anyway, it works well and from this, I worked on a new solution combined with supervisord for another application. This solution was created for a development environment and uses Redis as a cache DB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:enhancement Enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants