Skip to content
Permalink
Browse files

initial commit

  • Loading branch information
alihamidali committed Jan 14, 2020
0 parents commit aa3a57a3aad840d39d840aace58470a045114331
Showing with 161 additions and 0 deletions.
  1. +5 −0 apache/000-default.conf
  2. +80 −0 apache/wait-for.sh
  3. +33 −0 app/Dockerfile
  4. +1 −0 app/index.html
  5. +40 −0 docker-compose.yml
  6. +2 −0 mysql/Dockerfile
  7. 0 mysql/dump.sql
@@ -0,0 +1,5 @@
<VirtualHost *:80>

DocumentRoot /var/www/html

</VirtualHost>
@@ -0,0 +1,80 @@
#!/bin/sh

TIMEOUT=15
QUIET=0

echoerr() {
if [ "$QUIET" -ne 1 ]; then printf "%s\n" "$*" 1>&2; fi
}

usage() {
exitcode="$1"
cat << USAGE >&2
Usage:
$cmdname host:port [-t timeout] [-- command args]
-q | --quiet Do not output any status messages
-t TIMEOUT | --timeout=timeout Timeout in seconds, zero for no timeout
-- COMMAND ARGS Execute command with args after the test finishes
USAGE
exit "$exitcode"
}

wait_for() {
for i in `seq $TIMEOUT` ; do
nc -z "$HOST" "$PORT" > /dev/null 2>&1

result=$?
if [ $result -eq 0 ] ; then
if [ $# -gt 0 ] ; then
exec "$@"
fi
exit 0
fi
sleep 1
done
echo "Operation timed out" >&2
exit 1
}

while [ $# -gt 0 ]
do
case "$1" in
*:* )
HOST=$(printf "%s\n" "$1"| cut -d : -f 1)
PORT=$(printf "%s\n" "$1"| cut -d : -f 2)
shift 1
;;
-q | --quiet)
QUIET=1
shift 1
;;
-t)
TIMEOUT="$2"
if [ "$TIMEOUT" = "" ]; then break; fi
shift 2
;;
--timeout=*)
TIMEOUT="${1#*=}"
shift 1
;;
--)
shift
break
;;
--help)
usage 0
;;
*)
echoerr "Unknown argument: $1"
usage 1
;;
esac
done

if [ "$HOST" = "" -o "$PORT" = "" ]; then
echoerr "Error: you need to provide a host and port to test."
usage 2
fi

wait_for "$@"

@@ -0,0 +1,33 @@
FROM php:7.1.20-apache

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get -y update --fix-missing
RUN apt-get upgrade -y

# Install useful tools
RUN apt-get -y install apt-utils nano wget dialog netcat

#Install important libraries
RUN apt-get -y install --fix-missing apt-utils libxml2-dev libpng-dev zlib1g-dev poppler-utils build-essential git curl libcurl3 libcurl3-dev zip libsqlite3-dev libsqlite3-0 mysql-client

RUN docker-php-ext-install pdo_mysql
RUN docker-php-ext-install bcmath
RUN docker-php-ext-install pdo_sqlite
RUN docker-php-ext-install simplexml
RUN docker-php-ext-install mysqli
RUN docker-php-ext-install gd

RUN docker-php-ext-install curl
RUN docker-php-ext-install tokenizer
RUN docker-php-ext-install json

# Enable apache modules
RUN a2enmod rewrite headers

RUN deluser www-data \
&& groupadd -g 1000 -r www-data \
&& useradd -u 1000 -p -s -g www-data www-data

RUN apache2ctl restart

@@ -0,0 +1 @@
<h2>you are inside docker application</h2>
@@ -0,0 +1,40 @@
version: '3'

services:
app-server:
build:
context: ./app
image: app-server:latest
container_name: 'app-server'
restart: 'always'
ports:
- "9001:80"
environment:
- DATABASE_HOST=app-db
volumes:
- "./app:/var/www/html"
- "./apache/000-default.conf:/etc/apache2/sites-enabled/000-default.conf"
- "./apache/wait-for.sh:/"
command: ["chown", "-R", "www-data:www-data", "/var/www/html"]
depends_on:
- db-api

app-db:
image: ./mysql
container_name: 'app-db'
ports:
- 6033:3306
environment:
MYSQL_DATABASE: 'application_db'
MYSQL_USER: 'application_user'
MYSQL_PASSWORD: '123456'
MYSQL_ROOT_PASSWORD: '123456'

app-db-migration:
image: app-server:latest
container_name: 'app-db-migration'
command: /bin/sh -c "/wait-for.sh app-db:3306 -t 120 -- php /var/www/html/httpdocs/shared_libs/migrate.php"
links:
- db-api
depends_on:
- db-api
@@ -0,0 +1,2 @@
FROM mysql:latest
COPY ./dump.sql /docker-entrypoint-initdb.d/dump.sql
No changes.

0 comments on commit aa3a57a

Please sign in to comment.
You can’t perform that action at this time.