-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.8.2-fpm-sqlsrv
124 lines (111 loc) · 5.05 KB
/
Dockerfile.8.2-fpm-sqlsrv
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
FROM php:8.2-fpm-alpine3.17
LABEL maintainer="lzh1104 <[email protected]>"
ARG SWOOLE_VERSION
ARG SWOW_VERSION
ARG USE_SWOW
ARG USE_CHINA
ENV SWOOLE_V=${SWOOLE_VERSION:-5.0.1}
ENV SWOW_V=${SWOW_VERSION:-1.1.0}
ENV USE_SWOW_E=${USE_SWOW:-swoole}
ENV USE_CHINA_E=${USE_CHINA:+tuna}
# WORKDIR /var/www/html
# use mirror tsinghua
RUN set -eux; \
if [ "$USE_CHINA_E" == "tuna" ]; then \
sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories; \
fi; \
echo $USE_CHINA_E
RUN apk update \
&& apk add --no-cache tzdata gpg gpg-agent unixodbc-dev \
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone
# Install Microsoft ODBC Driver for SQL Server (Linux)
# https://learn.microsoft.com/zh-cn/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-2017&tabs=alpine18-install%2Calpine17-install%2Cdebian8-install%2Credhat7-13-install%2Crhel7-offline
RUN set -eux; \
cd /tmp; \
# Download the desired package(s)
curl -O https://download.microsoft.com/download/1/f/f/1fffb537-26ab-4947-a46a-7a45c27f6f77/msodbcsql18_18.2.1.1-1_amd64.apk; \
curl -O https://download.microsoft.com/download/1/f/f/1fffb537-26ab-4947-a46a-7a45c27f6f77/mssql-tools18_18.2.1.1-1_amd64.apk; \
\
#(Optional) Verify signature, if 'gpg' is missing install it using 'apk add gnupg':
curl -O https://download.microsoft.com/download/1/f/f/1fffb537-26ab-4947-a46a-7a45c27f6f77/msodbcsql18_18.2.1.1-1_amd64.sig; \
curl -O https://download.microsoft.com/download/1/f/f/1fffb537-26ab-4947-a46a-7a45c27f6f77/mssql-tools18_18.2.1.1-1_amd64.sig; \
\
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --import -; \
gpg --verify msodbcsql18_18.2.1.1-1_amd64.sig msodbcsql18_18.2.1.1-1_amd64.apk; \
gpg --verify mssql-tools18_18.2.1.1-1_amd64.sig mssql-tools18_18.2.1.1-1_amd64.apk; \
\
# Install the package(s)
apk add --allow-untrusted msodbcsql18_18.2.1.1-1_amd64.apk; \
apk add --allow-untrusted mssql-tools18_18.2.1.1-1_amd64.apk
RUN set -eux; \
apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
linux-headers \
imagemagick-dev \
openssl-dev \
# swoole enable c-ares
c-ares-dev \
libmcrypt-dev \
libxml2-dev \
libzip-dev \
libmemcached-dev \
libavif-dev gd-dev libpng-dev \
libwebp-dev libjpeg-turbo-dev libpng-dev \
freetype-dev curl-dev \
; \
export CFLAGS="$PHP_CFLAGS" \
CPPFLAGS="$PHP_CPPFLAGS" \
LDFLAGS="$PHP_LDFLAGS" \
; \
# https://learn.microsoft.com/zh-cn/sql/connect/php/installation-tutorial-linux-mac?view=sql-server-ver16
pecl install sqlsrv; \
pecl install pdo_sqlsrv; \
pecl install redis; \
pecl install apcu; \
pecl install protobuf; \
docker-php-ext-install bcmath \
mysqli pcntl pdo_mysql shmop soap sockets sysvsem opcache zip; \
docker-php-ext-configure gd --with-libdir=/usr/include --with-avif --with-webp --with-jpeg --with-freetype; \
docker-php-ext-install gd; \
pecl install imagick; \
pecl install memcached; \
pecl install mongodb; \
# pecl install xdebug; \
docker-php-ext-enable sqlsrv pdo_sqlsrv; \
docker-php-ext-enable redis apcu protobuf; \
# https://pecl.php.net/package/imagick
docker-php-ext-enable imagick; \
docker-php-ext-enable memcached mongodb; \
if [ "$USE_SWOW_E" != "swow" ]; then \
pecl install -D 'enable-sockets="yes" enable-openssl="yes" enable-http2="yes" enable-mysqlnd="yes" enable-swoole-json="yes" enable-swoole-curl="yes" enable-cares="yes"' swoole; \
# cd /tmp && pecl download "swoole-$SWOW_V" && tar xzvf "swoole-$SWOW_V.tgz" && cd "swoole-$SWOW_V" && phpize && ./configure --enable-sockets --enable-openssl --enable-mysqlnd --enable-swoole-json && make && make install; \
docker-php-ext-enable swoole; \
echo "swoole.use_shortname=off" >> /usr/local/etc/php/conf.d/docker-php-ext-swoole.ini; \
else \
# https://github.com/swow/swow
# swow 和 swoole 不能共存
curl -o swow.tar.gz -fL "https://github.com/swow/swow/archive/refs/tags/v$SWOW_V.tar.gz"; \
tar -xzf swow.tar.gz -C /tmp/; \
rm swow.tar.gz; \
cd "/tmp/swow-$SWOW_V/ext" && phpize && ./configure && make && make install; \
docker-php-ext-enable swow; \
fi; \
# Chane TimeZone
cp $PHP_INI_DIR/php.ini-development $PHP_INI_DIR/php.ini; \
# && cp $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini \
sed -i 's/;date.timezone =/date.timezone = "Asia\/Shanghai"/g' $PHP_INI_DIR/php.ini; \
\
runDeps="$( \
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \
| tr ',' '\n' \
| sort -u \
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
)"; \
apk add --no-cache $runDeps; \
\
apk del --no-network .build-deps; \
rm /tmp/* -rf
# install composer
RUN curl -sS https://getcomposer.org/installer | php \
&& mv composer.phar /usr/local/bin/composer