Browse Source

Add test automation for SQL Server backend

pull/303/head
Clemens Wolff 5 years ago
parent
commit
4285fda947
3 changed files with 49 additions and 15 deletions
  1. 6
      .travis.yml
  2. 19
      Dockerfile
  3. 39
      tools/install-mssql.sh

6
.travis.yml

@ -6,6 +6,7 @@ python:
env:
- DATABASE=sqlite
- DATABASE=postgres
- DATABASE=mssql
services:
- docker
@ -16,6 +17,11 @@ before_install:
if [[ "${DATABASE}" = "postgres" ]]; then
docker run --rm --name=postgres --network=doccano -d -e POSTGRES_USER=user -e POSTGRES_PASSWORD=pass -e POSTGRES_DB=db postgres
export DATABASE_URL="postgres://user:pass@postgres:5432/db?sslmode=disable"
elif [[ "${DATABASE}" = "mssql" ]]; then
docker run --rm --name=mssql --network=doccano -d -e ACCEPT_EULA=y -e SA_PASSWORD=sUp3rS3cr3t mcr.microsoft.com/mssql/server:2017-latest
docker exec -it mssql sh -c "while ! /opt/mssql-tools/bin/sqlcmd -U SA -P sUp3rS3cr3t -Q 'CREATE DATABASE db;'; do sleep 3; done"
export DATABASE_URL="mssql://SA:sUp3rS3cr3t@mssql:1433/db?sslmode=disable"
fi
install:

19
Dockerfile

@ -6,8 +6,8 @@ RUN curl -sL "https://deb.nodesource.com/setup_${NODE_VERSION}" | bash - \
&& apt-get install --no-install-recommends -y \
nodejs=8.16.0-1nodesource1
RUN apt-get install --no-install-recommends -y \
unixodbc-dev=2.3.4-1
COPY tools/install-mssql.sh /doccano/tools/install-mssql.sh
RUN /doccano/tools/install-mssql.sh --dev
COPY app/server/static/package*.json /doccano/app/server/static/
RUN cd /doccano/app/server/static \
@ -33,19 +33,8 @@ RUN cd /doccano \
FROM python:${PYTHON_VERSION}-slim-stretch AS runtime
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
curl=7.52.1-5+deb9u9 \
gnupg=2.1.18-8~deb9u4 \
apt-transport-https=1.4.9 \
&& curl -fsS https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
&& curl -fsS https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql.list \
&& apt-get update \
&& ACCEPT_EULA=Y apt-get install --no-install-recommends -y \
msodbcsql17=17.3.1.1-1 \
mssql-tools=17.3.0.1-1 \
&& apt-get remove -y curl gnupg apt-transport-https \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /doccano/tools/install-mssql.sh /doccano/tools/install-mssql.sh
RUN /doccano/tools/install-mssql.sh
RUN useradd -ms /bin/sh doccano

39
tools/install-mssql.sh

@ -0,0 +1,39 @@
#!/usr/bin/env bash
# parse arguments
mode="prod"
for opt in "$@"; do
case "${opt}" in
--dev) mode="dev" ;;
esac
done
set -eo pipefail
# install build dependencies
apt-get update
apt-get install --no-install-recommends -y \
curl=7.52.1-5+deb9u9 \
gnupg=2.1.18-8~deb9u4 \
apt-transport-https=1.4.9
# install dependency to compile django-pyodbc-azure
if [[ "${mode}" = "dev" ]]; then
apt-get install --no-install-recommends -y \
unixodbc-dev=2.3.4-1
fi
# add mssql repo
curl -fsS https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl -fsS https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql.list
apt-get update
# install mssql
ACCEPT_EULA=Y apt-get install --no-install-recommends -y \
msodbcsql17=17.3.1.1-1 \
mssql-tools=17.3.0.1-1
# remove build dependencies and artifacts
apt-get remove -y \
curl gnupg apt-transport-https
rm -rf /var/lib/apt/lists/*
Loading…
Cancel
Save