Skip to content

Commit 214f9c4

Browse files
author
May
authored
Merge pull request #16 from MayMeow/dev/update-dev-environment
Updated dev environment docker-compose files to use FPM+NGINX instead of built-in PHP server
2 parents d66720b + 0f51052 commit 214f9c4

File tree

10 files changed

+92
-83
lines changed

10 files changed

+92
-83
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
# Debug
22
# -----
3-
DEBUG=true
3+
DEBUG=true # IMPORTANT: Disable this for production environment
44

55
# App settings
66
# -----------------------
77
# Define your own salt or app will use generated one
88
# SECURITY_SALT=
9-
DB_HOST=cake-db
10-
DB_PASSWORD=cakepass
9+
DB_HOST=db
10+
DB_PASSWORD=cakepass # Change password for production environment
1111
DB_NAME=cake
1212
DB_USER=cake
1313

1414
# Redis
1515
# -----
16-
REDIS_HOST=cake-redis
16+
REDIS_HOST=redis
1717
REDIS_PORT=6379
1818

1919
# Database
2020
# --------
21-
POSTGRES_PASSWORD=cakepass
21+
POSTGRES_PASSWORD=cakepass # Change password for production environment
2222
POSTGRES_USER=cake
2323
POSTGRES_DB=cake

.env.example

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Debug
2+
# -----
3+
DEBUG=true # IMPORTANT: Disable this for production environment
4+
5+
# App settings
6+
# -----------------------
7+
# Define your own salt or app will use generated one
8+
# SECURITY_SALT=
9+
DB_HOST=db
10+
DB_PASSWORD=cakepass # Change password for production environment
11+
DB_NAME=cake
12+
DB_USER=cake
13+
14+
# Redis
15+
# -----
16+
REDIS_HOST=redis
17+
REDIS_PORT=6379
18+
19+
# Database
20+
# --------
21+
POSTGRES_PASSWORD=cakepass # Change password for production environment
22+
POSTGRES_USER=cake
23+
POSTGRES_DB=cake

.env.production.sample

Lines changed: 0 additions & 22 deletions
This file was deleted.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ Services contained for dev environment in `docker-compose.dev.yml`
1414

1515
|Service|Ports|Description|
1616
|----|----|----|
17-
|Cakephp App|8765|Your application|
18-
|Adminer|8080|Database management tool|
19-
|Postgres|5432 not exposed|Database server|
20-
|Redis|6379 not exposed|Cache server|
17+
|Your App|8080|Your application|
18+
|Adminer|8081|Database management tool|
19+
|Postgres|5432 not exposed in production environment|Database server|
20+
|Redis|6379 not exposed in production environment|Cache server|
2121
|Minio| 9000 (Api), 9001 (Console)|S3 compatible storage server|
2222

2323
## Installation

docker-compose.dev.yml

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,67 @@
11
version: "3.7"
22

33
services:
4-
cake-app:
4+
nginx:
55
build:
6-
args:
7-
user: cake
8-
uid: 1000
9-
context: ./
10-
dockerfile: ./vendor/maymeow/sail/sdk/8.0/Dockerfile
11-
# image: ghcr.io/maymeow/cake-notify/cake-notify:latest
12-
command: bash -c "composer install && php bin/cake.php server -H 0.0.0.0"
13-
env_file: .env.dev
14-
working_dir: /var/www/
15-
networks:
16-
- cake
6+
context: ./docker/nginx
7+
dockerfile: Dockerfile
8+
volumes_from:
9+
- app
1710
ports:
18-
- "8765:8765"
11+
- "8080:80"
12+
restart: unless-stopped
13+
depends_on:
14+
- app
15+
- db
16+
- redis
17+
18+
composer:
19+
image: ghcr.io/maymeow/php/sdk:8.1.6
20+
user: "1000:1000"
21+
working_dir: /var/www/
22+
command: bash -c "composer install"
23+
depends_on:
24+
- db
25+
- redis
26+
volumes:
27+
- ./:/var/www
28+
29+
app:
30+
image: ghcr.io/maymeow/php/runtime:8.1.6
31+
user: "1000:1000"
32+
env_file: .env
33+
restart: unless-stopped
34+
working_dir: /var/www/
1935
depends_on:
20-
- cake-db
21-
- cake-redis
36+
- db
37+
- redis
2238
volumes:
2339
- ./:/var/www
2440

