Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
arogachev committed Oct 24, 2024
1 parent ee5cef6 commit bdd6acc
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 51 deletions.
33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
3 changes: 0 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
99 changes: 54 additions & 45 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions tests/.env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bdd6acc

Please sign in to comment.