-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile-template-use-mssql-example
143 lines (110 loc) · 5.31 KB
/
Dockerfile-template-use-mssql-example
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# 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
# add msodbcsql packages
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/UBUNTU_VERSION/prod.list > /etc/apt/sources.list.d/mssql-release.list
# install msodbcsql and associated tools
RUN apt-get update
RUN ACCEPT_EULA=Y apt-get install -y msodbcsql17
RUN ACCEPT_EULA=Y apt-get install -y mssql-tools
# # add msssql-tools to path
RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
# 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-gd
RUN pear update-channels
RUN pecl -d php_suffix=PHP_VERSION install sqlsrv
RUN pecl uninstall -r sqlsrv
RUN pecl -d php_suffix=PHP_VERSION install pdo_sqlsrv
RUN pecl uninstall -r pdo_sqlsrv
RUN pecl -d php_suffix=PHP_VERSION install redis
RUN pecl uninstall -r redis
RUN pecl -d php_suffix=PHP_VERSION install yaml-2.2.1
RUN pecl uninstall -r yaml-2.2.1
RUN echo extension=pdo_sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/30-pdo_sqlsrv.ini
RUN echo extension=sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/20-sqlsrv.ini
# copy 30-pdo_sqlsrv.ini to some locations for loading
RUN cp /etc/php/PHP_VERSION/cli/conf.d/20-sqlsrv.ini /etc/php/PHP_VERSION/fpm/conf.d
RUN cp /etc/php/PHP_VERSION/cli/conf.d/30-pdo_sqlsrv.ini /etc/php/PHP_VERSION/fpm/conf.d
# export var for nano to work in command line
ENV TERM xterm
# Set workdir
WORKDIR /var/www/
# 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
# Copy the nvm-pm2 script over
ADD nvm-pm2.sh /var/www
# 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
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Start memcached?
#RUN service memcached start
# 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
# CMD service phpPHP_VERSION-fpm start && service nginx start