Dockerizing #10

Merged
PootisPenserHere merged 9 commits from dockerizing into master 2018-08-08 07:46:39 +00:00
9 changed files with 97 additions and 2 deletions

View File

@ -0,0 +1,5 @@
Dockerfile
README.md
buildspec.yml
CONTRIBUTING.md
docker-compose.yml

1
api-payroll/.htaccess Normal file
View File

@ -0,0 +1 @@
Options -Indexes

43
api-payroll/Dockerfile Normal file
View File

@ -0,0 +1,43 @@
FROM ubuntu:16.04
# Updating
RUN apt-get -y update && apt-get -y upgrade
# Installing php, apache and supplementary software
RUN apt-get -y install apache2 php7.0 libapache2-mod-php7.0 php7.0-cli php7.0-common php7.0-mbstring php7.0-gd php7.0-intl php7.0-xml php7.0-mysql php7.0-mcrypt php7.0-zip curl git unzip composer
# Enable apache mods
RUN a2enmod php7.0
RUN a2enmod rewrite
# Update the PHP.ini file, enable <? ?> tags and quieten logging
RUN sed -i "s/short_open_tag = Off/short_open_tag = On/" /etc/php/7.0/apache2/php.ini
RUN sed -i "s/error_reporting = .*$/error_reporting = E_ERROR | E_WARNING | E_PARSE/" /etc/php/7.0/apache2/php.ini
# Manually set up the apache environment variables
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
# Expose apache
EXPOSE 80
# Copy this repo into place.
ADD . /var/www/site
WORKDIR /var/www/site
# Testing permisions
RUN chmod 777 -R .
# Installing dependencies
RUN composer install
# Unit tests
RUN composer test
# Update the default apache site with the config we created.
ADD apache-config.conf /etc/apache2/sites-enabled/000-default.conf
# By default start up apache in the foreground, override with /bin/bash for interative
CMD /usr/sbin/apache2ctl -D FOREGROUND

View File

@ -0,0 +1,15 @@
<VirtualHost *:80>
ServerAdmin me@mydomain.com
DocumentRoot /var/www/site
<Directory /var/www/site/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order deny,allow
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

View File

@ -14,8 +14,9 @@ phases:
- echo Entered the build phase...
- echo Build started on `date`
- composer test
- sudo docker-compose up --build -d
post_build:
commands:
- echo Entered the post_build phase...
- sudo docker-compose down --rmi all -v
- echo Build completed on `date`

View File

@ -26,7 +26,7 @@ return [
// Datanase settings
'mysql' => [
'host' => 'localhost',
'host' => 'mysql',
'database' => 'payroll',
'user' => 'root',
'password' => '12345678',

1
database/.dockerignore Normal file
View File

@ -0,0 +1 @@
Dockerfile

3
database/Dockerfile Normal file
View File

@ -0,0 +1,3 @@
FROM mysql:5.7
ADD . /docker-entrypoint-initdb.d

26
docker-compose.yml Normal file
View File

@ -0,0 +1,26 @@
version: '3'
services:
api:
container_name: payroll_api
build: api-payroll/
ports:
- "8085:80"
volumes:
- api-payroll:/var/www/site
depends_on:
- mysql
mysql:
container_name: payroll_mysql
restart: always
build: database
ports:
- "3306:3306"
volumes:
- my-datavolume:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: '12345678'
MYSQL_USER: 'sloth'
MYSQL_PASS: '12345678'
volumes:
api-payroll:
my-datavolume: