Skip to content

Commit 8dcf6bc

Browse files
committed
Add SQL Server 2019
1 parent 9728e2e commit 8dcf6bc

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

docker/ubuntu20/Dockerfile

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,31 @@ FROM ubuntu:20.04
22

33
ARG DEBIAN_FRONTEND=noninteractive
44

5-
# install: php / mysql / postgres / sqlite / tools
5+
# install: php / mysql / postgres / sqlite / tools / mssql deps
66
RUN apt-get update && apt-get -y install \
77
php-cli php-xml php-mbstring \
88
mysql-server mysql-client php-mysql \
99
postgresql php-pgsql \
1010
postgresql-12-postgis-3 \
1111
sqlite3 php-sqlite3 \
12-
git wget
12+
git wget \
13+
curl apt-transport-https debconf-utils sudo gnupg
14+
15+
# adding custom MS repository
16+
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
17+
RUN curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/msprod.list
18+
RUN curl https://packages.microsoft.com/config/ubuntu/20.04/mssql-server-2019.list > /etc/apt/sources.list.d/mssql-server-2019.list
19+
20+
# install SQL Server and tools
21+
RUN apt-get update && apt-get -y install mssql-server
22+
RUN ACCEPT_EULA=Y MSSQL_PID=Express MSSQL_SA_PASSWORD=sapwd123! /opt/mssql/bin/mssql-conf setup || true
23+
RUN ACCEPT_EULA=Y apt-get install -y msodbcsql17 mssql-tools
24+
25+
# install pdo_sqlsrv
26+
RUN apt-get -y install php-pear build-essential unixodbc-dev php-dev
27+
RUN pecl install pdo_sqlsrv
28+
RUN echo extension=pdo_sqlsrv.so > /etc/php/7.4/mods-available/pdo_sqlsrv.ini
29+
RUN phpenmod pdo_sqlsrv
1330

1431
# install locales
1532
RUN apt-get -y install locales

docker/ubuntu20/run.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,23 @@ CREATE EXTENSION IF NOT EXISTS postgis;
4141
EOF
4242
echo "done"
4343

44-
echo -n "[3/4] Starting SQLServer 2017 ... "
45-
echo "skipped"
44+
echo -n "[3/4] Starting SQLServer 2019 ... "
45+
# run sqlserver server
46+
nohup /opt/mssql/bin/sqlservr --accept-eula > /root/mssql.log 2>&1 &
47+
# create database and user on postgres
48+
/opt/mssql-tools/bin/sqlcmd -l 30 -S localhost -U SA -P sapwd123! >/dev/null << 'EOF'
49+
CREATE DATABASE [php-crud-api]
50+
GO
51+
CREATE LOGIN [php-crud-api] WITH PASSWORD=N'php-crud-api', DEFAULT_DATABASE=[php-crud-api], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
52+
GO
53+
USE [php-crud-api]
54+
GO
55+
CREATE USER [php-crud-api] FOR LOGIN [php-crud-api] WITH DEFAULT_SCHEMA=[dbo]
56+
exec sp_addrolemember 'db_owner', 'php-crud-api';
57+
GO
58+
exit
59+
EOF
60+
echo "done"
4661

4762
echo -n "[4/4] Cloning PHP-CRUD-API v2 ... "
4863
# install software

0 commit comments

Comments
 (0)