Skip to content

Commit 41af03e

Browse files
committedOct 19, 2023
Docker compose setup to run tests locally.
1 parent 98ecc6c commit 41af03e

File tree

5 files changed

+91
-0
lines changed

5 files changed

+91
-0
lines changed
 

‎README.md

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ It means that composer will look at `master` branch of repository configured und
5959
### 2023-10-19
6060

6161
- Removed usage of deprecated `redis->getKeys()` in favor of `redis->keys()`.
62+
- Added docker-compose setup to run tests locally.
6263

6364
### 2023-09-18
6465

‎docker-compose.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
services:
2+
web:
3+
build: ./docker/web
4+
environment:
5+
PHP_IDE_CONFIG: "serverName=localhost"
6+
volumes:
7+
- ./:/var/www/html:cached
8+
working_dir: /var/www/html
9+
ports:
10+
- "8000:80"
11+
depends_on:
12+
- mysql
13+
- pgsql
14+
- memcached
15+
- redis
16+
mysql:
17+
image: mysql:5.6
18+
platform: linux/amd64
19+
command: mysqld --character-set-server=utf8 --collation-server=utf8_general_ci
20+
environment:
21+
MYSQL_ROOT_PASSWORD: root
22+
MYSQL_DATABASE: cakephp_test
23+
MYSQL_USER: cakephp_test
24+
MYSQL_PASSWORD: secret
25+
volumes:
26+
- ./docker/mysql:/docker-entrypoint-initdb.d:cached
27+
- mysql-data:/var/lib/mysql
28+
ports:
29+
- "3306:3306"
30+
pgsql:
31+
image: postgres:9.4
32+
platform: linux/amd64
33+
environment:
34+
POSTGRES_DB: cakephp_test
35+
POSTGRES_USER: postgres
36+
POSTGRES_PASSWORD: postgres
37+
volumes:
38+
- ./docker/pgsql:/docker-entrypoint-initdb.d:cached
39+
- pgsql-data:/var/lib/postgresql/data
40+
ports:
41+
- "5432:5432"
42+
memcached:
43+
image: memcached:latest
44+
hostname: memcached
45+
ports:
46+
- "11211:11211"
47+
redis:
48+
image: "redis:latest"
49+
hostname: redis
50+
ports:
51+
- "6379:6379"
52+
volumes:
53+
mysql-data:
54+
pgsql-data:
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CREATE DATABASE IF NOT EXISTS cakephp_test ;
2+
GRANT ALL ON cakephp_test.* TO 'cakephp_test'@'%' ;
3+
CREATE DATABASE IF NOT EXISTS cakephp_test2 ;
4+
GRANT ALL ON cakephp_test2.* TO 'cakephp_test'@'%' ;
5+
CREATE DATABASE IF NOT EXISTS cakephp_test3 ;
6+
GRANT ALL ON cakephp_test3.* TO 'cakephp_test'@'%' ;
7+
FLUSH PRIVILEGES ;
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
\c cakephp_test
2+
3+
CREATE SCHEMA test2;
4+
CREATE SCHEMA test3;

‎docker/web/Dockerfile

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM php:8.2-apache
2+
3+
RUN apt-get update && apt-get install -y --no-install-recommends \
4+
&& apt-get install -y libpq-dev libzip-dev unzip openssl libmcrypt-dev libmemcached-dev locales \
5+
&& rm -rf /var/lib/apt/lists/*
6+
7+
RUN docker-php-ext-install pdo_mysql pdo_pgsql zip \
8+
&& pecl install apcu redis memcached mcrypt xdebug \
9+
&& docker-php-ext-enable redis memcached mcrypt \
10+
&& docker-php-ext-enable xdebug \
11+
&& echo "extension=apcu.so" >> /usr/local/etc/php/php.ini \
12+
&& echo "apc.enable_cli = 1" >> /usr/local/etc/php/php.ini
13+
14+
COPY --from=composer /usr/bin/composer /usr/local/bin/composer
15+
16+
RUN sed -i '/de_DE /s/^# //g' /etc/locale.gen \
17+
&& sed -i '/es_ES /s/^# //g' /etc/locale.gen \
18+
&& locale-gen
19+
20+
ENV APACHE_DOCUMENT_ROOT /var/www/html/app/webroot
21+
22+
RUN a2enmod rewrite
23+
24+
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
25+
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf

0 commit comments

Comments
 (0)
Please sign in to comment.