Skip to content

Commit e689c80

Browse files
committed
improve docker stack
1 parent 7f062f3 commit e689c80

File tree

6 files changed

+31
-8
lines changed

6 files changed

+31
-8
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ bash: cli
4545
cli:
4646
$(DOCKER) bash
4747

48-
start-docker: config/components-dev.local.php config/components-test.local.php backend/config/cookie-validation.key env.php stop
48+
start-docker: runtime/build-docker config/components-dev.local.php config/components-test.local.php backend/config/cookie-validation.key env.php stop
4949
docker-compose up -d
5050
docker-compose exec -T backend-php bash -c "grep '^$(shell whoami):' /etc/passwd || useradd -m '$(shell whoami)' --uid=$(shell id -u) -G www-data -s /bin/bash"
5151
docker-compose exec -T backend-php bash -c "sed -i 's/#force_color_prompt=yes/force_color_prompt=yes/' /home/$(shell whoami)/.bashrc && sed -i 's~etc/bash_completion~etc/bash_completion.d/yii~' /home/$(shell whoami)/.bashrc"
@@ -60,6 +60,10 @@ start-docker: config/components-dev.local.php config/components-test.local.php b
6060
stop-docker:
6161
docker-compose down
6262

63+
runtime/build-docker: */Dockerfile
64+
docker-compose build
65+
touch $@
66+
6367
# copy config files if they do not exist
6468
config/components-%.local.php: config/components-ENV.local.php
6569
test -f $@ || cp $< $@

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ You can now continue with [generating code](#generate-code).
6262
### Using Docker
6363

6464
You need [Docker](https://docs.docker.com/install/) and [Docker Compose](https://docs.docker.com/compose/install/) installed.
65+
66+
Create the repository:
67+
68+
composer create-project cebe/yii2-app-api my-api
69+
6570
For the easiest way you need GNU make, then run:
6671

6772
make start-docker

api/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
FROM yiisoftware/yii2-php:7.4-apache
22

3+
# install git and unzip for composer install dist/source
4+
RUN apt-get update && apt-get -y install git unzip && apt-get clean && rm -rf /var/lib/apt/lists/*
5+
36
COPY config/apache.conf /etc/apache2/sites-enabled/000-default.conf

backend/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
FROM yiisoftware/yii2-php:7.4-apache
22

3+
# install git and unzip for composer install dist/source
4+
RUN apt-get update && apt-get -y install git unzip && apt-get clean && rm -rf /var/lib/apt/lists/*
5+
36
COPY config/apache.conf /etc/apache2/sites-enabled/000-default.conf

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"php": ">=7.1.0",
88
"yiisoft/yii2": "~2.0.16",
99
"cebe/php-openapi": "^1.1",
10-
"cebe/yii2-openapi": "^2.0@alpha",
10+
"cebe/yii2-openapi": "^2.0@beta",
1111
"yiisoft/yii2-gii": "^2.1"
1212
},
1313
"autoload": {

docker-compose.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ services:
1111
volumes:
1212
# Mount source-code for development
1313
- ./:/app
14+
depends_on:
15+
- db
16+
- redis
17+
- mailcatcher
1418

1519
backend-php:
1620
build: backend
@@ -21,19 +25,23 @@ services:
2125
- ~/.composer-docker/cache:/root/.composer/cache:delegated
2226
# Mount source-code for development
2327
- ./:/app
28+
depends_on:
29+
- db
30+
- redis
31+
- mailcatcher
2432

2533
db:
26-
image: mysql:5.7
34+
image: mariadb:10.8
2735
environment:
28-
#- MYSQL_ROOT_PASSWORD=verysecret
29-
- MYSQL_DATABASE=api_db
30-
- MYSQL_USER=api
31-
- MYSQL_PASSWORD=apisecret
36+
- MARIADB_ROOT_PASSWORD=verysecret
37+
- MARIADB_DATABASE=api_db
38+
- MARIADB_USER=api
39+
- MARIADB_PASSWORD=apisecret
3240

3341
redis:
3442
image: redis:3
3543

3644
mailcatcher:
3745
image: nisenabe/mailcatcher
3846
ports:
39-
- '80'
47+
- '8055:1080'

0 commit comments

Comments
 (0)