25-
cake-db:
41+
db:
2642
image: postgres:12.4
27-
networks:
28-
- cake
29-
# ports:
30-
# - "5432:5432"
43+
ports:
44+
- "5432:5432"
3145
volumes:
3246
- cake_data:/var/lib/postgresql/data
33-
env_file: .env.dev
47+
env_file: .env
3448

35-
cake-redis:
49+
redis:
3650
image: "redis:alpine"
37-
networks:
38-
- cake
3951
volumes:
4052
- cake_redis:/data
4153

4254
# if you need graphic acces to application database
4355
adminer:
4456
image: adminer
45-
networks:
46-
- cake
4757
ports:
48-
- "8080:8080"
58+
- "8081:8080"
4959

5060
minio:
5161
image: minio/minio:RELEASE.2021-08-05T22-01-19Z
52-
networks:
53-
- cake
5462
volumes:
5563
- minio_data:/data
56-
env_file: .env.dev
64+
env_file: .env
5765
command: server /data --console-address :9001
5866
ports:
5967
- "9000:9000"

docker-compose.prod.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ services:
1515
context: ./
1616
dockerfile: ./docker/app/Dockerfile
1717
# image: ghcr.io/maymeow/cake-notify/cake-notify:latest
18-
env_file: .env.production
18+
env_file: .env
1919
container_name: app
2020
restart: unless-stopped
2121
working_dir: /var/www/
@@ -27,6 +27,8 @@ services:
2727
- redis
2828
volumes:
2929
- /var/www
30+
# For sqlite uncomment following line
31+
# - ./app.sq3:/app.sq3
3032

3133
db:
3234
image: postgres:12.4
@@ -36,7 +38,7 @@ services:
3638
restart: unless-stopped
3739
volumes:
3840
- ./data/db:/var/lib/postgresql/data
39-
env_file: .env.production
41+
env_file: .env
4042

4143
nginx:
4244
build:
@@ -77,3 +79,17 @@ services:
7779
# networks:
7880
# - frontend
7981
# restart: unless-stopped
82+
83+
# If you need/want use minio S3 storage uncomment following
84+
# minio:
85+
# image: minio/minio:RELEASE.2021-08-05T22-01-19Z
86+
# volumes:
87+
# - minio_data:/data
88+
# env_file: .env
89+
# networks:
90+
# - cake_backend
91+
# command: server /data --console-address :9001
92+
# Optional: uncomment if you want to expose ports
93+
# ports:
94+
# - "9000:9000"
95+
# - "9001:9001"

docker/app/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ghcr.io/maymeow/php-ci-cd/php-ci-cd:8.1.6-cs-git-psalm AS build-env
1+
FROM ghcr.io/maymeow/php/sdk:8.1.6 AS build-env
22

33
WORKDIR /app
44

@@ -7,7 +7,7 @@ COPY . /app
77
## uncomment --no-scripts if you want to remove composer postinstallation scripts
88
RUN composer install --no-ansi --no-dev --no-interaction --no-plugins --no-progress --optimize-autoloader #--no-scripts
99

10-
FROM ghcr.io/maymeow/webapp-base/webapp-base:8.1.6
10+
FROM ghcr.io/maymeow/php/runtime:8.1.6
1111

1212
ARG user=www-data
1313

docker/devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ghcr.io/maymeow/php-ci-cd/php-ci-cd:8.1.6-cs-git-psalm
1+
FROM ghcr.io/maymeow/php/sdk:8.1.6
22

33
# arguments in docker-compose file
44
ARG user=vscode

docker/devcontainer/php8.Dockerfile

Lines changed: 0 additions & 16 deletions
This file was deleted.

docker/nginx/nginx.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ server {
1717
location ~ \.php$ {
1818
try_files $uri =404;
1919
fastcgi_split_path_info ^(.+\.php)(/.+)$;
20-
fastcgi_pass cakenotify_app:9000;
20+
fastcgi_pass app:9000;
2121
fastcgi_index index.php;
2222
include fastcgi_params;
2323
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

0 commit comments

Comments
 (0)