Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.14.x added tests for Oracle and docker for local development #227

Open
wants to merge 15 commits into
base: 2.14.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
/laminas-mkdoc-theme/
/phpunit.xml
/vendor/
/tmp
1 change: 1 addition & 0 deletions .local/mssql/2019/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/db
6 changes: 6 additions & 0 deletions .local/mssql/2019/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM mcr.microsoft.com/mssql/server:2019-CU13-ubuntu-20.04
#------------------------------------------------------------------------------
WORKDIR /app
COPY ./app /app
ENTRYPOINT /app/entrypoint.sh
#------------------------------------------------------------------------------
25 changes: 25 additions & 0 deletions .local/mssql/2019/app/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

_setup() {
for _ in {1..60}; do
if /opt/mssql-tools/bin/sqlcmd -S 127.0.0.1 -U sa -P "$SA_PASSWORD" -d master -i scripts/setup.sql; then
break
fi
echo "Server is not ready..."
sleep 1
done
}

echo "Starting SQL-Server on 127.0.0.1"
/opt/mssql/bin/mssql-conf set network.ipaddress 127.0.0.1
/opt/mssql/bin/sqlservr &
_setup

echo "Setup finished. Stopping SQL-Server..."
pid=$(pgrep -o sqlservr)
kill "$pid"
tail --pid="$pid" -f /dev/null

echo "Starting SQL-Server on 0.0.0.0"
/opt/mssql/bin/mssql-conf set network.ipaddress 0.0.0.0
/opt/mssql/bin/sqlservr
1 change: 1 addition & 0 deletions .local/mssql/2019/app/scripts/setup.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE DATABASE laminasdb_test;
27 changes: 27 additions & 0 deletions .local/mssql/2019/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
#------------------------------------------------------------------------------
cd $(dirname $(readlink -e $0))
#------------------------------------------------------------------------------
imgName='local/laminas-db-test-mssql:2019'

# docker image rm -f ${imgName}

# Create image on local computer
docker build --tag ${imgName} .
if [ ! "$?" == "0" ]; then
echo "-- Error build image ${imgName}"
exit 1
fi

# Push local image to dockerhub
#echo '--push image'
#docker login
#docker push ${imgName}
#if [ ! "$?" == "0" ]; then
# echo "-- Error push image ${imgName}"
# exit 1
#fi
#------------------------------------------------------------------------------
echo 'docker0 host is'
ifconfig docker0 | grep "inet "
#------------------------------------------------------------------------------
34 changes: 34 additions & 0 deletions .local/mssql/2019/docker-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
#------------------------------------------------------------------------------
set -e
cd $(dirname $(readlink -e $0))
#------------------------------------------------------------------------------
# @see https://hub.docker.com/_/microsoft-mssql-server
# @see https://github.com/Microsoft/mssql-docker
#----
#imageName='mcr.microsoft.com/mssql/server:2019-CU13-ubuntu-20.04'
imageName='local/laminas-db-test-mssql:2019'

SA_PASSWORD='Password123'
appDir=$(pwd)/app
dbDir=$(pwd)/db
if [ ! -d ${dbDir} ]; then
mkdir ${dbDir}
chmod 777 ${dbDir}
fi

#------------------------------------------------------------------------------
# RUN image and create database, user, schema.
#-----

# --user 1000:1000 \
docker run --rm -ti \
--name 'tmp.ldbt_mssql_2019' \
-p 1433:1433 \
-e ACCEPT_EULA=Y \
-e SA_PASSWORD=${SA_PASSWORD} \
-v ${appDir}:/app \
-v ${dbDir}:/var/opt/mssql/data \
${imageName}

#------------------------------------------------------------------------------
1 change: 1 addition & 0 deletions .local/mysql/8/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/db
42 changes: 42 additions & 0 deletions .local/mysql/8/docker-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
#------------------------------------------------------------------------------
set -e
cd $(dirname $(readlink -e $0))
#------------------------------------------------------------------------------
# @see https://hub.docker.com/_/mysql?tab=description
# @see https://github.com/docker-library/mysql
# @see https://github.com/docker-library/mysql/blob/master/8.0/docker-entrypoint.sh
# @see https://github.com/docker-library/mysql/blob/master/8.0/Dockerfile.debian
#----

