mirror of
https://github.com/yiisoft/yii2-app-advanced.git
synced 2026-02-20 01:21:23 +01:00
Added minimal Docker setup (#347)
This commit is contained in:
committed by
Alexander Makarov
parent
0d38cf0de9
commit
fa751a34e4
4
backend/Dockerfile
Normal file
4
backend/Dockerfile
Normal file
@@ -0,0 +1,4 @@
|
||||
FROM yiisoftware/yii2-php:7.2-apache
|
||||
|
||||
# Create a symlink for apache (if `/var/www/html` is available)
|
||||
RUN rm -rf /var/www/html && ln -s /app/backend/web/ /var/www/html || true
|
||||
38
docker-compose.yml
Normal file
38
docker-compose.yml
Normal file
@@ -0,0 +1,38 @@
|
||||
version: '3.2'
|
||||
|
||||
services:
|
||||
|
||||
frontend:
|
||||
build: frontend
|
||||
ports:
|
||||
- 20080:80
|
||||
volumes:
|
||||
# Re-use local composer cache via host-volume
|
||||
- ~/.composer-docker/cache:/root/.composer/cache:delegated
|
||||
# Mount source-code for development
|
||||
- ./:/app
|
||||
|
||||
backend:
|
||||
build: backend
|
||||
ports:
|
||||
- 21080:80
|
||||
volumes:
|
||||
# Re-use local composer cache via host-volume
|
||||
- ~/.composer-docker/cache:/root/.composer/cache:delegated
|
||||
# Mount source-code for development
|
||||
- ./:/app
|
||||
|
||||
mysql:
|
||||
image: mysql:5.7
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=verysecret
|
||||
- MYSQL_DATABASE=yii2advanced
|
||||
- MYSQL_USER=yii2advanced
|
||||
- MYSQL_PASSWORD=secret
|
||||
|
||||
#pgsql:
|
||||
# image: postgres:9.5
|
||||
# environment:
|
||||
# - POSTGRES_DB=yii2advanced
|
||||
# - POSTGRES_USER=yii2advanced
|
||||
# - POSTGRES_PASSWORD=secret
|
||||
@@ -280,3 +280,41 @@ That's all. You just need to wait for completion! After that you can access proj
|
||||
* frontend: http://y2aa-frontend.test
|
||||
* backend: http://y2aa-backend.test
|
||||
|
||||
|
||||
### Installing using Docker
|
||||
|
||||
Install the application dependencies
|
||||
|
||||
docker-compose run --rm backend composer install
|
||||
|
||||
Initialize the application by running the `init` command within a container
|
||||
|
||||
docker-compose run --rm backend /app/init
|
||||
|
||||
Add a database service like and adjust the components['db'] configuration in `common/config/main-local.php` accordingly.
|
||||
|
||||
'dsn' => 'mysql:host=mysql;dbname=yii2advanced',
|
||||
'username' => 'yii2advanced',
|
||||
'password' => 'secret',
|
||||
|
||||
> Docker networking creates a DNS entry for the host `mysql` available from your `backend` and `frontend` containers.
|
||||
|
||||
> If you want to use another database, such a Postgres, uncomment the corresponding section in `docker-compose.yml` and update your database connection.
|
||||
|
||||
> 'dsn' => 'pgsql:host=pgsql;dbname=yii2advanced',
|
||||
|
||||
For more information about Docker setup please visit the [guide](http://www.yiiframework.com/doc-2.0/guide-index.html).
|
||||
|
||||
Run the migrations
|
||||
|
||||
docker-compose run --rm backend yii migrate
|
||||
|
||||
Start the application
|
||||
|
||||
docker-compose up -d
|
||||
|
||||
Access it in your brower by opening
|
||||
|
||||
- frontend: http://127.0.0.1:20080
|
||||
- backend: http://127.0.0.1:21080
|
||||
|
||||
|
||||
4
frontend/Dockerfile
Normal file
4
frontend/Dockerfile
Normal file
@@ -0,0 +1,4 @@
|
||||
FROM yiisoftware/yii2-php:7.2-apache
|
||||
|
||||
# Create a symlink for apache (if `/var/www/html` is available)
|
||||
RUN rm -rf /var/www/html && ln -s /app/frontend/web/ /var/www/html || true
|
||||
Reference in New Issue
Block a user