Skip to content

Commit

Permalink
Merge branch 'gl-docker-integration'
Browse files Browse the repository at this point in the history
  • Loading branch information
garethlawson committed May 19, 2017
2 parents f5deb28 + 6506e5d commit 365ee4f
Show file tree
Hide file tree
Showing 11 changed files with 2,275 additions and 6 deletions.
117 changes: 117 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
##########################################################################
# Ruggedy Docker Container #
# Author: Ruggedy.io #
# Version 0.1 Beta #
##########################################################################

FROM ubuntu:16.04
MAINTAINER Ruggedy <hello@ruggedy.io>

##########################################################################
# Initial Server and Environment Settings #
##########################################################################

RUN DEBIAN_FRONTEND=noninteractive
ENV LANGUAGE=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8
ENV LC_CTYPE=UTF-8
ENV LANG=en_US.UTF-8
ENV TERM xterm

##########################################################################
# Repositories #
##########################################################################

RUN apt-get update
RUN apt-get upgrade -y --force-yes
RUN apt-get install -y --force-yes \
software-properties-common\
supervisor \
php7.0-cli \
php7.0-common \
php7.0-curl \
php7.0-json \
php7.0-xml \
php7.0-mbstring \
php7.0-mcrypt \
php7.0-mysql \
php7.0-zip \
php7.0-gd \
php7.0-soap \
git \
curl \
vim \
nano \
nodejs \
zip \
unzip \
npm \
nginx \
php7.0-fpm

##########################################################################
# Configure Supervisor #
##########################################################################

RUN mkdir -p /var/log/supervisor
COPY docker-files/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
VOLUME ["/var/log/supervisor"]

##########################################################################
# Configure PHP-FPM and NGINX DAEMON #
##########################################################################

RUN sed -i 's/;daemonize = yes/daemonize = no/g' /etc/php/7.0/fpm/php-fpm.conf
RUN sed -i '1s/^/daemon off;\n/' /etc/nginx/nginx.conf
RUN mkdir /run/php

RUN rm /etc/php/7.0/fpm/php.ini
COPY docker-files/php.ini /etc/php/7.0/fpm/

RUN rm /etc/nginx/sites-available/default
RUN rm /etc/nginx/sites-enabled/default
COPY docker-files/default /etc/nginx/sites-available/
RUN ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
COPY docker-files/nginx.conf /etc/nginx/

##########################################################################
# Configure Composer #
##########################################################################

RUN curl -sS https://getcomposer.org/installer | php \
-- --install-dir=/usr/local/bin --filename=composer

##########################################################################
# Setup and Configure Ruggedy App #
##########################################################################

WORKDIR /usr/share/nginx/html/
RUN mkdir ruggedy-vma
COPY docker-files/.env /usr/share/nginx/html/ruggedy-vma

WORKDIR /usr/share/nginx/html/ruggedy-vma

RUN npm install -g \
bower

COPY package.json /usr/share/nginx/html/ruggedy-vma
RUN npm link gulp
RUN ln -s /usr/bin/nodejs /usr/bin/node

WORKDIR /usr/share/nginx/html
RUN chown -R www-data:www-data ./ruggedy-vma
RUN find /usr/share/nginx/html/ruggedy-vma -type d -exec chmod 755 {} \;
VOLUME ["/usr/share/nginx/html"]

##########################################################################
# Install and start the cron #
##########################################################################

COPY docker-files/crontab /etc/cron.d/ruggedy-cron
RUN chmod 0600 /etc/cron.d/ruggedy-cron
RUN touch /var/log/cron.log
RUN crontab /etc/cron.d/ruggedy-cron

CMD ["/usr/bin/supervisord"]

EXPOSE 80
35 changes: 35 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: '2'
services:
web:
restart: always
build: .
container_name: ruggedy-vma
ports:
- "80:80"
- "443:443"
environment:
- DB_1_PORT_3306_TCP_ADDR=db
depends_on:
- db
volumes_from:
- web-data
web-data:
build: .
entrypoint: /bin/true
volumes:
- ./:/usr/share/nginx/html/ruggedy-vma
db:
image: mysql:latest
restart: always
environment:
- MYSQL_ROOT_PASSWORD=uh239r8hf
- MYSQL_DATABASE=ruggedy_go
ports:
- "3306:3306"
volumes_from:
- db-data
db-data:
image: mysql:latest
volumes:
- /var/lib/mysql
entrypoint: /bin/true
48 changes: 48 additions & 0 deletions docker-files/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
APP_ENV=local
APP_DEBUG=false
APP_LOG_LEVEL=debug
APP_KEY=SomeRandomString
APP_URL=http://localhost
APP_LOCALE=en
APP_DATE_FORMAT="Y-m-d H:i:s"
APP_MODEL_NAMESPACE=App\Entities
APP_EXCEPTION_NAMESPACE=App\Exceptions

DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=3306
DB_DATABASE=ruggedy_go
DB_USERNAME=root
DB_PASSWORD=uh239r8hf

BROADCAST_DRIVER=log
DOCTRINE_PROXY_AUTOGENERATE=true

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_NAME=""
MAIL_FROM_ADDRESS=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=

MAIL_DRIVER=mailgun
MAILGUN_DOMAIN=null
MAILGUN_SECRET=null

GTM_CONTAINER_ID=null

USES_GUEST_ACCOUNT=null
6 changes: 6 additions & 0 deletions docker-files/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
cp docker-files/.env ./
docker-compose up -d
echo "Waiting for containers to initialise..."
sleep 10
docker exec -t ruggedy-vma /usr/share/nginx/html/ruggedy-vma/docker-files/post-docker-compose-up.sh
3 changes: 3 additions & 0 deletions docker-files/crontab
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* * * * * /usr/bin/php /usr/share/nginx/html/ruggedy-vma/artisan schedule:run >> /usr/share/nginx/html/ruggedy-vma/storage/logs/cron.log 2>&1


27 changes: 27 additions & 0 deletions docker-files/default
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
server {
listen 80;
listen [::]:80 ipv6only=on;

root /usr/share/nginx/html/ruggedy-vma/public;
index index.php index.html index.htm;

location / {
try_files $uri $uri/ /index.php?$query_string;
}

error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;

}

location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
99 changes: 99 additions & 0 deletions docker-files/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
daemon off;
user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
worker_connections 768;
# multi_accept on;
}

http {

##
# Basic Settings
##

client_max_body_size 50M;

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

##
# Logging Settings
##

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;
gzip_disable "msie6";

# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##

#include /etc/nginx/naxsi_core.rules;

##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##

#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;

##
# Virtual Host Configs
##

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}


#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}

Loading

0 comments on commit 365ee4f

Please sign in to comment.