Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
arogachev committed Nov 18, 2024
1 parent 44c33de commit ab5e779
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 20 deletions.
12 changes: 10 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
FROM composer/composer:latest-bin AS composer
FROM php:8.3-cli

# System packages
Expand Down Expand Up @@ -52,7 +53,11 @@ RUN echo 'umask 002' >> /root/.bashrc

# PHP extensions

RUN docker-php-ext-install pdo_mysql pdo_pgsql
RUN docker-php-ext-install \
pdo_mysql \
pdo_pgsql \
# For Psalm, to make use of JIT for a 20%+ performance boost.
opcache

RUN echo 'instantclient,/usr/local/instantclient' | pecl install oci8
RUN echo "extension=oci8.so" > /usr/local/etc/php/conf.d/php-oci8.ini
Expand All @@ -66,9 +71,12 @@ RUN printf "; priority=20\nextension=sqlsrv.so\n" > /usr/local/etc/php/conf.d/ph
RUN pecl install pdo_sqlsrv
RUN printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /usr/local/etc/php/conf.d/php-pdo-sqlsrv.ini

# For code coverage (mutation testing)
RUN pecl install pcov && docker-php-ext-enable pcov

# Composer

COPY --from=composer:2.8.1 /usr/bin/composer /usr/local/bin/composer
COPY --from=composer /composer /usr/bin/composer

# Code

Expand Down
47 changes: 41 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,41 @@
test-all: vendor/bin/phpunit --testsuite Sqlite,Mysql,Pgsql,Mssql,Oracle
test-sqlite: vendor/bin/phpunit --testsuite Sqlite
test-mysql: vendor/bin/phpunit --testsuite Mysql
test-pgsql: vendor/bin/phpunit --testsuite Pgsql
test-mssql: vendor/bin/phpunit --testsuite Mssql
test-oracle: vendor/bin/phpunit --testsuite Oracle
run:
docker compose run --rm --entrypoint $(CMD) php

test-all: test-sqlite \
test-mysql \
test-pgsql \
test-mssql \
test-oracle
test-sqlite: testsuite-Sqlite
test-mysql: testsuite-Mysql
test-pgsql: testsuite-Pgsql
test-mssql: testsuite-Mssql
test-oracle:
docker compose run \
--rm \
--entrypoint 'bash -c -l "vendor/bin/phpunit --testsuite Oracle"' \
php

testsuite-%:
docker compose run \
--rm \
--entrypoint "vendor/bin/phpunit --testsuite $(subst testsuite-,,$@)" \
php

static-analysis: CMD="vendor/bin/psalm --no-cache"
static-analysis: run

mutation: CMD="\
vendor/bin/roave-infection-static-analysis-plugin \
--threads=2 \
--min-msi=0 \
--min-covered-msi=100 \
--ignore-msi-with-no-mutations \
--only-covered"
mutation: run

composer-require-checker: CMD="vendor/bin/composer-require-checker"
composer-require-checker: run

shell: CMD="bash"
shell: run
66 changes: 54 additions & 12 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ services:
condition: service_healthy
postgres:
condition: service_healthy
mssql:
condition: service_healthy
oracle:
condition: service_healthy
environment:
YII_MYSQL_DATABASE: yii
YII_MYSQL_HOST: mysql
Expand All @@ -31,11 +35,11 @@ services:
YII_MSSQL_USER: SA
YII_MSSQL_PASSWORD: YourStrong!Passw0rd

YII_ORACLE_DATABASE:
YII_ORACLE_SID: FREE
YII_ORACLE_HOST: oracle
YII_ORACLE_PORT:
YII_ORACLE_PORT: 1521
YII_ORACLE_USER: system
YII_ORACLE_PASSWORD: root
YII_ORACLE_PASSWORD: sys_user_password
mysql:
image: mysql:9
ports:
Expand All @@ -52,6 +56,23 @@ services:
interval: 5s
timeout: 5s
retries: 20
mariadb:
image: mariadb:11
ports:
- "13306:3306"
volumes:
- type: tmpfs
target: /var/lib/mysql
environment:
MYSQL_DATABASE: yii
MYSQL_ROOT_PASSWORD: root
MYSQL_ROOT_HOST: "%"
healthcheck:
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
start_period: 10s
interval: 10s
timeout: 5s
retries: 3
postgres:
image: postgres:17
ports:
Expand All @@ -75,16 +96,37 @@ services:
ACCEPT_EULA: Y
ports:
- "1433:1433"
expose:
- "1433"
user: root
volumes:
- mssql-data:/var/opt/mssql/data
- mssql-log:/var/opt/mssql/log
- mssql-secrets:/var/opt/mssql/secrets
healthcheck:
test: /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P "$${SA_PASSWORD}" -Q "SELECT 1" -b -C -o /dev/null
interval: 10s
timeout: 3s
retries: 100
start_period: 10s
oracle:
image: gvenzl/oracle-xe:21
build:
context: docker/oracle
ports:
- "1521:1521"
expose:
- "1521"
volumes:
- oracle-data:/opt/oracle/oradata
environment:
ORACLE_PASSWORD : root
ORACLE_DATABASE : yiitest
APP_USER: yiitest
APP_USER_PASSWORD: root
ORACLE_PASSWORD: sys_user_password
APP_USER: my_user
APP_USER_PASSWORD: password_i_should_change
healthcheck:
test: ["CMD", "healthcheck.sh"]
interval: 10s
timeout: 5s
retries: 100
start_period: 5s
start_interval: 5s
volumes:
mssql-data:
mssql-log:
mssql-secrets:
oracle-data:
3 changes: 3 additions & 0 deletions docker/oracle/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM gvenzl/oracle-free:23

RUN chown -R 54321:54321 /opt/oracle/oradata && chmod 0777 /opt/oracle/oradata

0 comments on commit ab5e779

Please sign in to comment.