Skip to content

Commit d6e1ae7

Browse files
committed
added Dockerfile and assets
1 parent 9b48e52 commit d6e1ae7

File tree

5 files changed

+131
-0
lines changed

5 files changed

+131
-0
lines changed

Dockerfile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
FROM phusion/baseimage:0.9.16
2+
3+
# Forked from: https://github.com/fideloper/docker-nginx-php
4+
# Other components and inspiration from: https://github.com/dmyers/docker-laravel
5+
6+
ENV HOME /root
7+
8+
RUN /etc/my_init.d/00_regen_ssh_host_keys.sh
9+
10+
CMD ["/sbin/my_init"]
11+
12+
# Nginx-PHP Installation
13+
RUN apt-get update -y && apt-get install -y vim curl wget build-essential python-software-properties git-core
14+
RUN apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 4F4EA0AAE5267A6C
15+
RUN add-apt-repository -y ppa:ondrej/php5-5.6 && add-apt-repository -y ppa:nginx/stable && add-apt-repository ppa:chris-lea/node.js
16+
RUN apt-get update -y && sudo apt-get upgrade -y && apt-get install -y php5 php5-cli php5-fpm php5-mysql php5-curl \
17+
php5-gd php5-mcrypt php5-intl php5-imap php5-tidy php-pear php5-xmlrpc \
18+
nodejs
19+
20+
# Install nginx
21+
RUN apt-get install -y nginx
22+
23+
# Add build script
24+
RUN mkdir -p /root/setup
25+
ADD build/setup.sh /root/setup/setup.sh
26+
RUN chmod +x /root/setup/setup.sh
27+
RUN (cd /root/setup/; /root/setup/setup.sh)
28+
29+
# Copy files from repo
30+
ADD build/default /etc/nginx/sites-available/default
31+
32+
# Add all required files and folders, update permissions
33+
ADD build/nginx.sh /etc/service/nginx/run
34+
RUN chmod +x /etc/service/nginx/run
35+
36+
ADD build/phpfpm.sh /etc/service/phpfpm/run
37+
RUN chmod +x /etc/service/phpfpm/run
38+
39+
RUN chown -R www-data:www-data /var/www
40+
RUN chmod -R 755 /var/www
41+
RUN chown www-data:www-data -R /var/www/app/storage
42+
43+
EXPOSE 80
44+
VOLUME /var/www
45+
46+
# Cleanup apt and lists
47+
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

build/default

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
server {
2+
listen 80;
3+
4+
root /var/www/public/;
5+
index index.html index.htm index.php;
6+
7+
# Make site accessible from http://set-ip-address.xip.io
8+
server_name localhost;
9+
10+
access_log /var/log/nginx/localhost.com-access.log;
11+
error_log /var/log/nginx/localhost.com-error.log error;
12+
13+
charset utf-8;
14+
15+
location / {
16+
try_files $uri $uri/ /index.html /index.php?$query_string;
17+
}
18+
19+
location = /favicon.ico { log_not_found off; access_log off; }
20+
location = /robots.txt { access_log off; log_not_found off; }
21+
22+
error_page 404 /index.php;
23+
24+
# pass the PHP scripts to php5-fpm
25+
# Note: \.php$ is susceptible to file upload attacks
26+
# Consider using: "location ~ ^/(index|app|app_dev|config)\.php(/|$) {"
27+
location ~ \.php$ {
28+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
29+
# With php5-fpm:
30+
fastcgi_pass unix:/var/run/php5-fpm.sock;
31+
fastcgi_index index.php;
32+
include fastcgi_params;
33+
fastcgi_param REMOTE_ADDR $http_x_real_ip;
34+
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
35+
fastcgi_param HTTPS off;
36+
}
37+
38+
# Deny .htaccess file access
39+
location ~ /\.ht {
40+
deny all;
41+
}
42+
}

build/nginx.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
nginx

build/phpfpm.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
php5-fpm -c /etc/php5/fpm

build/setup.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
3+
# Run Node.js output versions
4+
node -v
5+
npm -v
6+
7+
##-------------------------------------------------------
8+
# UPDATE CONFIG FILES
9+
##-------------------------------------------------------
10+
11+
# Set timezone to UTC
12+
sed -i "s/;date.timezone =.*/date.timezone = UTC/" /etc/php5/fpm/php.ini
13+
sed -i "s/;date.timezone =.*/date.timezone = UTC/" /etc/php5/cli/php.ini
14+
15+
# Setup php-fpm to not run as daemon (allow my_init to control)
16+
sed -i -e "s/;daemonize\s*=\s*yes/daemonize = no/g" /etc/php5/fpm/php-fpm.conf
17+
sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php5/fpm/php.ini
18+
19+
# Setup permissions for php5-fpm
20+
sed -i '/^;listen.mode = .*/alisten.mode = 0660' /etc/php5/fpm/pool.d/www.conf
21+
sed -i '/^listen.mode = .*/alisten.owner = www-data' /etc/php5/fpm/pool.d/www.conf
22+
sed -i '/^listen.mode = .*/alisten.group = www-data' /etc/php5/fpm/pool.d/www.conf
23+
24+
# Dynamic PHP environment variables for php-fpm
25+
#&#&
26+
27+
##-------------------------------------------------------
28+
# UPDATE FILES AND FOLDERS
29+
##-------------------------------------------------------
30+
31+
# Add required php5-fpm folders
32+
mkdir -p /var/run/php5-fpm && chown -R www-data:www-data /var/run/php5-fpm
33+
mkdir -p /var/log/php5-fpm && chown -R www-data:www-data /var/log/php5-fpm
34+
35+
# Remove existing www folder
36+
# rm -fr /var/www

0 commit comments

Comments
 (0)