imageName=mysql:8.0.27

MYSQL_ROOT_PASSWORD='Password123'
MYSQL_DATABASE='laminasdb_test'
MYSQL_USER='root'
MYSQL_PASSWORD='Password123'

dbDir=$(pwd)/db
if [ ! -d ${dbDir} ]; then
mkdir ${dbDir}
chmod 777 ${dbDir}
fi

#------------------------------------------------------------------------------
# RUN image and create database, user, schema.
#-----

# -e MYSQL_USER=${MYSQL_USER} \

docker run --rm -ti \
--name tmp.ldbt_mysql \
--user 1000:1000 \
-p 3306:3306 \
-p 33060:33060 \
-e MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} \
-e MYSQL_DATABASE=${MYSQL_DATABASE} \
-e MYSQL_PASSWORD=${MYSQL_PASSWORD} \
-v ${dbDir}:/var/lib/mysql \
${imageName}

#------------------------------------------------------------------------------
1 change: 1 addition & 0 deletions .local/oracle-xe/11/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/db
65 changes: 65 additions & 0 deletions .local/oracle-xe/11/docker-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash
#------------------------------------------------------------------------------
set -e
cd $(dirname $(readlink -e $0))
#------------------------------------------------------------------------------
# @see https://github.com/gvenzl/oci-oracle-xe
# @see https://github.com/gvenzl/oci-oracle-xe/blob/main/container-entrypoint.sh
# @see https://github.com/gvenzl/oci-oracle-xe/blob/main/Dockerfile.1840
# @see https://github.com/gvenzl/oci-oracle-xe/blob/main/install.1840.sh
#
# FROM oraclelinux:8-slim
# WORKDIR ${ORACLE_BASE} is '/opt/oracle'
# sqlplus is /opt/oracle/product/18c/dbhomeXE/bin/sqlplus
#----

# Avalible:
# 11.2.0.2, 11
# 11.2.0.2-slim, 11-slim
# 11.2.0.2-full, 11-full
imageName=gvenzl/oracle-xe:11-full

# ORACLE_PASSWORD
# This variable is mandatory for the first container startup and
# specifies the password for the Oracle Database SYS and SYSTEM users.
oraclePassword='sysPass'

# ORACLE_DATABASE
# (for 18c only)
# This is an optional variable. Set this variable to a non-empty string to
# create a new pluggable database with the name specified in this variable.
oracleDatabase='laminasdb_test'

# APP_USER
# This is an optional variable. Set this variable to a non-empty string to
# create a new database schema user with the name specified in this variable.
appUser='ldbtUser'

# APP_USER_PASSWORD
# This is an optional variable. Set this variable to a non-empty string to
# define a password for the database schema user specified by APP_USER.
# This variable requires APP_USER to be specified as well.
appUserPassword='Password123'

dbDir=$(pwd)/db
if [ ! -d $dbDir ]; then
mkdir ${dbDir}
chmod 777 ${dbDir}
fi

#------------------------------------------------------------------------------
# RUN image and create database, user, schema.
#-----

# --user 1000:1000 \
docker run --rm -ti \
--name='tmp.ldbt_oracle_xe_11' \
-p 1521:1521 \
-e ORACLE_PASSWORD=${oraclePassword} \
-e ORACLE_DATABASE=${oracleDatabase} \
-e APP_USER=${appUser} \
-e APP_USER_PASSWORD=${appUserPassword} \
-v ${dbDir}:/opt/oracle/oradata \
$imageName

