Permalink
Browse files

Introduced Docker

  • Loading branch information...
dominik59 committed Jan 18, 2018
1 parent 2fb2567 commit f6cd48df65d29b013d7924c9b31a106ad5458248
Showing with 97 additions and 12 deletions.
  1. +11 −0 .idea/dataSources.xml
  2. +22 −0 Dockerfile-dev
  3. +3 −0 Dockerfile-postgres
  4. BIN composer.phar
  5. +4 −4 config/test/config.php
  6. +0 −8 recreate_test_db.sh
  7. +11 −0 run_composer.sh
  8. +41 −0 start_environment.sh
  9. +5 −0 variables
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="@172.17.0.3" uuid="2e39127e-7942-437c-a0ab-5e8fef3475f1">
<driver-ref>postgresql</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
<jdbc-url>jdbc:postgresql://172.17.0.3:5432/</jdbc-url>
</data-source>
</component>
</project>
@@ -0,0 +1,22 @@
FROM php:7.1
WORKDIR /var/www
RUN apt-get update \
&& apt-get install -y libpq-dev git unzip \
&& docker-php-ext-install -j$(nproc) pdo pdo_pgsql pgsql \
&& pecl install xdebug \
&& docker-php-ext-enable xdebug \
&& echo "xdebug.remote_connect_back=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
&& echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
&& echo "alias migrate-test='(cd /var/www/html/; export environment=test; ./db.sh db:migrate)'" >> /etc/bash.bashrc \
&& echo "alias migrate-prod='(cd /var/www/html/; export environment=prod; ./db.sh db:migrate)'" >> /etc/bash.bashrc \
&& apt-get clean && apt-get -y autoremove \
&& rm -rf /var/lib/apt/lists/*
RUN rm -rf /var/www/html
COPY . /var/www/
RUN ./composer.phar install --no-dev
@@ -0,0 +1,3 @@
FROM postgres:10
ADD ./test/test-db/recreate_schema.sql /docker-entrypoint-initdb.d/
BIN +1.75 MB composer.phar
Binary file not shown.
@@ -17,13 +17,13 @@
$config['db']['dsn'] = 'sqlite:ouzo_test';
} else {
$config['sql_dialect'] = PostgresDialect::class;
$config['db']['user'] = 'postgres';
$config['db']['pass'] = '';
$config['db']['user'] = 'ouzo_user';
$config['db']['pass'] = 'password';
$config['db']['driver'] = 'pgsql';
$config['db']['host'] = '127.0.0.1';
$config['db']['host'] = '172.17.0.3';
$config['db']['port'] = '5432';
}
$config['db']['dbname'] = 'ouzo_test';
$config['db']['dbname'] = 'ouzo';
$config['global']['prefix_system'] = '';
$config['global']['suffix_cache'] = '1234';

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,11 @@
#!/bin/bash
source variables
ARGS="install"
if [ $# -ne 0 ]
then
ARGS=$@
fi
docker run --rm -e HOME=/var/www -e GIT_COMMITTER_NAME=docker -e GIT_COMMITTER_EMAIL=docker@docker \
-u `id -u $USER` -v $(pwd):/var/www/ -t $DOCKER_WEB_NAME /var/www/composer.phar $ARGS
@@ -0,0 +1,41 @@
#!/bin/bash
source variables
docker ps |grep "$DOCKER_DB_NAME"
run=$?
docker ps -a|grep "$DOCKER_DB_NAME"
exists=$?
if [ ${exists} -ne 0 ]
then
echo "###Base does not exist###"
else
echo "###Base does exist###"
docker stop $DOCKER_DB_NAME
docker rm -f $DOCKER_DB_NAME
fi
docker build --pull --rm -f Dockerfile-postgres -t $DOCKER_DB_NAME .
docker run --name $DOCKER_DB_NAME -e POSTGRES_PASSWORD=$DB_PASSWORD -e POSTGRES_USER=$DB_USER -e POSTGRES_DB=$DB_NAME -d $DOCKER_DB_NAME
until docker exec $DOCKER_DB_NAME /usr/lib/postgresql/10/bin/pg_isready; do sleep 2; done
docker rm -f $DOCKER_WEB_NAME
set -e
docker build --pull --rm -f Dockerfile-dev -t $DOCKER_WEB_NAME .
docker run --name $DOCKER_WEB_NAME --link $DOCKER_DB_NAME:$DOCKER_DB_NAME -d -v $(pwd):/var/www/ -v /dev/log:/dev/log -p 8009:80 $DOCKER_WEB_NAME
./run_composer.sh
DOCKER_DB_IP=$(docker inspect $DOCKER_DB_NAME|jq .[].NetworkSettings.IPAddress | tr -d '"')
DOCKER_WEB_IP=$(docker inspect $DOCKER_WEB_NAME|jq .[].NetworkSettings.IPAddress | tr -d '"')
echo
echo "Application available on http://localhost:8009"
echo " web IP = $DOCKER_WEB_IP"
echo " database IP = $DOCKER_DB_IP"
echo
echo export PGHOST=$DOCKER_DB_IP
echo export PGUSER=$DB_USER
echo export PGDATABASE=$DB_NAME
echo export PGPASSWORD=$DB_PASSWORD
echo
@@ -0,0 +1,5 @@
DOCKER_DB_NAME="ouzo-postgres"
DOCKER_WEB_NAME="ouzo-dev"
DB_NAME="ouzo"
DB_USER="ouzo_user"
DB_PASSWORD="password"

0 comments on commit f6cd48d

Please sign in to comment.