From d8cf59d74a9dbdc064badff45d8810ae9a415495 Mon Sep 17 00:00:00 2001 From: Alexey Rogachev Date: Tue, 29 Oct 2024 13:12:40 +0500 Subject: [PATCH 01/27] Initial commit --- Dockerfile | 80 ++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 6 ++++ docker-compose.yml | 65 +++++++++++++++++++++++++++++++++++++ 3 files changed, 151 insertions(+) create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..7addcf76c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,80 @@ +FROM php:8.3-cli + +# System packages + +RUN apt-get update && apt-get install -y \ + unzip \ + # PostgreSQL + libpq-dev \ + # MSSQL + apt-transport-https \ + gnupg2 \ + libpng-dev \ + # Oracle + libaio1 && \ + rm -rf /var/lib/apt/lists/* + +# MSSQL dependencies + +ENV ACCEPT_EULA=Y + +# Install prerequisites for the sqlsrv and pdo_sqlsrv PHP extensions. +# Some packages are pinned with lower priority to prevent build issues due to package conflicts. +# Link: https://github.com/microsoft/linux-package-repositories/issues/39 +RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \ + && curl https://packages.microsoft.com/config/debian/11/prod.list > /etc/apt/sources.list.d/mssql-release.list \ + && echo "Package: unixodbc\nPin: origin \"packages.microsoft.com\"\nPin-Priority: 100\n" >> /etc/apt/preferences.d/microsoft \ + && echo "Package: unixodbc-dev\nPin: origin \"packages.microsoft.com\"\nPin-Priority: 100\n" >> /etc/apt/preferences.d/microsoft \ + && echo "Package: libodbc1:amd64\nPin: origin \"packages.microsoft.com\"\nPin-Priority: 100\n" >> /etc/apt/preferences.d/microsoft \ + && echo "Package: odbcinst\nPin: origin \"packages.microsoft.com\"\nPin-Priority: 100\n" >> /etc/apt/preferences.d/microsoft \ + && echo "Package: odbcinst1debian2:amd64\nPin: origin \"packages.microsoft.com\"\nPin-Priority: 100\n" >> /etc/apt/preferences.d/microsoft \ + && apt-get update \ + && apt-get install -y msodbcsql18 mssql-tools18 unixodbc-dev \ + && rm -rf /var/lib/apt/lists/* + +# Oracle dependencies + +RUN cd /tmp && curl -L https://download.oracle.com/otn_software/linux/instantclient/2350000/instantclient-basic-linux.x64-23.5.0.24.07.zip -O +RUN cd /tmp && curl -L https://download.oracle.com/otn_software/linux/instantclient/2350000/instantclient-sdk-linux.x64-23.5.0.24.07.zip -O +RUN cd /tmp && curl -L https://download.oracle.com/otn_software/linux/instantclient/2350000/instantclient-sqlplus-linux.x64-23.5.0.24.07.zip -O + +RUN unzip /tmp/instantclient-basic-linux.x64-23.5.0.24.07.zip -d /usr/local/ +RUN unzip -o /tmp/instantclient-sdk-linux.x64-23.5.0.24.07.zip -d /usr/local/ +RUN unzip -o /tmp/instantclient-sqlplus-linux.x64-23.5.0.24.07.zip -d /usr/local/ + +RUN ln -s /usr/local/instantclient_23_5 /usr/local/instantclient +# Fixes error "libnnz19.so: cannot open shared object file: No such file or directory" +RUN ln -s /usr/local/instantclient/lib* /usr/lib +RUN ln -s /usr/local/instantclient/sqlplus /usr/bin/sqlplus + +RUN echo 'export LD_LIBRARY_PATH="/usr/local/instantclient"' >> /root/.bashrc +RUN echo 'umask 002' >> /root/.bashrc + +# PHP extensions + +RUN docker-php-ext-install pdo_mysql pdo_pgsql + +RUN echo 'instantclient,/usr/local/instantclient' | pecl install oci8 +RUN echo "extension=oci8.so" > /usr/local/etc/php/conf.d/php-oci8.ini + +RUN echo 'instantclient,/usr/local/instantclient' | pecl install pdo_oci +RUN echo "extension=pdo_oci.so" > /usr/local/etc/php/conf.d/php-pdo-oci.ini + +RUN pecl install sqlsrv +RUN printf "; priority=20\nextension=sqlsrv.so\n" > /usr/local/etc/php/conf.d/php-sqlsrv.ini + +RUN pecl install pdo_sqlsrv +RUN printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /usr/local/etc/php/conf.d/php-pdo-sqlsrv.ini + +# Composer + +COPY --from=composer:2.8.1 /usr/bin/composer /usr/local/bin/composer + +# Code + +COPY . /code +WORKDIR /code + +# PHP packages + +RUN composer install diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..06e11269d --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +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 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..fe8b262ef --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,65 @@ +services: + php: + build: . + volumes: + - ./src:/code/src + - ./tests:/code/tests + - ./phpunit.xml.dist:/code/phpunit.xml.dist + command: tail -F anything + depends_on: + mysql: + condition: service_healthy + postgres: + condition: service_healthy + mysql: + image: mysql:9 + ports: + - "3306:3306" + volumes: + - type: tmpfs + target: /var/lib/mysql + environment: + MYSQL_DATABASE: yii + MYSQL_ROOT_PASSWORD: root + MYSQL_ROOT_HOST: "%" + healthcheck: + test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost", "-uroot" ] + interval: 5s + timeout: 5s + retries: 20 + postgres: + image: postgres:17 + ports: + - "5432:5432" + volumes: + - type: tmpfs + target: /var/lib/postgresql/data + environment: + POSTGRES_DB: yii + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + healthcheck: + test: [ "CMD-SHELL", "pg_isready -U postgres" ] + interval: 5s + timeout: 5s + retries: 5 + mssql: + image: mcr.microsoft.com/mssql/server:2022-latest + environment: + SA_PASSWORD: YourStrong!Passw0rd + ACCEPT_EULA: Y + ports: + - "1433:1433" + expose: + - "1433" + oracle: + image: gvenzl/oracle-xe:21 + ports: + - "1521:1521" + expose: + - "1521" + environment: + ORACLE_PASSWORD : root + ORACLE_DATABASE : yiitest + APP_USER: yiitest + APP_USER_PASSWORD: root From 3c5ca51975bd02c56afd9d304e39b93f997f42e6 Mon Sep 17 00:00:00 2001 From: Alexey Rogachev Date: Wed, 30 Oct 2024 17:51:37 +0500 Subject: [PATCH 02/27] WIP --- .gitignore | 3 +++ composer.json | 6 ++++++ docker-compose.yml | 7 +++++++ 3 files changed, 16 insertions(+) diff --git a/.gitignore b/.gitignore index c942fd526..d800ee125 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,6 @@ phpunit.phar #codeception /tests/_output c3.php + +# Docker +docker-compose.override.yml diff --git a/composer.json b/composer.json index 9bcedb8b6..118df7556 100644 --- a/composer.json +++ b/composer.json @@ -61,6 +61,12 @@ }, "autoload-dev": { "psr-4": { + "Yiisoft\\ActiveRecord\\": "vendor/yiisoft/active-record/src", + "Yiisoft\\Db\\Mssql\\": "vendor/yiisoft/db-mssql/src", + "Yiisoft\\Db\\Mysql\\": "vendor/yiisoft/db-mysql/src", + "Yiisoft\\Db\\Oracle\\": "vendor/yiisoft/db-oracle/src", + "Yiisoft\\Db\\Pgsql\\": "vendor/yiisoft/db-pgsql/src", + "Yiisoft\\Db\\Sqlite\\": "vendor/yiisoft/db-sqlite/src", "Yiisoft\\Db\\Tests\\": "tests", "Yiisoft\\ActiveRecord\\Tests\\": "vendor/yiisoft/active-record/tests", "Yiisoft\\Db\\Mssql\\Tests\\": "vendor/yiisoft/db-mssql/tests", diff --git a/docker-compose.yml b/docker-compose.yml index fe8b262ef..57ec3aaf6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,6 +4,7 @@ services: volumes: - ./src:/code/src - ./tests:/code/tests + - ./composer.json:/code/composer.json - ./phpunit.xml.dist:/code/phpunit.xml.dist command: tail -F anything depends_on: @@ -11,6 +12,12 @@ services: condition: service_healthy postgres: condition: service_healthy + environment: + YII_MYSQL_DATABASE: yii + YII_MYSQL_HOST: mysql + YII_MYSQL_PORT: 3306 + YII_MYSQL_USER: root + YII_MYSQL_PASSWORD: root mysql: image: mysql:9 ports: From b23740fc05f182da24b834cda0156ebe11483bc6 Mon Sep 17 00:00:00 2001 From: Alexey Rogachev Date: Fri, 1 Nov 2024 21:26:15 +0500 Subject: [PATCH 03/27] WIP --- docker-compose.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 57ec3aaf6..9cf6f661a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,6 +18,18 @@ services: YII_MYSQL_PORT: 3306 YII_MYSQL_USER: root YII_MYSQL_PASSWORD: root + + YII_PGSQL_DATABASE: yii + YII_PGSQL_HOST: postgres + YII_PGSQL_PORT: 5432 + YII_PGSQL_USER: postgres + YII_PGSQL_PASSWORD: postgres + + YII_MSSQL_DATABASE: tempdb + YII_MSSQL_HOST: mssql + YII_MSSQL_PORT: 1433 + YII_MSSQL_USER: SA + YII_MSSQL_PASSWORD: YourStrong!Passw0rd mysql: image: mysql:9 ports: From 44c33debaeb06e68a62d18e426fe564fcc0f69a4 Mon Sep 17 00:00:00 2001 From: Alexey Rogachev Date: Fri, 1 Nov 2024 21:42:23 +0500 Subject: [PATCH 04/27] WIP --- docker-compose.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 9cf6f661a..6ae2b5913 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -30,6 +30,12 @@ services: YII_MSSQL_PORT: 1433 YII_MSSQL_USER: SA YII_MSSQL_PASSWORD: YourStrong!Passw0rd + + YII_ORACLE_DATABASE: + YII_ORACLE_HOST: oracle + YII_ORACLE_PORT: + YII_ORACLE_USER: system + YII_ORACLE_PASSWORD: root mysql: image: mysql:9 ports: From ab5e77928b3ab8b35c46d5fc7a1f0c6ae1782b10 Mon Sep 17 00:00:00 2001 From: Alexey Rogachev Date: Mon, 18 Nov 2024 23:23:34 +0500 Subject: [PATCH 05/27] WIP --- Dockerfile | 12 ++++++-- Makefile | 47 ++++++++++++++++++++++++---- docker-compose.yml | 66 ++++++++++++++++++++++++++++++++-------- docker/oracle/Dockerfile | 3 ++ 4 files changed, 108 insertions(+), 20 deletions(-) create mode 100644 docker/oracle/Dockerfile diff --git a/Dockerfile b/Dockerfile index 7addcf76c..bf0a95372 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,4 @@ +FROM composer/composer:latest-bin AS composer FROM php:8.3-cli # System packages @@ -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 @@ -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 diff --git a/Makefile b/Makefile index 06e11269d..50c4eb6fa 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index 6ae2b5913..062a94eb5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 @@ -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: @@ -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: @@ -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: diff --git a/docker/oracle/Dockerfile b/docker/oracle/Dockerfile new file mode 100644 index 000000000..cc7e1498a --- /dev/null +++ b/docker/oracle/Dockerfile @@ -0,0 +1,3 @@ +FROM gvenzl/oracle-free:23 + +RUN chown -R 54321:54321 /opt/oracle/oradata && chmod 0777 /opt/oracle/oradata From aa8696d48ee77f122267c28cbf778e57f48e0ee5 Mon Sep 17 00:00:00 2001 From: Alexey Rogachev Date: Wed, 20 Nov 2024 00:30:55 +0500 Subject: [PATCH 06/27] WIP --- Makefile | 7 +++++++ docker-compose.yml | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/Makefile b/Makefile index 50c4eb6fa..201e2a2c1 100644 --- a/Makefile +++ b/Makefile @@ -3,11 +3,18 @@ run: test-all: test-sqlite \ test-mysql \ + test-mariadb \ test-pgsql \ test-mssql \ test-oracle test-sqlite: testsuite-Sqlite test-mysql: testsuite-Mysql +test-mariadb: + docker compose run \ + --rm \ + --entrypoint "vendor/bin/phpunit --testsuite Mysql" \ + -e YII_MYSQL_TYPE=mariadb \ + php test-pgsql: testsuite-Pgsql test-mssql: testsuite-Mssql test-oracle: diff --git a/docker-compose.yml b/docker-compose.yml index 062a94eb5..e519cf96f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,6 +10,8 @@ services: depends_on: mysql: condition: service_healthy + mariadb: + condition: service_healthy postgres: condition: service_healthy mssql: @@ -22,6 +24,13 @@ services: YII_MYSQL_PORT: 3306 YII_MYSQL_USER: root YII_MYSQL_PASSWORD: root + YII_MYSQL_TYPE: mysql + + YII_MARIADB_DATABASE: yii + YII_MARIADB_HOST: mariadb + YII_MARIADB_PORT: 13306 + YII_MARIADB_USER: root + YII_MARIADB_PASSWORD: root YII_PGSQL_DATABASE: yii YII_PGSQL_HOST: postgres From d466d6f4bab808e7de08361682554454b8c2832b Mon Sep 17 00:00:00 2001 From: Alexey Rogachev Date: Thu, 21 Nov 2024 18:42:05 +0500 Subject: [PATCH 07/27] WIP --- docker-compose.yml | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index e519cf96f..dd2d45b4b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,6 +16,8 @@ services: condition: service_healthy mssql: condition: service_healthy +# mssql-init: +# condition: service_completed_successfully oracle: condition: service_healthy environment: @@ -38,7 +40,7 @@ services: YII_PGSQL_USER: postgres YII_PGSQL_PASSWORD: postgres - YII_MSSQL_DATABASE: tempdb + YII_MSSQL_DATABASE: yii YII_MSSQL_HOST: mssql YII_MSSQL_PORT: 1433 YII_MSSQL_USER: SA @@ -76,12 +78,13 @@ services: MYSQL_DATABASE: yii MYSQL_ROOT_PASSWORD: root MYSQL_ROOT_HOST: "%" + MYSQL_TCP_PORT: 13306 healthcheck: test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] start_period: 10s interval: 10s timeout: 5s - retries: 3 + retries: 30 postgres: image: postgres:17 ports: @@ -100,9 +103,6 @@ services: retries: 5 mssql: image: mcr.microsoft.com/mssql/server:2022-latest - environment: - SA_PASSWORD: YourStrong!Passw0rd - ACCEPT_EULA: Y ports: - "1433:1433" user: root @@ -110,12 +110,24 @@ services: - mssql-data:/var/opt/mssql/data - mssql-log:/var/opt/mssql/log - mssql-secrets:/var/opt/mssql/secrets + environment: + SA_PASSWORD: YourStrong!Passw0rd + ACCEPT_EULA: Y 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 + mssql-init: + image: mcr.microsoft.com/mssql/server:2022-latest + network_mode: service:mssql + command: > + /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P "YourStrong!Passw0rd" + -Q "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = 'yii') BEGIN CREATE DATABASE yii END" -b -C + depends_on: + mssql: + condition: service_healthy oracle: build: context: docker/oracle From 28119a0431ddfbb93aaa388f20fd2d862408d5bf Mon Sep 17 00:00:00 2001 From: Alexey Rogachev Date: Mon, 25 Nov 2024 19:04:53 +0500 Subject: [PATCH 08/27] WIP --- docker/oracle/Dockerfile.23 | 128 ++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 docker/oracle/Dockerfile.23 diff --git a/docker/oracle/Dockerfile.23 b/docker/oracle/Dockerfile.23 new file mode 100644 index 000000000..512d5e7e2 --- /dev/null +++ b/docker/oracle/Dockerfile.23 @@ -0,0 +1,128 @@ +# +# Since: September, 2023 +# Author: gvenzl +# Name: Dockerfile.23 +# Description: Dockerfile to build Oracle Database 23 Free +# +# Copyright 2023 Gerald Venzl +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM oraclelinux:8-slim as builder + +ARG BUILD_MODE BUILD_VERSION DB_FLAVOR ARCH RPM_ARCH + +ENV OCI_IMAGE_VERSION=${BUILD_VERSION} \ + OCI_IMAGE_FLAVOR=${BUILD_MODE} \ + ORACLE_BASE=/opt/oracle \ + ORACLE_BASE_CONFIG=/opt/oracle/product/23${DB_FLAVOR}/dbhomeFree \ + ORACLE_BASE_HOME=/opt/oracle/product/23${DB_FLAVOR}/dbhomeFree \ + ORACLE_HOME=/opt/oracle/product/23${DB_FLAVOR}/dbhomeFree \ + ORACLE_SID=FREE \ + PATH=${PATH}:/opt/oracle/product/23${DB_FLAVOR}/dbhomeFree/bin:/opt/oracle \ + NLS_LANG=.AL32UTF8 + +COPY oracle-database-free-23${DB_FLAVOR}-${BUILD_VERSION}-1.0-1.el8.${RPM_ARCH}.rpm install.23.sh container-entrypoint.sh resetPassword createAppUser createDatabase healthcheck.sh /install/ + +RUN /install/install.23.sh "${BUILD_MODE}" + +########################################################################################## +### Layer 1 --> Core OS +########################################################################################## + +FROM scratch as os_layer + +ARG DB_FLAVOR + +# Redefine environment variables, etc. as we copied everything from an empty image (scratch) +ENV ORACLE_BASE=/opt/oracle \ + ORACLE_BASE_CONFIG=/opt/oracle/product/23${DB_FLAVOR}/dbhomeFree \ + ORACLE_BASE_HOME=/opt/oracle/product/23${DB_FLAVOR}/dbhomeFree \ + ORACLE_HOME=/opt/oracle/product/23${DB_FLAVOR}/dbhomeFree \ + ORACLE_SID=FREE \ + PATH=${PATH}:/opt/oracle/product/23${DB_FLAVOR}/dbhomeFree/bin:/opt/oracle \ + NLS_LANG=.AL32UTF8 + +COPY --from=builder / / +RUN rm -rf "${ORACLE_BASE}" + +########################################################################################## +### Layer 2 --> Oracle Home without bin/oracle, lib, rdbms, and FREE.7z +########################################################################################## + +FROM os_layer as oracle_home + +COPY --from=builder --chown=oracle:oinstall "${ORACLE_BASE}" "${ORACLE_BASE}" + +RUN rm "${ORACLE_HOME}"/bin/oracle +RUN rm -r "${ORACLE_HOME}"/lib +RUN rm -r "${ORACLE_HOME}"/rdbms +RUN rm "${ORACLE_BASE}"/"${ORACLE_SID}".7z + + +########################################################################################## +### Layer 3 --> Oracle binary (bin/oracle) +########################################################################################## + +FROM oracle_home as oracle_binary + +COPY --from=builder --chown=oracle:oinstall "${ORACLE_HOME}"/bin/oracle "${ORACLE_HOME}"/bin/oracle + +########################################################################################## +### Layer 4 --> Oracle lib +########################################################################################## + +FROM oracle_binary as oracle_lib + +COPY --from=builder --chown=oracle:oinstall "${ORACLE_HOME}"/lib "${ORACLE_HOME}"/lib + +########################################################################################## +### Layer 5 --> Oracle lib +########################################################################################## + +FROM oracle_lib as oracle_rdbms + +COPY --from=builder --chown=oracle:oinstall "${ORACLE_HOME}"/rdbms "${ORACLE_HOME}"/rdbms + +########################################################################################## +### Layer 6 --> Oracle (compressed) db files +########################################################################################## + +FROM oracle_rdbms as db_files + +COPY --from=builder --chown=oracle:oinstall "${ORACLE_BASE}"/"${ORACLE_SID}".7z "${ORACLE_BASE}"/ + +########################################################################################## +### Finalize (reset permissions for root owned files, set label, user, etc.) +########################################################################################## + +RUN chown root "${ORACLE_HOME}"/bin/extjob; \ + chmod 4750 "${ORACLE_HOME}"/bin/extjob; \ + chown root "${ORACLE_HOME}"/rdbms/admin/externaljob.ora; \ + chmod 640 "${ORACLE_HOME}"/rdbms/admin/externaljob.ora; \ + chown root "${ORACLE_HOME}"/bin/jssu; \ + chmod 4750 "${ORACLE_HOME}"/bin/jssu + +LABEL org.opencontainers.image.title="Oracle Database Free Container images" +LABEL org.opencontainers.image.description="Oracle Database Free for everyone!" +LABEL org.opencontainers.image.authors="Gerald Venzl" +LABEL org.opencontainers.image.source=https://github.com/gvenzl/oci-oracle-free +LABEL org.opencontainers.image.licenses=Apache-2.0 +LABEL org.opencontainers.image.documentation=https://github.com/gvenzl/oci-oracle-free/blob/main/README.md + +USER oracle +WORKDIR ${ORACLE_BASE} + +HEALTHCHECK CMD "${ORACLE_BASE}"/healthcheck.sh >/dev/null || exit 1 + +ENTRYPOINT ["container-entrypoint.sh"] From bcea1667d54524c75a93b1669bc62e2e2e57efe4 Mon Sep 17 00:00:00 2001 From: Alexey Rogachev Date: Mon, 2 Dec 2024 20:12:05 +0500 Subject: [PATCH 09/27] Try approach with PHP and Oracle in one service --- Dockerfile | 16 +-- Makefile | 10 +- docker-compose.yml | 265 ++++++++++++++++++++++-------------- docker/oracle/Dockerfile | 27 +++- docker/oracle/Dockerfile.23 | 128 ----------------- docker/test/Dockerfile | 33 +++++ docker/test1/Dockerfile | 16 +++ 7 files changed, 253 insertions(+), 242 deletions(-) delete mode 100644 docker/oracle/Dockerfile.23 create mode 100644 docker/test/Dockerfile create mode 100644 docker/test1/Dockerfile diff --git a/Dockerfile b/Dockerfile index bf0a95372..5ae2baacc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ FROM composer/composer:latest-bin AS composer -FROM php:8.3-cli + +FROM php:8.3-cli as php # System packages @@ -44,7 +45,6 @@ RUN unzip -o /tmp/instantclient-sdk-linux.x64-23.5.0.24.07.zip -d /usr/local/ RUN unzip -o /tmp/instantclient-sqlplus-linux.x64-23.5.0.24.07.zip -d /usr/local/ RUN ln -s /usr/local/instantclient_23_5 /usr/local/instantclient -# Fixes error "libnnz19.so: cannot open shared object file: No such file or directory" RUN ln -s /usr/local/instantclient/lib* /usr/lib RUN ln -s /usr/local/instantclient/sqlplus /usr/bin/sqlplus @@ -59,18 +59,18 @@ RUN docker-php-ext-install \ # 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 - -RUN echo 'instantclient,/usr/local/instantclient' | pecl install pdo_oci -RUN echo "extension=pdo_oci.so" > /usr/local/etc/php/conf.d/php-pdo-oci.ini - RUN pecl install sqlsrv RUN printf "; priority=20\nextension=sqlsrv.so\n" > /usr/local/etc/php/conf.d/php-sqlsrv.ini RUN pecl install pdo_sqlsrv RUN printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /usr/local/etc/php/conf.d/php-pdo-sqlsrv.ini +RUN echo 'instantclient,/usr/local/instantclient' | pecl install oci8 +RUN echo "extension=oci8.so" > /usr/local/etc/php/conf.d/php-oci8.ini + +RUN echo 'instantclient,/usr/local/instantclient' | pecl install pdo_oci +RUN echo "extension=pdo_oci.so" > /usr/local/etc/php/conf.d/php-pdo-oci.ini + # For code coverage (mutation testing) RUN pecl install pcov && docker-php-ext-enable pcov diff --git a/Makefile b/Makefile index 201e2a2c1..74bc5a87f 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ run: - docker compose run --rm --entrypoint $(CMD) php + docker compose run --user root --rm --entrypoint $(CMD) php test-all: test-sqlite \ test-mysql \ @@ -19,9 +19,11 @@ test-pgsql: testsuite-Pgsql test-mssql: testsuite-Mssql test-oracle: docker compose run \ + --user root \ + --workdir /code \ --rm \ - --entrypoint 'bash -c -l "vendor/bin/phpunit --testsuite Oracle"' \ - php + --entrypoint "bash -c -l 'vendor/bin/phpunit --testsuite Oracle $(RUN_ARGS)'" \ + php-oracle testsuite-%: docker compose run \ @@ -29,6 +31,8 @@ testsuite-%: --entrypoint "vendor/bin/phpunit --testsuite $(subst testsuite-,,$@)" \ php +# --filter showDatabases vendor/yiisoft/db-mssql/tests/CommandTest.php + static-analysis: CMD="vendor/bin/psalm --no-cache" static-analysis: run diff --git a/docker-compose.yml b/docker-compose.yml index dd2d45b4b..1a9563e2b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,20 +6,6 @@ services: - ./tests:/code/tests - ./composer.json:/code/composer.json - ./phpunit.xml.dist:/code/phpunit.xml.dist - command: tail -F anything - depends_on: - mysql: - condition: service_healthy - mariadb: - condition: service_healthy - postgres: - condition: service_healthy - mssql: - condition: service_healthy -# mssql-init: -# condition: service_completed_successfully - oracle: - condition: service_healthy environment: YII_MYSQL_DATABASE: yii YII_MYSQL_HOST: mysql @@ -40,7 +26,7 @@ services: YII_PGSQL_USER: postgres YII_PGSQL_PASSWORD: postgres - YII_MSSQL_DATABASE: yii + YII_MSSQL_DATABASE: tempdb YII_MSSQL_HOST: mssql YII_MSSQL_PORT: 1433 YII_MSSQL_USER: SA @@ -51,103 +37,178 @@ services: YII_ORACLE_PORT: 1521 YII_ORACLE_USER: system YII_ORACLE_PASSWORD: sys_user_password - mysql: - image: mysql:9 - ports: - - "3306:3306" - volumes: - - type: tmpfs - target: /var/lib/mysql - environment: - MYSQL_DATABASE: yii - MYSQL_ROOT_PASSWORD: root - MYSQL_ROOT_HOST: "%" - healthcheck: - test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost", "-uroot" ] - 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: "%" - MYSQL_TCP_PORT: 13306 - healthcheck: - test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] - start_period: 10s - interval: 10s - timeout: 5s - retries: 30 - postgres: - image: postgres:17 - ports: - - "5432:5432" - volumes: - - type: tmpfs - target: /var/lib/postgresql/data - environment: - POSTGRES_DB: yii - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - healthcheck: - test: [ "CMD-SHELL", "pg_isready -U postgres" ] - interval: 5s - timeout: 5s - retries: 5 - mssql: - image: mcr.microsoft.com/mssql/server:2022-latest - ports: - - "1433:1433" - user: root - volumes: - - mssql-data:/var/opt/mssql/data - - mssql-log:/var/opt/mssql/log - - mssql-secrets:/var/opt/mssql/secrets - environment: - SA_PASSWORD: YourStrong!Passw0rd - ACCEPT_EULA: Y - 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 - mssql-init: - image: mcr.microsoft.com/mssql/server:2022-latest - network_mode: service:mssql - command: > - /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P "YourStrong!Passw0rd" - -Q "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = 'yii') BEGIN CREATE DATABASE yii END" -b -C - depends_on: - mssql: - condition: service_healthy - oracle: + + ORACLE_PASSWORD: sys_user_password + APP_USER: my_user + APP_USER_PASSWORD: password_i_should_change + command: tail -F anything + php-oracle: build: - context: docker/oracle + context: docker/oracle ports: - "1521:1521" volumes: - - oracle-data:/opt/oracle/oradata + - ./src:/code/src + - ./tests:/code/tests + - ./composer.json:/code/composer.json + - ./phpunit.xml.dist:/code/phpunit.xml.dist + - php-oracle-data:/opt/oracle/oradata environment: + YII_MYSQL_DATABASE: yii + YII_MYSQL_HOST: mysql + YII_MYSQL_PORT: 3306 + YII_MYSQL_USER: root + YII_MYSQL_PASSWORD: root + YII_MYSQL_TYPE: mysql + + YII_MARIADB_DATABASE: yii + YII_MARIADB_HOST: mariadb + YII_MARIADB_PORT: 13306 + YII_MARIADB_USER: root + YII_MARIADB_PASSWORD: root + + YII_PGSQL_DATABASE: yii + YII_PGSQL_HOST: postgres + YII_PGSQL_PORT: 5432 + YII_PGSQL_USER: postgres + YII_PGSQL_PASSWORD: postgres + + YII_MSSQL_DATABASE: tempdb + YII_MSSQL_HOST: mssql + YII_MSSQL_PORT: 1433 + YII_MSSQL_USER: SA + YII_MSSQL_PASSWORD: YourStrong!Passw0rd + + YII_ORACLE_SID: FREE + YII_ORACLE_HOST: 172.17.0.1 + YII_ORACLE_PORT: 1521 + YII_ORACLE_USER: system + YII_ORACLE_PASSWORD: sys_user_password + 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 + command: tail -F anything +# depends_on: +# mysql: +# condition: service_healthy +# mariadb: +# condition: service_healthy +# postgres: +# condition: service_healthy +# mssql: +# condition: service_healthy +# oracle: +# condition: service_healthy +# mysql: +# image: mysql:9 +# ports: +# - "3306:3306" +# volumes: +# - type: tmpfs +# target: /var/lib/mysql +# environment: +# MYSQL_DATABASE: yii +# MYSQL_ROOT_PASSWORD: root +# MYSQL_ROOT_HOST: "%" +# healthcheck: +# test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost", "-uroot" ] +# 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: "%" +# MYSQL_TCP_PORT: 13306 +# healthcheck: +# test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] +# start_period: 10s +# interval: 10s +# timeout: 5s +# retries: 30 +# postgres: +# image: postgres:17 +# ports: +# - "5432:5432" +# volumes: +# - type: tmpfs +# target: /var/lib/postgresql/data +# environment: +# POSTGRES_DB: yii +# POSTGRES_USER: postgres +# POSTGRES_PASSWORD: postgres +# healthcheck: +# test: [ "CMD-SHELL", "pg_isready -U postgres" ] +# interval: 5s +# timeout: 5s +# retries: 5 +# mssql: +# image: mcr.microsoft.com/mssql/server:2022-latest +# ports: +# - "1433:1433" +# user: root +# volumes: +# - mssql-data:/var/opt/mssql/data +# - mssql-log:/var/opt/mssql/log +# - mssql-secrets:/var/opt/mssql/secrets +# environment: +# SA_PASSWORD: YourStrong!Passw0rd +# ACCEPT_EULA: Y +# 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: +# build: +# context: docker/oracle +# ports: +# - "1521:1521" +# volumes: +# - oracle-data:/opt/oracle/oradata +# environment: +# 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 +# test1: +# build: +# context: docker/test1 +# volumes: +# - test1-oracle-data:/opt/oracle/oradata +# environment: +# ORACLE_PASSWORD: sys_user_password +# APP_USER: my_user +# APP_USER_PASSWORD: password_i_should_change +# command: tail -F anything + # entrypoint: /opt/oracle/container-entrypoint.sh +# healthcheck: +# test: [ "CMD", "/opt/oracle/healthcheck.sh" ] +# interval: 10s +# timeout: 5s +# retries: 100 +# start_period: 5s +# start_interval: 5s volumes: + php-oracle-data: mssql-data: mssql-log: mssql-secrets: oracle-data: + # test-oracle-data: + test1-oracle-data: diff --git a/docker/oracle/Dockerfile b/docker/oracle/Dockerfile index cc7e1498a..a9b71e7ff 100644 --- a/docker/oracle/Dockerfile +++ b/docker/oracle/Dockerfile @@ -1,3 +1,28 @@ -FROM gvenzl/oracle-free:23 +FROM --platform=linux/amd64 db-php:latest AS php + +FROM gvenzl/oracle-free:23 AS oracle + +COPY --from=php /usr/local/lib/php/ /usr/local/lib/php/ +COPY --from=php /usr/local/include/php/ /usr/local/include/php/ +COPY --from=php /usr/local/php/ /usr/local/php/ +COPY --from=php /usr/local/bin/php /usr/local/bin/php +COPY --from=php /usr/local/bin/php-config /usr/local/bin/php-config +COPY --from=php /usr/local/etc/php/ /usr/local/etc/php/ + +COPY --from=php /usr/lib/x86_64-linux-gnu/*.so* /usr/lib/x86_64-linux-gnu/ +COPY --from=php /usr/lib/x86_64-linux-gnu/*.so* /usr/lib64/ + +COPY --from=php /opt/* /opt/ +COPY --from=php /usr/local/instantclient_23_5/ /usr/local/instantclient_23_5/ + +COPY --from=php /code/ /code/ + +COPY --from=php /root/.bashrc /root/.bashrc + +USER root +RUN ln -s /usr/local/instantclient_23_5 /usr/local/instantclient +RUN ln -s /usr/local/instantclient/lib* /usr/lib +RUN ln -s /usr/local/instantclient/sqlplus /usr/bin/sqlplus +USER oracle RUN chown -R 54321:54321 /opt/oracle/oradata && chmod 0777 /opt/oracle/oradata diff --git a/docker/oracle/Dockerfile.23 b/docker/oracle/Dockerfile.23 deleted file mode 100644 index 512d5e7e2..000000000 --- a/docker/oracle/Dockerfile.23 +++ /dev/null @@ -1,128 +0,0 @@ -# -# Since: September, 2023 -# Author: gvenzl -# Name: Dockerfile.23 -# Description: Dockerfile to build Oracle Database 23 Free -# -# Copyright 2023 Gerald Venzl -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -FROM oraclelinux:8-slim as builder - -ARG BUILD_MODE BUILD_VERSION DB_FLAVOR ARCH RPM_ARCH - -ENV OCI_IMAGE_VERSION=${BUILD_VERSION} \ - OCI_IMAGE_FLAVOR=${BUILD_MODE} \ - ORACLE_BASE=/opt/oracle \ - ORACLE_BASE_CONFIG=/opt/oracle/product/23${DB_FLAVOR}/dbhomeFree \ - ORACLE_BASE_HOME=/opt/oracle/product/23${DB_FLAVOR}/dbhomeFree \ - ORACLE_HOME=/opt/oracle/product/23${DB_FLAVOR}/dbhomeFree \ - ORACLE_SID=FREE \ - PATH=${PATH}:/opt/oracle/product/23${DB_FLAVOR}/dbhomeFree/bin:/opt/oracle \ - NLS_LANG=.AL32UTF8 - -COPY oracle-database-free-23${DB_FLAVOR}-${BUILD_VERSION}-1.0-1.el8.${RPM_ARCH}.rpm install.23.sh container-entrypoint.sh resetPassword createAppUser createDatabase healthcheck.sh /install/ - -RUN /install/install.23.sh "${BUILD_MODE}" - -########################################################################################## -### Layer 1 --> Core OS -########################################################################################## - -FROM scratch as os_layer - -ARG DB_FLAVOR - -# Redefine environment variables, etc. as we copied everything from an empty image (scratch) -ENV ORACLE_BASE=/opt/oracle \ - ORACLE_BASE_CONFIG=/opt/oracle/product/23${DB_FLAVOR}/dbhomeFree \ - ORACLE_BASE_HOME=/opt/oracle/product/23${DB_FLAVOR}/dbhomeFree \ - ORACLE_HOME=/opt/oracle/product/23${DB_FLAVOR}/dbhomeFree \ - ORACLE_SID=FREE \ - PATH=${PATH}:/opt/oracle/product/23${DB_FLAVOR}/dbhomeFree/bin:/opt/oracle \ - NLS_LANG=.AL32UTF8 - -COPY --from=builder / / -RUN rm -rf "${ORACLE_BASE}" - -########################################################################################## -### Layer 2 --> Oracle Home without bin/oracle, lib, rdbms, and FREE.7z -########################################################################################## - -FROM os_layer as oracle_home - -COPY --from=builder --chown=oracle:oinstall "${ORACLE_BASE}" "${ORACLE_BASE}" - -RUN rm "${ORACLE_HOME}"/bin/oracle -RUN rm -r "${ORACLE_HOME}"/lib -RUN rm -r "${ORACLE_HOME}"/rdbms -RUN rm "${ORACLE_BASE}"/"${ORACLE_SID}".7z - - -########################################################################################## -### Layer 3 --> Oracle binary (bin/oracle) -########################################################################################## - -FROM oracle_home as oracle_binary - -COPY --from=builder --chown=oracle:oinstall "${ORACLE_HOME}"/bin/oracle "${ORACLE_HOME}"/bin/oracle - -########################################################################################## -### Layer 4 --> Oracle lib -########################################################################################## - -FROM oracle_binary as oracle_lib - -COPY --from=builder --chown=oracle:oinstall "${ORACLE_HOME}"/lib "${ORACLE_HOME}"/lib - -########################################################################################## -### Layer 5 --> Oracle lib -########################################################################################## - -FROM oracle_lib as oracle_rdbms - -COPY --from=builder --chown=oracle:oinstall "${ORACLE_HOME}"/rdbms "${ORACLE_HOME}"/rdbms - -########################################################################################## -### Layer 6 --> Oracle (compressed) db files -########################################################################################## - -FROM oracle_rdbms as db_files - -COPY --from=builder --chown=oracle:oinstall "${ORACLE_BASE}"/"${ORACLE_SID}".7z "${ORACLE_BASE}"/ - -########################################################################################## -### Finalize (reset permissions for root owned files, set label, user, etc.) -########################################################################################## - -RUN chown root "${ORACLE_HOME}"/bin/extjob; \ - chmod 4750 "${ORACLE_HOME}"/bin/extjob; \ - chown root "${ORACLE_HOME}"/rdbms/admin/externaljob.ora; \ - chmod 640 "${ORACLE_HOME}"/rdbms/admin/externaljob.ora; \ - chown root "${ORACLE_HOME}"/bin/jssu; \ - chmod 4750 "${ORACLE_HOME}"/bin/jssu - -LABEL org.opencontainers.image.title="Oracle Database Free Container images" -LABEL org.opencontainers.image.description="Oracle Database Free for everyone!" -LABEL org.opencontainers.image.authors="Gerald Venzl" -LABEL org.opencontainers.image.source=https://github.com/gvenzl/oci-oracle-free -LABEL org.opencontainers.image.licenses=Apache-2.0 -LABEL org.opencontainers.image.documentation=https://github.com/gvenzl/oci-oracle-free/blob/main/README.md - -USER oracle -WORKDIR ${ORACLE_BASE} - -HEALTHCHECK CMD "${ORACLE_BASE}"/healthcheck.sh >/dev/null || exit 1 - -ENTRYPOINT ["container-entrypoint.sh"] diff --git a/docker/test/Dockerfile b/docker/test/Dockerfile new file mode 100644 index 000000000..1935f888e --- /dev/null +++ b/docker/test/Dockerfile @@ -0,0 +1,33 @@ +FROM gvenzl/oracle-free:23 AS oracle + +RUN chown -R 54321:54321 /opt/oracle/oradata && chmod 0777 /opt/oracle/oradata + +RUN ls + +# COPY ./container-entrypoint-custom.sh ./container-entrypoint-custom.sh +# RUN ["chmod", "+x", "container-entrypoint-custom.sh"] +# RUN ORACLE_PASSWORD=sys_user_password container-entrypoint-custom.sh + +FROM php:8.3-cli AS php + +COPY --from=oracle /opt/oracle/ /opt/oracle/ +COPY --from=oracle /usr/bin/7zzs /usr/bin/7zzs + +ENV PATH="$PATH:/opt/oracle/product/23ai/dbhomeFree/bin:/opt/oracle" + +RUN apt-get update && apt-get install -y \ + # Oracle + libaio1 + +ENV ORACLE_SID=FREE +ENV ORACLE_BASE=/opt/oracle +ENV ORACLE_HOME=/opt/oracle/product/23ai/dbhomeFree +ENV ORACLE_BASE_HOME=/opt/oracle/product/23ai/dbhomeFree +ENV NLS_LANG=.AL32UTF8 +ENV ORACLE_BASE_CONFIG=/opt/oracle/product/23ai/dbhomeFree + +RUN groupadd -g 54321 oracle +RUN useradd oracle -u 54321 -g 54321 -m -s /bin/bash +RUN chown -R 54321:54321 /opt/oracle + +# ENTRYPOINT ["/opt/oracle/container-entrypoint.sh"] diff --git a/docker/test1/Dockerfile b/docker/test1/Dockerfile new file mode 100644 index 000000000..3e01fa40e --- /dev/null +++ b/docker/test1/Dockerfile @@ -0,0 +1,16 @@ +FROM php:8.3-cli AS php + +FROM gvenzl/oracle-free:23 AS oracle + +COPY --from=php /usr/local/lib/php/ /usr/local/lib/php/ +COPY --from=php /usr/local/include/php/ /usr/local/include/php/ +COPY --from=php /usr/local/php/ /usr/local/php/ +COPY --from=php /usr/local/bin/php /usr/local/bin/php +COPY --from=php /usr/local/bin/php-config /usr/local/bin/php-config +COPY --from=php /usr/local/etc/php/ /usr/local/etc/php/ + +COPY --from=php /usr/lib/x86_64-linux-gnu/*.so* /usr/lib/x86_64-linux-gnu/ +COPY --from=php /usr/lib/x86_64-linux-gnu/*.so* /usr/lib64/ +COPY --from=php /usr/bin/ldd /usr/bin/ldd + +RUN chown -R 54321:54321 /opt/oracle/oradata && chmod 0777 /opt/oracle/oradata From c7e8975ab4bf1600339b2f2172eb1194d819e0af Mon Sep 17 00:00:00 2001 From: Alexey Rogachev Date: Mon, 2 Dec 2024 20:22:25 +0500 Subject: [PATCH 10/27] Cleanup --- docker-compose.yml | 246 ++++++++++++++------------------------- docker/oracle/Dockerfile | 27 +---- docker/test/Dockerfile | 33 ------ docker/test1/Dockerfile | 16 --- 4 files changed, 90 insertions(+), 232 deletions(-) delete mode 100644 docker/test/Dockerfile delete mode 100644 docker/test1/Dockerfile diff --git a/docker-compose.yml b/docker-compose.yml index 1a9563e2b..753bb5ba2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -42,173 +42,105 @@ services: APP_USER: my_user APP_USER_PASSWORD: password_i_should_change command: tail -F anything - php-oracle: + depends_on: + mysql: + condition: service_healthy + mariadb: + condition: service_healthy + postgres: + condition: service_healthy + mssql: + condition: service_healthy + oracle: + condition: service_healthy + mysql: + image: mysql:9 + ports: + - "3306:3306" + volumes: + - type: tmpfs + target: /var/lib/mysql + environment: + MYSQL_DATABASE: yii + MYSQL_ROOT_PASSWORD: root + MYSQL_ROOT_HOST: "%" + healthcheck: + test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost", "-uroot" ] + 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: "%" + MYSQL_TCP_PORT: 13306 + healthcheck: + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] + start_period: 10s + interval: 10s + timeout: 5s + retries: 30 + postgres: + image: postgres:17 + ports: + - "5432:5432" + volumes: + - type: tmpfs + target: /var/lib/postgresql/data + environment: + POSTGRES_DB: yii + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + healthcheck: + test: [ "CMD-SHELL", "pg_isready -U postgres" ] + interval: 5s + timeout: 5s + retries: 5 + mssql: + image: mcr.microsoft.com/mssql/server:2022-latest + ports: + - "1433:1433" + user: root + volumes: + - mssql-data:/var/opt/mssql/data + - mssql-log:/var/opt/mssql/log + - mssql-secrets:/var/opt/mssql/secrets + environment: + SA_PASSWORD: YourStrong!Passw0rd + ACCEPT_EULA: Y + 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: build: - context: docker/oracle + context: docker/oracle ports: - "1521:1521" volumes: - - ./src:/code/src - - ./tests:/code/tests - - ./composer.json:/code/composer.json - - ./phpunit.xml.dist:/code/phpunit.xml.dist - - php-oracle-data:/opt/oracle/oradata + - oracle-data:/opt/oracle/oradata environment: - YII_MYSQL_DATABASE: yii - YII_MYSQL_HOST: mysql - YII_MYSQL_PORT: 3306 - YII_MYSQL_USER: root - YII_MYSQL_PASSWORD: root - YII_MYSQL_TYPE: mysql - - YII_MARIADB_DATABASE: yii - YII_MARIADB_HOST: mariadb - YII_MARIADB_PORT: 13306 - YII_MARIADB_USER: root - YII_MARIADB_PASSWORD: root - - YII_PGSQL_DATABASE: yii - YII_PGSQL_HOST: postgres - YII_PGSQL_PORT: 5432 - YII_PGSQL_USER: postgres - YII_PGSQL_PASSWORD: postgres - - YII_MSSQL_DATABASE: tempdb - YII_MSSQL_HOST: mssql - YII_MSSQL_PORT: 1433 - YII_MSSQL_USER: SA - YII_MSSQL_PASSWORD: YourStrong!Passw0rd - - YII_ORACLE_SID: FREE - YII_ORACLE_HOST: 172.17.0.1 - YII_ORACLE_PORT: 1521 - YII_ORACLE_USER: system - YII_ORACLE_PASSWORD: sys_user_password - ORACLE_PASSWORD: sys_user_password APP_USER: my_user APP_USER_PASSWORD: password_i_should_change - command: tail -F anything -# depends_on: -# mysql: -# condition: service_healthy -# mariadb: -# condition: service_healthy -# postgres: -# condition: service_healthy -# mssql: -# condition: service_healthy -# oracle: -# condition: service_healthy -# mysql: -# image: mysql:9 -# ports: -# - "3306:3306" -# volumes: -# - type: tmpfs -# target: /var/lib/mysql -# environment: -# MYSQL_DATABASE: yii -# MYSQL_ROOT_PASSWORD: root -# MYSQL_ROOT_HOST: "%" -# healthcheck: -# test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost", "-uroot" ] -# 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: "%" -# MYSQL_TCP_PORT: 13306 -# healthcheck: -# test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] -# start_period: 10s -# interval: 10s -# timeout: 5s -# retries: 30 -# postgres: -# image: postgres:17 -# ports: -# - "5432:5432" -# volumes: -# - type: tmpfs -# target: /var/lib/postgresql/data -# environment: -# POSTGRES_DB: yii -# POSTGRES_USER: postgres -# POSTGRES_PASSWORD: postgres -# healthcheck: -# test: [ "CMD-SHELL", "pg_isready -U postgres" ] -# interval: 5s -# timeout: 5s -# retries: 5 -# mssql: -# image: mcr.microsoft.com/mssql/server:2022-latest -# ports: -# - "1433:1433" -# user: root -# volumes: -# - mssql-data:/var/opt/mssql/data -# - mssql-log:/var/opt/mssql/log -# - mssql-secrets:/var/opt/mssql/secrets -# environment: -# SA_PASSWORD: YourStrong!Passw0rd -# ACCEPT_EULA: Y -# 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: -# build: -# context: docker/oracle -# ports: -# - "1521:1521" -# volumes: -# - oracle-data:/opt/oracle/oradata -# environment: -# 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 -# test1: -# build: -# context: docker/test1 -# volumes: -# - test1-oracle-data:/opt/oracle/oradata -# environment: -# ORACLE_PASSWORD: sys_user_password -# APP_USER: my_user -# APP_USER_PASSWORD: password_i_should_change -# command: tail -F anything - # entrypoint: /opt/oracle/container-entrypoint.sh -# healthcheck: -# test: [ "CMD", "/opt/oracle/healthcheck.sh" ] -# interval: 10s -# timeout: 5s -# retries: 100 -# start_period: 5s -# start_interval: 5s + healthcheck: + test: ["CMD", "healthcheck.sh"] + interval: 10s + timeout: 5s + retries: 100 + start_period: 5s + start_interval: 5s volumes: - php-oracle-data: mssql-data: mssql-log: mssql-secrets: oracle-data: - # test-oracle-data: - test1-oracle-data: diff --git a/docker/oracle/Dockerfile b/docker/oracle/Dockerfile index a9b71e7ff..cc7e1498a 100644 --- a/docker/oracle/Dockerfile +++ b/docker/oracle/Dockerfile @@ -1,28 +1,3 @@ -FROM --platform=linux/amd64 db-php:latest AS php - -FROM gvenzl/oracle-free:23 AS oracle - -COPY --from=php /usr/local/lib/php/ /usr/local/lib/php/ -COPY --from=php /usr/local/include/php/ /usr/local/include/php/ -COPY --from=php /usr/local/php/ /usr/local/php/ -COPY --from=php /usr/local/bin/php /usr/local/bin/php -COPY --from=php /usr/local/bin/php-config /usr/local/bin/php-config -COPY --from=php /usr/local/etc/php/ /usr/local/etc/php/ - -COPY --from=php /usr/lib/x86_64-linux-gnu/*.so* /usr/lib/x86_64-linux-gnu/ -COPY --from=php /usr/lib/x86_64-linux-gnu/*.so* /usr/lib64/ - -COPY --from=php /opt/* /opt/ -COPY --from=php /usr/local/instantclient_23_5/ /usr/local/instantclient_23_5/ - -COPY --from=php /code/ /code/ - -COPY --from=php /root/.bashrc /root/.bashrc - -USER root -RUN ln -s /usr/local/instantclient_23_5 /usr/local/instantclient -RUN ln -s /usr/local/instantclient/lib* /usr/lib -RUN ln -s /usr/local/instantclient/sqlplus /usr/bin/sqlplus -USER oracle +FROM gvenzl/oracle-free:23 RUN chown -R 54321:54321 /opt/oracle/oradata && chmod 0777 /opt/oracle/oradata diff --git a/docker/test/Dockerfile b/docker/test/Dockerfile deleted file mode 100644 index 1935f888e..000000000 --- a/docker/test/Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -FROM gvenzl/oracle-free:23 AS oracle - -RUN chown -R 54321:54321 /opt/oracle/oradata && chmod 0777 /opt/oracle/oradata - -RUN ls - -# COPY ./container-entrypoint-custom.sh ./container-entrypoint-custom.sh -# RUN ["chmod", "+x", "container-entrypoint-custom.sh"] -# RUN ORACLE_PASSWORD=sys_user_password container-entrypoint-custom.sh - -FROM php:8.3-cli AS php - -COPY --from=oracle /opt/oracle/ /opt/oracle/ -COPY --from=oracle /usr/bin/7zzs /usr/bin/7zzs - -ENV PATH="$PATH:/opt/oracle/product/23ai/dbhomeFree/bin:/opt/oracle" - -RUN apt-get update && apt-get install -y \ - # Oracle - libaio1 - -ENV ORACLE_SID=FREE -ENV ORACLE_BASE=/opt/oracle -ENV ORACLE_HOME=/opt/oracle/product/23ai/dbhomeFree -ENV ORACLE_BASE_HOME=/opt/oracle/product/23ai/dbhomeFree -ENV NLS_LANG=.AL32UTF8 -ENV ORACLE_BASE_CONFIG=/opt/oracle/product/23ai/dbhomeFree - -RUN groupadd -g 54321 oracle -RUN useradd oracle -u 54321 -g 54321 -m -s /bin/bash -RUN chown -R 54321:54321 /opt/oracle - -# ENTRYPOINT ["/opt/oracle/container-entrypoint.sh"] diff --git a/docker/test1/Dockerfile b/docker/test1/Dockerfile deleted file mode 100644 index 3e01fa40e..000000000 --- a/docker/test1/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM php:8.3-cli AS php - -FROM gvenzl/oracle-free:23 AS oracle - -COPY --from=php /usr/local/lib/php/ /usr/local/lib/php/ -COPY --from=php /usr/local/include/php/ /usr/local/include/php/ -COPY --from=php /usr/local/php/ /usr/local/php/ -COPY --from=php /usr/local/bin/php /usr/local/bin/php -COPY --from=php /usr/local/bin/php-config /usr/local/bin/php-config -COPY --from=php /usr/local/etc/php/ /usr/local/etc/php/ - -COPY --from=php /usr/lib/x86_64-linux-gnu/*.so* /usr/lib/x86_64-linux-gnu/ -COPY --from=php /usr/lib/x86_64-linux-gnu/*.so* /usr/lib64/ -COPY --from=php /usr/bin/ldd /usr/bin/ldd - -RUN chown -R 54321:54321 /opt/oracle/oradata && chmod 0777 /opt/oracle/oradata From d03a8c2abd57c60296dc6a0e40c6f7237670e0b7 Mon Sep 17 00:00:00 2001 From: Alexey Rogachev Date: Mon, 2 Dec 2024 21:24:44 +0500 Subject: [PATCH 11/27] WIP --- Dockerfile | 2 +- Makefile | 39 +++++++++++++++++++-------------------- docs/internals.md | 4 ++++ 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5ae2baacc..2a2bd70b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM composer/composer:latest-bin AS composer -FROM php:8.3-cli as php +FROM php:8.3-cli # System packages diff --git a/Makefile b/Makefile index 74bc5a87f..0695f932b 100644 --- a/Makefile +++ b/Makefile @@ -1,38 +1,37 @@ run: - docker compose run --user root --rm --entrypoint $(CMD) php + docker compose run \ + --rm \ + --entrypoint $(CMD) \ + php -test-all: test-sqlite \ - test-mysql \ - test-mariadb \ - test-pgsql \ - test-mssql \ - test-oracle -test-sqlite: testsuite-Sqlite -test-mysql: testsuite-Mysql -test-mariadb: +test-driver-all: test-driver-sqlite \ + test-driver-mysql \ + test-driver-mariadb \ + test-driver-pgsql \ + test-driver-mssql \ + test-driver-oracle +test-driver-sqlite: testsuite-Sqlite +test-driver-mysql: testsuite-Mysql +test-driver-mariadb: docker compose run \ --rm \ - --entrypoint "vendor/bin/phpunit --testsuite Mysql" \ + --entrypoint "vendor/bin/phpunit --testsuite Mysql $(RUN_ARGS)" \ -e YII_MYSQL_TYPE=mariadb \ php -test-pgsql: testsuite-Pgsql -test-mssql: testsuite-Mssql -test-oracle: +test-driver-pgsql: testsuite-Pgsql +test-driver-mssql: testsuite-Mssql +test-driver-oracle: docker compose run \ - --user root \ - --workdir /code \ --rm \ --entrypoint "bash -c -l 'vendor/bin/phpunit --testsuite Oracle $(RUN_ARGS)'" \ - php-oracle + php testsuite-%: docker compose run \ --rm \ - --entrypoint "vendor/bin/phpunit --testsuite $(subst testsuite-,,$@)" \ + --entrypoint "vendor/bin/phpunit --testsuite $(subst testsuite-,,$@) $(RUN_ARGS)" \ php -# --filter showDatabases vendor/yiisoft/db-mssql/tests/CommandTest.php - static-analysis: CMD="vendor/bin/psalm --no-cache" static-analysis: run diff --git a/docs/internals.md b/docs/internals.md index 1d151b86e..9afe6c3e5 100644 --- a/docs/internals.md +++ b/docs/internals.md @@ -64,6 +64,10 @@ Suites available: - Pgsql - Sqlite +```shell +make test-oracle RUN_ARGS="--group temp" +``` + ## Static analysis The code is statically analyzed with [Psalm](https://psalm.dev/). To run static analysis: From 4498919a1c068cf0bc2f5ce1bf639c348563a1cf Mon Sep 17 00:00:00 2001 From: Alexey Rogachev Date: Tue, 3 Dec 2024 22:13:05 +0500 Subject: [PATCH 12/27] WIP --- Makefile | 12 +++-- docker-compose.yml | 1 + docs/internals.md | 118 +++++++++++++++++++++++++++------------------ 3 files changed, 81 insertions(+), 50 deletions(-) diff --git a/Makefile b/Makefile index 0695f932b..c93287468 100644 --- a/Makefile +++ b/Makefile @@ -4,12 +4,15 @@ run: --entrypoint $(CMD) \ php +test-all: test-base \ + test-driver-all test-driver-all: test-driver-sqlite \ test-driver-mysql \ test-driver-mariadb \ test-driver-pgsql \ test-driver-mssql \ test-driver-oracle +test-base: testsuite-Db test-driver-sqlite: testsuite-Sqlite test-driver-mysql: testsuite-Mysql test-driver-mariadb: @@ -32,9 +35,6 @@ testsuite-%: --entrypoint "vendor/bin/phpunit --testsuite $(subst testsuite-,,$@) $(RUN_ARGS)" \ php -static-analysis: CMD="vendor/bin/psalm --no-cache" -static-analysis: run - mutation: CMD="\ vendor/bin/roave-infection-static-analysis-plugin \ --threads=2 \ @@ -44,6 +44,12 @@ vendor/bin/roave-infection-static-analysis-plugin \ --only-covered" mutation: run +static-analysis: CMD="vendor/bin/psalm --no-cache" +static-analysis: run + +rector: CMD="vendor/bin/rector" +rector: run + composer-require-checker: CMD="vendor/bin/composer-require-checker" composer-require-checker: run diff --git a/docker-compose.yml b/docker-compose.yml index 753bb5ba2..8302c5846 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -33,6 +33,7 @@ services: YII_MSSQL_PASSWORD: YourStrong!Passw0rd YII_ORACLE_SID: FREE + YII_ORACLE_DATABASE: FREEPDB1 YII_ORACLE_HOST: oracle YII_ORACLE_PORT: 1521 YII_ORACLE_USER: system diff --git a/docs/internals.md b/docs/internals.md index 9afe6c3e5..53fe939b3 100644 --- a/docs/internals.md +++ b/docs/internals.md @@ -6,90 +6,114 @@ All our packages have github actions by default, so you can test your [contribut > Note: We recommend pull requesting in draft mode until all tests pass. -## Unit testing +## Local development -This package can be tested globally or individually for each DBMS. +Docker is used to ease the local development. -- [MSSQL](https://github.com/yiisoft/db-mssql) -- [MySQL/MariaDB](https://github.com/yiisoft/db-mysql) -- [Oracle](https://github.com/yiisoft/db-oracle) -- [PostgreSQL](https://github.com/yiisoft/db-pgsql) -- [SQLite](https://github.com/yiisoft/db-sqlite) +### Setup -### Docker images +Prerequisites: -For greater ease it is recommended to use Docker containers for each DBMS, for this you can use the [docker-compose.yml](https://docs.docker.com/compose/compose-file/) file that in the root directory of each package. +- Docker. +- Docker Compose. +- +Clone all repos of drivers' packages: -- [MSSQL 2022](https://github.com/yiisoft/db-mssql/blob/master/docker-compose.yml) -- [MySQL 8](https://github.com/yiisoft/db-mysql/blob/master/docker-compose.yml) -- [MariaDB 10.11](https://github.com/yiisoft/db-mysql/blob/master/docker-compose-mariadb.yml) -- [Oracle 21](https://github.com/yiisoft/db-oracle/blob/master/docker-compose.yml) -- [PostgreSQL 15](https://github.com/yiisoft/db-pgsql/blob/master/docker-compose.yml) +- [SQLite](https://github.com/yiisoft/db-sqlite) +- [MySQL](https://github.com/yiisoft/db-mysql) +- [PostgreSQL](https://github.com/yiisoft/db-pgsql) +- [Microsoft SQL Server](https://github.com/yiisoft/db-mssql) +- [Oracle](https://github.com/yiisoft/oracle) + +Create `docker-compose.override.yml` file in the root of the package. Add this contents: + +```yaml +services: + php: + volumes: + - /path/to/packages/db-sqlite:/code/vendor/yiisoft/db-sqlite + - /path/to/packages/db-mysql:/code/vendor/yiisoft/db-mysql + - /path/to/packages/db-pgsql:/code/vendor/yiisoft/db-pgsql + - /path/to/packages/db-mssql:/code/vendor/yiisoft/db-mssql + - /path/to/packages/db-oracle:/code/vendor/yiisoft/db-oracle +``` -For running the Docker containers you can use the following command: +Adjust the `/path/to/packages` to the path where packages are installed on your host machine. -```shell -docker compose up -d -``` +In case of ports' collisions, the mapping and enviroment variables can also be adjusted here. -### Global testing +### Unit testing -The following steps are required to run the tests. +#### Available commands -1. Run all Docker containers for each DBMS. -2. Install the dependencies of the project with composer. -3. Run the tests. +`make test-all` - run all available tests. +`make test-db` - run tests for base db package only. +`make test-driver-all` - run tests for all drivers. +`make test-driver-sqlite` - run tests for SQLite driver only. +`make test-driver-mysql` - run tests for MySQL driver only (using MySQL database). +`make test-driver-mariadb` - run tests for MySQL driver only (using MariaDB database). +`make test-driver-pgsql` - run tests for PostgreSQL driver only. +`make test-driver-mssql` - run tests for Microsoft SQL Server driver only. +`make test-driver-oracle`- run tsets for Oracle driver only. -```shell -./vendor/bin/phpunit -``` +#### Testing different versions -### Individual testing +Docker Compose services use the following stack: -The following steps are required to run the tests. +- PHP 8.3. +- MySQL 9. +- MariaDB 11. +- PostgreSQL 19. +- Microsoft SQL Server 2022. +- Oracle Free 23. -1. Run the Docker container for the dbms you want to test. -2. Install the dependencies of the project with composer. -3. Run the tests. +Different versions are available in GitHub Actions. Other versions of RDBMS might be added to Docker Compose in the +future. -```shell -./vendor/bin/phpunit --testsuite=Pgsql -``` +#### Slow execution time -Suites available: +Running `make` command for the first time can take some time due to building and/or starting all required Docker Compose +services. All subsequent calls will be faster. -- Mssql -- Mysql -- Oracle -- Pgsql -- Sqlite +The execution time of Oracle tests is the longest. The recommended flow is to run only changed / added tests. Add +`@group temp` PHPDoc annotation to changed / added tests temporarily. Then you can limit running tests with the +following command: ```shell -make test-oracle RUN_ARGS="--group temp" +make test-driver-oracle RUN_ARGS="--group temp" ``` -## Static analysis +Don't forget to remove the temporary `@group` tags before marking PR as ready for review. + +Avoid mixing changes for altering test structure with actual changes in test code. + +### Static analysis The code is statically analyzed with [Psalm](https://psalm.dev/). To run static analysis: ```shell -./vendor/bin/psalm +make static-analysis ``` -## Code style +### Code style Use [Rector](https://github.com/rectorphp/rector) to make codebase follow some specific rules or use either newest or any specific version of PHP: ```shell -./vendor/bin/rector +make rector ``` -## Dependencies +### Dependencies This package uses [composer-require-checker](https://github.com/maglnet/ComposerRequireChecker) to check if all dependencies are correctly defined in `composer.json`. To run the checker, execute the following command: ```shell -./vendor/bin/composer-require-checker +make composer-require-checker ``` + +### Miscellaneous commands + +`make shell` - open interactive shell. +`make run command` - run arbitrary command. From 82b078a0aabb5b3b4264df218892a26499677cfd Mon Sep 17 00:00:00 2001 From: Alexey Rogachev Date: Tue, 3 Dec 2024 22:22:16 +0500 Subject: [PATCH 13/27] WIP --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index f179fcdd0..c7dbc2e02 100644 --- a/composer.json +++ b/composer.json @@ -62,6 +62,7 @@ "autoload-dev": { "psr-4": { "Yiisoft\\ActiveRecord\\": "vendor/yiisoft/active-record/src", + "Yiisoft\\Db\\Migration": "vendor/yiisoft/db-migration/src", "Yiisoft\\Db\\Mssql\\": "vendor/yiisoft/db-mssql/src", "Yiisoft\\Db\\Mysql\\": "vendor/yiisoft/db-mysql/src", "Yiisoft\\Db\\Oracle\\": "vendor/yiisoft/db-oracle/src", From 95bfdb714cb599e8273dbd7c315f63374084f668 Mon Sep 17 00:00:00 2001 From: Alexey Rogachev Date: Tue, 3 Dec 2024 22:31:50 +0500 Subject: [PATCH 14/27] WIP --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c7dbc2e02..bf75d7cc3 100644 --- a/composer.json +++ b/composer.json @@ -62,7 +62,7 @@ "autoload-dev": { "psr-4": { "Yiisoft\\ActiveRecord\\": "vendor/yiisoft/active-record/src", - "Yiisoft\\Db\\Migration": "vendor/yiisoft/db-migration/src", + "Yiisoft\\Db\\Migration\\": "vendor/yiisoft/db-migration/src", "Yiisoft\\Db\\Mssql\\": "vendor/yiisoft/db-mssql/src", "Yiisoft\\Db\\Mysql\\": "vendor/yiisoft/db-mysql/src", "Yiisoft\\Db\\Oracle\\": "vendor/yiisoft/db-oracle/src", From 9cb425c5324e6816658b2947f6dd48dc51cbe0ad Mon Sep 17 00:00:00 2001 From: Alexey Rogachev Date: Thu, 5 Dec 2024 20:07:13 +0500 Subject: [PATCH 15/27] make help [skip ci] --- Makefile | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index c93287468..e7d0e2045 100644 --- a/Makefile +++ b/Makefile @@ -1,29 +1,29 @@ -run: +run: ## Run arbitrary command. docker compose run \ --rm \ --entrypoint $(CMD) \ php -test-all: test-base \ +test-all: test-base \ ## Run all available tests. test-driver-all -test-driver-all: test-driver-sqlite \ +test-driver-all: test-driver-sqlite \ ## Run tests for all drivers. test-driver-mysql \ test-driver-mariadb \ test-driver-pgsql \ test-driver-mssql \ test-driver-oracle -test-base: testsuite-Db -test-driver-sqlite: testsuite-Sqlite -test-driver-mysql: testsuite-Mysql -test-driver-mariadb: +test-base: testsuite-Db ## Run tests for base db package only. +test-driver-sqlite: testsuite-Sqlite ## Run tests for SQLite driver only. +test-driver-mysql: testsuite-Mysql ## Run tests for MySQL driver only (using MySQL database). +test-driver-mariadb: ## Run tests for MySQL driver only (using MariaDB database). docker compose run \ --rm \ --entrypoint "vendor/bin/phpunit --testsuite Mysql $(RUN_ARGS)" \ -e YII_MYSQL_TYPE=mariadb \ php -test-driver-pgsql: testsuite-Pgsql -test-driver-mssql: testsuite-Mssql -test-driver-oracle: +test-driver-pgsql: testsuite-Pgsql ## Run tests for PostgreSQL driver only. +test-driver-mssql: testsuite-Mssql ## Run tests for Microsoft SQL Server driver only. +test-driver-oracle: ## Run tsets for Oracle driver only. docker compose run \ --rm \ --entrypoint "bash -c -l 'vendor/bin/phpunit --testsuite Oracle $(RUN_ARGS)'" \ @@ -41,17 +41,22 @@ vendor/bin/roave-infection-static-analysis-plugin \ --min-msi=0 \ --min-covered-msi=100 \ --ignore-msi-with-no-mutations \ ---only-covered" +--only-covered" ## Run mutation tests using Infection. mutation: run -static-analysis: CMD="vendor/bin/psalm --no-cache" +static-analysis: CMD="vendor/bin/psalm --no-cache" ## Run static analysis using Psalm. static-analysis: run -rector: CMD="vendor/bin/rector" +rector: CMD="vendor/bin/rector" ## Check code style using Rector. rector: run -composer-require-checker: CMD="vendor/bin/composer-require-checker" +composer-require-checker: CMD="vendor/bin/composer-require-checker" ## Check dependencies using Composer Require Checker. composer-require-checker: run -shell: CMD="bash" +shell: CMD="bash" ## Open interactive shell. shell: run + +.PHONY: help +help: ## This help. + @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) +.DEFAULT_GOAL := help From 2b623c19aaa0e470e99fbc3577626168c5454142 Mon Sep 17 00:00:00 2001 From: Alexey Rogachev Date: Fri, 6 Dec 2024 21:04:56 +0500 Subject: [PATCH 16/27] Move the rest of Docker related files to docker folder --- .gitignore | 2 +- Dockerfile => docker/Dockerfile | 2 +- docker-compose.yml => docker/docker-compose.yml | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) rename Dockerfile => docker/Dockerfile (99%) rename docker-compose.yml => docker/docker-compose.yml (95%) diff --git a/.gitignore b/.gitignore index d800ee125..ddce887d8 100644 --- a/.gitignore +++ b/.gitignore @@ -46,4 +46,4 @@ phpunit.phar c3.php # Docker -docker-compose.override.yml +docker/docker-compose.override.yml diff --git a/Dockerfile b/docker/Dockerfile similarity index 99% rename from Dockerfile rename to docker/Dockerfile index 2a2bd70b3..c2a016c4a 100644 --- a/Dockerfile +++ b/docker/Dockerfile @@ -80,7 +80,7 @@ COPY --from=composer /composer /usr/bin/composer # Code -COPY . /code +COPY .. /code WORKDIR /code # PHP packages diff --git a/docker-compose.yml b/docker/docker-compose.yml similarity index 95% rename from docker-compose.yml rename to docker/docker-compose.yml index 8302c5846..5e00dd8b5 100644 --- a/docker-compose.yml +++ b/docker/docker-compose.yml @@ -2,10 +2,10 @@ services: php: build: . volumes: - - ./src:/code/src - - ./tests:/code/tests - - ./composer.json:/code/composer.json - - ./phpunit.xml.dist:/code/phpunit.xml.dist + - ./../src:/code/src + - ./../tests:/code/tests + - ./../composer.json:/code/composer.json + - ./../phpunit.xml.dist:/code/phpunit.xml.dist environment: YII_MYSQL_DATABASE: yii YII_MYSQL_HOST: mysql @@ -124,7 +124,7 @@ services: start_period: 10s oracle: build: - context: docker/oracle + context: oracle ports: - "1521:1521" volumes: From 4afa91d0a26ff749aa9ac73efbd46391e194bf71 Mon Sep 17 00:00:00 2001 From: Alexey Rogachev Date: Fri, 6 Dec 2024 21:46:38 +0500 Subject: [PATCH 17/27] WIP [skip ci] --- docker/Dockerfile | 4 ++-- docker/docker-compose.yml | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index c2a016c4a..1d2ca6e18 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -80,9 +80,9 @@ COPY --from=composer /composer /usr/bin/composer # Code -COPY .. /code +COPY . /code WORKDIR /code # PHP packages -RUN composer install +RUN COMPOSER_ALLOW_SUPERUSER=1 composer install diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 5e00dd8b5..5050af55e 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,11 +1,13 @@ services: php: - build: . + build: + context: ./.. + dockerfile: ./docker/Dockerfile volumes: - - ./../src:/code/src - - ./../tests:/code/tests - - ./../composer.json:/code/composer.json - - ./../phpunit.xml.dist:/code/phpunit.xml.dist + - ./src:/code/src + - ./tests:/code/tests + - ./composer.json:/code/composer.json + - ./phpunit.xml.dist:/code/phpunit.xml.dist environment: YII_MYSQL_DATABASE: yii YII_MYSQL_HOST: mysql From 397c3c3b5d99462112e127e7786670897055eb8c Mon Sep 17 00:00:00 2001 From: Alexey Rogachev Date: Fri, 6 Dec 2024 21:57:14 +0500 Subject: [PATCH 18/27] Adjust .gitattributes [skip ci] --- .gitattributes | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitattributes b/.gitattributes index e2b21a8d7..c5e9f777f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -21,15 +21,15 @@ *.gif binary *.ttf binary -# Ignore some meta files when creating an archive of this repository +# Ignore some files when creating an archive of this repository /.github export-ignore /.editorconfig export-ignore /.gitattributes export-ignore /.gitignore export-ignore /phpunit.xml.dist export-ignore +/docker export-ignore /docs export-ignore # Avoid merge conflicts in CHANGELOG # https://about.gitlab.com/2015/02/10/gitlab-reduced-merge-conflicts-by-90-percent-with-changelog-placeholders/ /CHANGELOG.md merge=union - From 80870e8d1dc914913ea8c8c565619bee09d998e8 Mon Sep 17 00:00:00 2001 From: Alexey Rogachev Date: Fri, 6 Dec 2024 22:22:10 +0500 Subject: [PATCH 19/27] WIP [skip ci] --- Makefile | 8 ++++---- docker/docker-compose.yml | 8 ++++---- docs/internals.md | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index e7d0e2045..32aa06c74 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ run: ## Run arbitrary command. - docker compose run \ + docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml run \ --rm \ --entrypoint $(CMD) \ php @@ -16,7 +16,7 @@ test-base: testsuite-Db ## Run tests for base db package only. test-driver-sqlite: testsuite-Sqlite ## Run tests for SQLite driver only. test-driver-mysql: testsuite-Mysql ## Run tests for MySQL driver only (using MySQL database). test-driver-mariadb: ## Run tests for MySQL driver only (using MariaDB database). - docker compose run \ + docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml run \ --rm \ --entrypoint "vendor/bin/phpunit --testsuite Mysql $(RUN_ARGS)" \ -e YII_MYSQL_TYPE=mariadb \ @@ -24,13 +24,13 @@ test-driver-mariadb: ## Run tests for MySQL driver only (using MariaDB database) test-driver-pgsql: testsuite-Pgsql ## Run tests for PostgreSQL driver only. test-driver-mssql: testsuite-Mssql ## Run tests for Microsoft SQL Server driver only. test-driver-oracle: ## Run tsets for Oracle driver only. - docker compose run \ + docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml run \ --rm \ --entrypoint "bash -c -l 'vendor/bin/phpunit --testsuite Oracle $(RUN_ARGS)'" \ php testsuite-%: - docker compose run \ + docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml run \ --rm \ --entrypoint "vendor/bin/phpunit --testsuite $(subst testsuite-,,$@) $(RUN_ARGS)" \ php diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 5050af55e..097ce046c 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -4,10 +4,10 @@ services: context: ./.. dockerfile: ./docker/Dockerfile volumes: - - ./src:/code/src - - ./tests:/code/tests - - ./composer.json:/code/composer.json - - ./phpunit.xml.dist:/code/phpunit.xml.dist + - ./../src:/code/src + - ./../tests:/code/tests + - ./../composer.json:/code/composer.json + - ./../phpunit.xml.dist:/code/phpunit.xml.dist environment: YII_MYSQL_DATABASE: yii YII_MYSQL_HOST: mysql diff --git a/docs/internals.md b/docs/internals.md index 53fe939b3..cafb9ad51 100644 --- a/docs/internals.md +++ b/docs/internals.md @@ -25,7 +25,7 @@ Clone all repos of drivers' packages: - [Microsoft SQL Server](https://github.com/yiisoft/db-mssql) - [Oracle](https://github.com/yiisoft/oracle) -Create `docker-compose.override.yml` file in the root of the package. Add this contents: +Create `docker/docker-compose.override.yml` file with this content: ```yaml services: From 167406a82a64e0446c131a0465a440644feb6dcf Mon Sep 17 00:00:00 2001 From: Alexey Rogachev Date: Mon, 9 Dec 2024 13:45:57 +0500 Subject: [PATCH 20/27] Add name in docker compose [skip ci] --- docker/docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 097ce046c..b51daf72c 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,3 +1,4 @@ +name: yiisoft-db services: php: build: From f573a62d8fd7b6a0440054e99d231f4ac2081e95 Mon Sep 17 00:00:00 2001 From: Alexey Rogachev Date: Mon, 9 Dec 2024 13:50:17 +0500 Subject: [PATCH 21/27] Update docs/internals.md Co-authored-by: Sergei Tigrov --- docs/internals.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/internals.md b/docs/internals.md index cafb9ad51..cbafe3401 100644 --- a/docs/internals.md +++ b/docs/internals.md @@ -14,9 +14,9 @@ Docker is used to ease the local development. Prerequisites: -- Docker. -- Docker Compose. -- +- [Docker](https://docs.docker.com/get-started/get-docker/) +- [Docker Compose](https://docs.docker.com/compose/install/) + Clone all repos of drivers' packages: - [SQLite](https://github.com/yiisoft/db-sqlite) From 890ee0bf18aacf43c5a4def422faa02b553754f8 Mon Sep 17 00:00:00 2001 From: Alexey Rogachev Date: Mon, 9 Dec 2024 14:45:25 +0500 Subject: [PATCH 22/27] WIP [skip ci] --- Makefile | 30 ++++++++++++++++++++++-------- docs/internals.md | 41 ++++++++++++++++++++++++++++------------- 2 files changed, 50 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 32aa06c74..278d48cff 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,31 @@ +.PHONY: help +help: ## Show the list of available commands with description. + @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) +.DEFAULT_GOAL := help + +build: ## Build services. + docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml build +up: ## Start services. + docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml up -d --remove-orphans +build-up: # Build and start services. + docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml up -d --remove-orphans --build +stop: ## Stop running services. + docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml stop +down: ## Stop running services and remove all services (not defined services, containers, networks, volumes, images). + docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml down \ + --remove-orphans \ + --volumes \ + --rmi + run: ## Run arbitrary command. docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml run \ --rm \ --entrypoint $(CMD) \ php +shell: CMD="bash" ## Open interactive shell. +shell: run + test-all: test-base \ ## Run all available tests. test-driver-all test-driver-all: test-driver-sqlite \ ## Run tests for all drivers. @@ -52,11 +74,3 @@ rector: run composer-require-checker: CMD="vendor/bin/composer-require-checker" ## Check dependencies using Composer Require Checker. composer-require-checker: run - -shell: CMD="bash" ## Open interactive shell. -shell: run - -.PHONY: help -help: ## This help. - @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) -.DEFAULT_GOAL := help diff --git a/docs/internals.md b/docs/internals.md index cbafe3401..531f80988 100644 --- a/docs/internals.md +++ b/docs/internals.md @@ -46,15 +46,15 @@ In case of ports' collisions, the mapping and enviroment variables can also be a #### Available commands -`make test-all` - run all available tests. -`make test-db` - run tests for base db package only. -`make test-driver-all` - run tests for all drivers. -`make test-driver-sqlite` - run tests for SQLite driver only. -`make test-driver-mysql` - run tests for MySQL driver only (using MySQL database). -`make test-driver-mariadb` - run tests for MySQL driver only (using MariaDB database). -`make test-driver-pgsql` - run tests for PostgreSQL driver only. -`make test-driver-mssql` - run tests for Microsoft SQL Server driver only. -`make test-driver-oracle`- run tsets for Oracle driver only. +- `make test-all` - run all available tests. +- `make test-db` - run tests for base db package only. +- `make test-driver-all` - run tests for all drivers. +- `make test-driver-sqlite` - run tests for SQLite driver only. +- `make test-driver-mysql` - run tests for MySQL driver only (using MySQL database). +- `make test-driver-mariadb` - run tests for MySQL driver only (using MariaDB database). +- `make test-driver-pgsql` - run tests for PostgreSQL driver only. +- `make test-driver-mssql` - run tests for Microsoft SQL Server driver only. +- `make test-driver-oracle`- run tsets for Oracle driver only. #### Testing different versions @@ -87,6 +87,14 @@ Don't forget to remove the temporary `@group` tags before marking PR as ready fo Avoid mixing changes for altering test structure with actual changes in test code. +### Mutation testing + +The package tests are checked with Infection mutation framework with Infection Static Analysis Plugin. To run it: + +```shell +make mutation +``` + ### Static analysis The code is statically analyzed with [Psalm](https://psalm.dev/). To run static analysis: @@ -113,7 +121,14 @@ dependencies are correctly defined in `composer.json`. To run the checker, execu make composer-require-checker ``` -### Miscellaneous commands - -`make shell` - open interactive shell. -`make run command` - run arbitrary command. +### Other commands + +- `make help` / `make` - show the list of available commands with description. +- `make build` - build services. +- `make up` - start services. +- `make build-up` - build and start services. +- `make stop` - stop running services. +- `make down` - stop running services and remove all services (not defined services, containers, networks, volumes, +images). +- `make run command` - run arbitrary command. +- `make shell` - open interactive shell. From 7b32101a2a4300465e7fe116a317a059ff92e4ee Mon Sep 17 00:00:00 2001 From: Alexey Rogachev Date: Mon, 9 Dec 2024 20:52:39 +0500 Subject: [PATCH 23/27] WIP [skip ci] --- Makefile | 4 +++- docs/internals.md | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 278d48cff..df0cc85f5 100644 --- a/Makefile +++ b/Makefile @@ -9,13 +9,15 @@ up: ## Start services. docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml up -d --remove-orphans build-up: # Build and start services. docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml up -d --remove-orphans --build +ps: ## List running services + docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml ps stop: ## Stop running services. docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml stop down: ## Stop running services and remove all services (not defined services, containers, networks, volumes, images). docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml down \ --remove-orphans \ --volumes \ - --rmi + --rmi all run: ## Run arbitrary command. docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml run \ diff --git a/docs/internals.md b/docs/internals.md index 531f80988..5a9405c0c 100644 --- a/docs/internals.md +++ b/docs/internals.md @@ -127,6 +127,7 @@ make composer-require-checker - `make build` - build services. - `make up` - start services. - `make build-up` - build and start services. +- `make ps` - list running services. - `make stop` - stop running services. - `make down` - stop running services and remove all services (not defined services, containers, networks, volumes, images). From 6da0e5bc78129db42cded181a2dec7e90bb777aa Mon Sep 17 00:00:00 2001 From: Alexey Rogachev Date: Mon, 9 Dec 2024 21:17:31 +0500 Subject: [PATCH 24/27] Windows docs [skip ci] --- docs/internals.md | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/docs/internals.md b/docs/internals.md index 5a9405c0c..56ce6f981 100644 --- a/docs/internals.md +++ b/docs/internals.md @@ -10,12 +10,24 @@ All our packages have github actions by default, so you can test your [contribut Docker is used to ease the local development. -### Setup +## Prerequisites: + +### Docker Compose + +Install [Docker](https://docs.docker.com/get-started/get-docker/) with +[Docker Compose](https://docs.docker.com/compose/install/). -Prerequisites: +### make -- [Docker](https://docs.docker.com/get-started/get-docker/) -- [Docker Compose](https://docs.docker.com/compose/install/) +make is required for running commands. To get it working on Windows, some of the options are: + +- It ships with [Git BASH](https://git-scm.com/downloads/win). +- Installation using [Chocolatey](https://chocolatey.org). [Install](https://chocolatey.org/install) Chocolatey first, +then run `choco install make`. +- It is available within [Cygwin](https://www.cygwin.com/). +- Use [WSL](https://learn.microsoft.com/en-us/windows/wsl/install). + +### Setup Clone all repos of drivers' packages: From fb83e8b809801f25ea99cd17fcc8d61d774f7060 Mon Sep 17 00:00:00 2001 From: Alexey Rogachev Date: Tue, 10 Dec 2024 20:13:41 +0500 Subject: [PATCH 25/27] Update docs/internals.md Co-authored-by: Sergei Predvoditelev --- docs/internals.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/internals.md b/docs/internals.md index 56ce6f981..760b3211b 100644 --- a/docs/internals.md +++ b/docs/internals.md @@ -59,7 +59,7 @@ In case of ports' collisions, the mapping and enviroment variables can also be a #### Available commands - `make test-all` - run all available tests. -- `make test-db` - run tests for base db package only. +- `make test-base` - run tests for base db package only. - `make test-driver-all` - run tests for all drivers. - `make test-driver-sqlite` - run tests for SQLite driver only. - `make test-driver-mysql` - run tests for MySQL driver only (using MySQL database). From 3edb0ba69de9ed1b91334b1dbdbb7787f10babd3 Mon Sep 17 00:00:00 2001 From: Alexey Rogachev Date: Tue, 10 Dec 2024 20:13:59 +0500 Subject: [PATCH 26/27] Update docs/internals.md Co-authored-by: Sergei Predvoditelev --- docs/internals.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/internals.md b/docs/internals.md index 760b3211b..ab0583d16 100644 --- a/docs/internals.md +++ b/docs/internals.md @@ -52,7 +52,7 @@ services: Adjust the `/path/to/packages` to the path where packages are installed on your host machine. -In case of ports' collisions, the mapping and enviroment variables can also be adjusted here. +In case of ports' collisions, the mapping and environment variables can also be adjusted here. ### Unit testing From 1d5491a61a9c0c24eb5cb87f7011101e8fa16a42 Mon Sep 17 00:00:00 2001 From: Alexey Rogachev Date: Tue, 10 Dec 2024 23:26:50 +0500 Subject: [PATCH 27/27] Fix [skip ci] --- Makefile | 10 +++++----- docs/internals.md | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index df0cc85f5..814e74e0a 100644 --- a/Makefile +++ b/Makefile @@ -28,14 +28,14 @@ run: ## Run arbitrary command. shell: CMD="bash" ## Open interactive shell. shell: run -test-all: test-base \ ## Run all available tests. - test-driver-all -test-driver-all: test-driver-sqlite \ ## Run tests for all drivers. +test-all: test-base \ + test-driver-all ## Run all available tests. +test-driver-all: test-driver-sqlite \ test-driver-mysql \ test-driver-mariadb \ test-driver-pgsql \ test-driver-mssql \ - test-driver-oracle + test-driver-oracle ## Run tests for all drivers. test-base: testsuite-Db ## Run tests for base db package only. test-driver-sqlite: testsuite-Sqlite ## Run tests for SQLite driver only. test-driver-mysql: testsuite-Mysql ## Run tests for MySQL driver only (using MySQL database). @@ -47,7 +47,7 @@ test-driver-mariadb: ## Run tests for MySQL driver only (using MariaDB database) php test-driver-pgsql: testsuite-Pgsql ## Run tests for PostgreSQL driver only. test-driver-mssql: testsuite-Mssql ## Run tests for Microsoft SQL Server driver only. -test-driver-oracle: ## Run tsets for Oracle driver only. +test-driver-oracle: ## Run tests for Oracle driver only. docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml run \ --rm \ --entrypoint "bash -c -l 'vendor/bin/phpunit --testsuite Oracle $(RUN_ARGS)'" \ diff --git a/docs/internals.md b/docs/internals.md index 56ce6f981..6a96e2c0b 100644 --- a/docs/internals.md +++ b/docs/internals.md @@ -66,7 +66,7 @@ In case of ports' collisions, the mapping and enviroment variables can also be a - `make test-driver-mariadb` - run tests for MySQL driver only (using MariaDB database). - `make test-driver-pgsql` - run tests for PostgreSQL driver only. - `make test-driver-mssql` - run tests for Microsoft SQL Server driver only. -- `make test-driver-oracle`- run tsets for Oracle driver only. +- `make test-driver-oracle`- run tests for Oracle driver only. #### Testing different versions