Skip to content
This repository was archived by the owner on Dec 11, 2023. It is now read-only.

Commit 8f33f0f

Browse files
committed
Add basic docker integration
1 parent 8fa1480 commit 8f33f0f

File tree

9 files changed

+160
-4
lines changed

9 files changed

+160
-4
lines changed

Dockerfile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM php:7.3.6-fpm-alpine
2+
WORKDIR /app
3+
4+
RUN apk --update upgrade \
5+
&& apk add --no-cache autoconf automake make gcc g++ icu-dev rabbitmq-c rabbitmq-c-dev \
6+
&& pecl install amqp-1.9.4 \
7+
&& pecl install apcu-5.1.17 \
8+
&& pecl install xdebug-2.7.0RC2 \
9+
&& docker-php-ext-install -j$(nproc) \
10+
bcmath \
11+
opcache \
12+
intl \
13+
pdo_mysql \
14+
&& docker-php-ext-enable \
15+
amqp \
16+
apcu \
17+
opcache
18+
19+
COPY etc/infrastructure/php/ /usr/local/etc/php/

Makefile

+46-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,48 @@
1-
.PONY: start-local
1+
.PONY: build deps composer-install composer-update composer reload test run-tests start stop destroy doco rebuild start-local
2+
3+
current-dir := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
4+
5+
build: deps start
6+
7+
deps: composer-install
8+
9+
# 🐘 Composer
10+
composer-install: CMD=install
11+
composer-update: CMD=update
12+
composer composer-install composer-update:
13+
@docker run --rm --interactive --tty --volume $(current-dir):/app --user $(id -u):$(id -g) \
14+
gsingh1/prestissimo $(CMD) \
15+
--ignore-platform-reqs \
16+
--no-ansi \
17+
--no-interaction
18+
19+
reload:
20+
@docker-compose exec php-fpm kill -USR2 1
21+
@docker-compose exec nginx nginx -s reload
22+
23+
test:
24+
@docker exec -it codelytv-cqrs_ddd_php_example-php make run-tests
25+
26+
run-tests:
27+
mkdir -p build/test_results/phpunit
28+
./vendor/bin/phpstan analyse -l 7 -c etc/phpstan/phpstan.neon applications/mooc_backend/src
29+
./vendor/bin/phpunit --exclude-group='disabled' --log-junit build/test_results/phpunit/junit.xml tests
30+
./vendor/bin/behat -p mooc_backend --format=progress -v
31+
32+
# 🐳 Docker Compose
33+
start: CMD=up -d
34+
stop: CMD=stop
35+
destroy: CMD=down
36+
37+
# Usage: `make doco CMD="ps --services"`
38+
# Usage: `make doco CMD="build --parallel --pull --force-rm --no-cache"`
39+
doco start stop destroy:
40+
@docker-compose $(CMD)
41+
42+
rebuild:
43+
docker-compose build --pull --force-rm --no-cache
44+
make deps
45+
make start
246

347
start-local:
4-
php -S localhost:8090 apps/mooc/backend/public/index.php
48+
php -S localhost:8030 apps/mooc/backend/public/index.php

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@
44

55
`composer create-project codelytv/ddd-skeleton`
66

7-
## Usage
8-
`make start-local`
7+
## Starting the server
8+
* Local using: `make start-local`
9+
* Docker using: `make build`
10+
11+
And then going to `http://localhost:8030/health-check` to check all is ok.

docker-compose.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
version: '3'
2+
3+
services:
4+
nginx:
5+
container_name: codelytv-ddd-skeleton-nginx
6+
image: nginx:1.15-alpine
7+
restart: unless-stopped
8+
ports:
9+
- "8030:80"
10+
volumes:
11+
- .:/app:delegated
12+
- ./etc/infrastructure/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
13+
depends_on:
14+
- php
15+
16+
php:
17+
container_name: codelytv-ddd-skeleton-php
18+
build:
19+
context: .
20+
dockerfile: Dockerfile
21+
restart: unless-stopped
22+
ports:
23+
- "9090:9001"
24+
volumes:
25+
- .:/app:delegated
26+
env_file:
27+
- .env

etc/infrastructure/nginx/default.conf

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
server {
2+
listen 80;
3+
server_name localhost api.codelytv.localhost;
4+
root /app/apps/mooc/backend/public;
5+
6+
error_log stderr;
7+
access_log stdout;
8+
9+
rewrite ^/index\.php/?(.*)$ /$1 permanent;
10+
11+
try_files $uri @rewriteapp;
12+
13+
location @rewriteapp {
14+
rewrite ^(.*)$ /index.php/$1 last;
15+
}
16+
17+
location ~ /\. {
18+
deny all;
19+
}
20+
21+
location ~ ^/(index)\.php(/|$) {
22+
fastcgi_split_path_info ^(.+\.php)(/.*)$;
23+
include fastcgi_params;
24+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
25+
fastcgi_index index.php;
26+
send_timeout 1800;
27+
fastcgi_read_timeout 1800;
28+
fastcgi_pass php:9000;
29+
}
30+
}
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apc.shm_segments=1
2+
apc.shm_size=256M
3+
apc.num_files_hint=7000
4+
apc.user_entries_hint=4096
5+
apc.ttl=7200
6+
apc.user_ttl=7200
7+
apc.gc_ttl=3600
8+
apc.max_file_size=1M
9+
apc.stat=1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
opcache.memory_consumption=128
2+
opcache.interned_strings_buffer=8
3+
opcache.max_accelerated_files=4000
4+
opcache.revalidate_freq=60
5+
opcache.fast_shutdown=1
6+
opcache.enable_cli=1
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
zend_extension=xdebug.so
2+
3+
;Debugging
4+
xdebug.remote_enable = 1;
5+
xdebug.remote_connect_back = 1;
6+
xdebug.remote_autostart = 1;
7+
xdebug.remote_port = 9001;
8+
9+
;Profiling
10+
xdebug.profiler_enable = 0;
11+
xdebug.profiler_enable_trigger = 1;
12+
xdebug.profiler_output_dir = "/tmp/xdebug";
13+
14+
xdebug.max_nesting_level = 500;

etc/infrastructure/php/php.ini

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
date.timezone = "UTC"
2+
html_errors = "On"
3+
display_errors = "On"
4+
error_reporting = E_ALL

0 commit comments

Comments
 (0)