diff --git a/Dockerfile b/Dockerfile index 8901426..e4d223a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,6 +33,39 @@ RUN apt-get update && apt-get install -y unzip libaio1 RUN apt-get update && apt-get install -y libpq-dev RUN docker-php-ext-install pdo_mysql pdo_pgsql +# MSSQL + +ENV ACCEPT_EULA=Y + +# Install prerequisites required for tools and extensions installed later on. +RUN apt-get update \ + && apt-get install -y apt-transport-https gnupg2 libpng-dev libzip-dev nano \ + && rm -rf /var/lib/apt/lists/* + +# 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/* + +#RUN apt-get update && apt-get install -y unixodbc-dev +#RUN curl https://packages.microsoft.com/keys/microsoft.asc | tee /etc/apt/trusted.gpg.d/microsoft.asc +#RUN apt-get update && ACCEPT_EULA=Y apt-get install -y msodbcsql18 + +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 diff --git a/Makefile b/Makefile index 9e7f584..6362979 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ test-all: vendor/bin/phpunit --testsuite Sqlite,Mysql,Pgsql,Mssql,Oracle 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 test-temp: vendor/bin/phpunit --testsuite Mysql --filter testOffset tests/Mysql/QueryDataReaderTest.php diff --git a/composer.json b/composer.json index e0c887b..94926f7 100644 --- a/composer.json +++ b/composer.json @@ -49,9 +49,6 @@ "yiisoft/db-pgsql": "^1.3", "yiisoft/db-sqlite": "^1.2" }, - "provide": { - "ext-pdo_pgsql": "*" - }, "autoload": { "psr-4": { "Yiisoft\\Data\\Db\\": "src" diff --git a/docker-compose.yml b/docker-compose.yml index 7bbf8a3..f9722fc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,51 +6,60 @@ services: - ./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 +# 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: - POSTGRES_DB: yii - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - healthcheck: - test: [ "CMD-SHELL", "pg_isready -U postgres" ] - interval: 5s - timeout: 5s - retries: 5 - oracle: - image: gvenzl/oracle-xe:21 + SA_PASSWORD: YourStrong!Passw0rd + ACCEPT_EULA: Y ports: - - "1521:1521" + - "1433:1433" expose: - - "1521" - environment: - ORACLE_PASSWORD : root - ORACLE_DATABASE : yiitest - APP_USER: yiitest - APP_USER_PASSWORD: root + - "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 diff --git a/tests/.env b/tests/.env index d2a159a..8a6f71b 100644 --- a/tests/.env +++ b/tests/.env @@ -11,10 +11,10 @@ YII_PGSQL_USER=postgres YII_PGSQL_PASSWORD=postgres YII_MSSQL_DATABASE=tempdb -YII_MSSQL_HOST=127.0.0.1 -YII_MSSQL_PORT=11433 +YII_MSSQL_HOST=mssql +YII_MSSQL_PORT=1433 YII_MSSQL_USER=SA -YII_MSSQL_PASSWORD=SSpaSS__1 +YII_MSSQL_PASSWORD=YourStrong!Passw0rd YII_ORACLE_DATABASE= YII_ORACLE_HOST=oracle