#------------------------------------------------------------------------------
1 change: 1 addition & 0 deletions .local/oracle-xe/18/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/db
65 changes: 65 additions & 0 deletions .local/oracle-xe/18/docker-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash
#------------------------------------------------------------------------------
set -e
cd $(dirname $(readlink -e $0))
#------------------------------------------------------------------------------
# @see https://github.com/gvenzl/oci-oracle-xe
# @see https://github.com/gvenzl/oci-oracle-xe/blob/main/container-entrypoint.sh
# @see https://github.com/gvenzl/oci-oracle-xe/blob/main/Dockerfile.1840
# @see https://github.com/gvenzl/oci-oracle-xe/blob/main/install.1840.sh
#
# FROM oraclelinux:8-slim
# WORKDIR ${ORACLE_BASE} is '/opt/oracle'
# sqlplus is /opt/oracle/product/18c/dbhomeXE/bin/sqlplus
#----

# Avalible:
# 18.4.0, 18, latest
# 18.4.0-slim, 18-slim, slim
# 18.4.0-full, 18-full, full
imageName='gvenzl/oracle-xe:18.4.0'

# ORACLE_PASSWORD
# This variable is mandatory for the first container startup and
# specifies the password for the Oracle Database SYS and SYSTEM users.
oraclePassword='sysPass'

# ORACLE_DATABASE
# (for 18c only)
# This is an optional variable. Set this variable to a non-empty string to
# create a new pluggable database with the name specified in this variable.
oracleDatabase='laminasdb_test'

# APP_USER
# This is an optional variable. Set this variable to a non-empty string to
# create a new database schema user with the name specified in this variable.
appUser='ldbtUser'

# APP_USER_PASSWORD
# This is an optional variable. Set this variable to a non-empty string to
# define a password for the database schema user specified by APP_USER.
# This variable requires APP_USER to be specified as well.
appUserPassword='Password123'

dbDir=$(pwd)/db
if [ ! -d $dbDir ]; then
mkdir ${dbDir}
chmod 777 ${dbDir}
fi

#------------------------------------------------------------------------------
# RUN image and create database, user, schema.
#-----

# --user 1000:1000 \
docker run --rm -ti \
--name='tmp.ldbt_oracle_xe_18' \
-p 1521:1521 \
-e ORACLE_PASSWORD=${oraclePassword} \
-e ORACLE_DATABASE=${oracleDatabase} \
-e APP_USER=${appUser} \
-e APP_USER_PASSWORD=${appUserPassword} \
-v ${dbDir}:/opt/oracle/oradata \
$imageName

#------------------------------------------------------------------------------
1 change: 1 addition & 0 deletions .local/postgres/14/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/db
41 changes: 41 additions & 0 deletions .local/postgres/14/docker-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
#------------------------------------------------------------------------------
set -e
cd $(dirname $(readlink -e $0))
#------------------------------------------------------------------------------
# @see https://hub.docker.com/_/postgres?tab=description
# @see https://github.com/docker-library/docs/blob/master/postgres/README.md
# @see https://github.com/docker-library/postgres
# @see https://github.com/docker-library/postgres/tree/master/14/alpine
# @see https://github.com/docker-library/postgres/blob/master/14/alpine/Dockerfile
# @see https://github.com/docker-library/postgres/blob/master/14/alpine/docker-entrypoint.sh
#----
imageName='postgres:14.0-alpine'

POSTGRES_DB='laminasdb_test'
POSTGRES_USER='postgres'
#POSTGRES_PASSWORD='Password123'

dbDir=$(pwd)/db
if [ ! -d ${dbDir} ]; then
mkdir ${dbDir}
chmod 777 ${dbDir}
fi

#------------------------------------------------------------------------------
# RUN image and create database, user, schema.
#-----

# --user 1000:1000 \
# -e POSTGRES_PASSWORD=${POSTGRES_PASSWORD} \
docker run --rm -ti \
--name 'tmp.ldbt_postgres_14' \
-p 5432:5432 \
-e POSTGRES_USER=${POSTGRES_USER} \
-e POSTGRES_HOST_AUTH_METHOD=trust \
-e POSTGRES_DB=${POSTGRES_DB} \
-v ${dbDir}:/var/lib/postgresql/data \
${imageName}


#------------------------------------------------------------------------------
Loading