-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile-template
129 lines (99 loc) · 4.44 KB
/
Dockerfile-template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# Set the base image to ubuntu:UBUNTU_VERSION
FROM ubuntu:UBUNTU_VERSION
# File Author / Maintainer
LABEL maintainer "Angela Murrell <[email protected]>"
# Update the repository and install nginx and phpPHP_VERSION
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y nano && \
apt-get install -y curl && \
apt-get install -y sudo && \
apt-get install -y wget && \
apt-get install -y git && \
apt-get install -y unzip && \
apt-get install -y ruby-full && \
apt-get install -y ufw && \
apt-get install -y software-properties-common && \
apt-get install -y apt-transport-https && \
apt-get install -y nginx && \
apt-get install -y unixodbc-dev
RUN LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php && \
apt-get update
RUN apt-get update && \
apt-get -y --no-install-recommends install phpPHP_VERSION && \
apt-get -y --no-install-recommends install phpPHP_VERSION-fpm && \
apt-get -y --no-install-recommends install apt-utils && \
apt-get -y install freetds-bin tdsodbc unixodbc unixodbc-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
# Set which PHP we want to use
RUN sudo update-alternatives --set php /usr/bin/phpPHP_VERSION
RUN sudo update-alternatives --set phar /usr/bin/pharPHP_VERSION
RUN sudo update-alternatives --set phar.phar /usr/bin/phar.pharPHP_VERSION
# Install more stuff
RUN apt-get update && \
apt-get -y install phpPHP_VERSION-curl && \
apt-get -y install phpPHP_VERSION-mysql && \
apt-get -y install php-pear && \
apt-get -y install phpPHP_VERSION-dev && \
apt-get -y install libcurl3-openssl-dev && \
apt-get -y install libyaml-dev && \
apt-get -y install phpPHP_VERSION-zip && \
apt-get -y install phpPHP_VERSION-mbstring && \
apt-get -y install phpPHP_VERSION-gd && \
apt-get -y install phpPHP_VERSION-sybase && \
apt-get -y install phpPHP_VERSION-memcached && \
apt-get -y install phpPHP_VERSION-pgsql && \
apt-get -y install phpPHP_VERSION-xml && \
apt-get -y install phpPHP_VERSION-intl && \
apt-get -y install phpPHP_VERSION-bcmath && \
apt-get -y install phpPHP_VERSION-redis && \
apt-get -y install phpPHP_VERSION-xdebug && \
apt-get -y install phpPHP_VERSION-gd
RUN pear update-channels
RUN pecl -d php_suffix=PHP_VERSION install redis
RUN pecl uninstall -r redis
RUN pecl -d php_suffix=PHP_VERSION install yaml-YAML_VERSION
RUN pecl uninstall -r yaml-YAML_VERSION
# add xdebug config settings
ADD xdebug.computed.ini /etc/php/PHP_VERSION/mods-available/xdebug.ini
# export var for nano to work in command line
ENV TERM xterm
# Set workdir
WORKDIR /var/www/
# Setup a bashrc for www-data
RUN cp /etc/skel/.bashrc /var/www/.bashrc
# Add site directory
RUN mkdir /var/www/site
# Copy a configuration file from the current directory
ADD nginx.site.computed.conf /etc/nginx/sites-available/
# Remove symbolic link to default enabled nginx site in sites-enabled
RUN rm /etc/nginx/sites-enabled/default
# Make Symbolic link to enable the site
RUN ln -s /etc/nginx/sites-available/nginx.site.computed.conf /etc/nginx/sites-enabled/
# Append "daemon off;" to the configuration file
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
# Append source brc alias to the bashrc profile file
RUN echo 'alias brc="source /root/.bashrc"' >> /root/.bashrc
# Copy a configuration file from the current directory
ADD php7-fpm.site.custom.conf /etc/php/PHP_VERSION/fpm/pool.d
# daemon off for php also
RUN sed -i "/;daemonize = .*/c\daemonize = no" /etc/php/PHP_VERSION/fpm/php-fpm.conf && \
sed -i "/variables_order = .*/c\variables_order = \"EGPCS\"" /etc/php/PHP_VERSION/fpm/php.ini && \
sed -i "/pid = .*/c\;pid = /run/php/phpPHP_VERSION-fpm.pid" /etc/php/PHP_VERSION/fpm/php-fpm.conf
# Remove pool.d/www.conf
RUN rm /etc/php/PHP_VERSION/fpm/pool.d/www.conf
# Adjust www-data
RUN usermod -u 1000 www-data
# Set ownership on working dir
RUN chown -R www-data:www-data /var/www/
# Change user
USER www-data
# Copy the nvm-pm2 script over, run it.
ADD nvm-pm2.sh /var/www/nvm-pm2.sh
RUN cd /var/www/ && echo "NVM_VERSION" && ./nvm-pm2.sh
USER root
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Set the default command to execute when creating a new container
# The following runs FPM and removes all its extraneous log output on top of what your app outputs to stdout
CMD service phpPHP_VERSION-fpm start && service nginx start && /usr/sbin/php-fpmPHP_VERSION -F -O 2>&1 | sed -u 's,.*: \"\(.*\)$,\1,'| sed -u 's,"$,,' 1>&1