Skip to content

Commit

Permalink
✨ Add Microsoft ODBC driver for SQL Server (#62)
Browse files Browse the repository at this point in the history
Signed-off-by: Jacob Woffenden <[email protected]>
  • Loading branch information
jacobwoffenden authored Nov 11, 2024
1 parent c505f26 commit 1d8809f
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
27 changes: 26 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ ENV CONTAINER_USER="analyticalplatform" \
KUBECTL_VERSION="1.29.10" \
HELM_VERSION="3.16.2" \
CLOUD_PLATFORM_CLI_VERSION="1.37.12" \
MICROSOFT_SQL_ODBC_VERSION="18.4.1.1-1" \
MICROSOFT_SQL_TOOLS_VERSION="18.4.1.1-1" \
CUDA_VERSION="12.6.1" \
NVIDIA_DISABLE_REQUIRE="true" \
NVIDIA_CUDA_CUDART_VERSION="12.6.77-1" \
NVIDIA_CUDA_COMPAT_VERSION="560.35.03-1" \
NVIDIA_VISIBLE_DEVICES="all" \
NVIDIA_DRIVER_CAPABILITIES="compute,utility" \
LD_LIBRARY_PATH="/usr/local/nvidia/lib:/usr/local/nvidia/lib64" \
PATH="/usr/local/nvidia/bin:/usr/local/cuda/bin:/opt/conda/bin:/home/analyticalplatform/.local/bin:${PATH}"
PATH="/usr/local/nvidia/bin:/usr/local/cuda/bin:/opt/conda/bin:/home/analyticalplatform/.local/bin:/opt/mssql-tools18/bin:${PATH}"

SHELL ["/bin/bash", "-e", "-u", "-o", "pipefail", "-c"]

Expand Down Expand Up @@ -320,5 +322,28 @@ install --owner nobody --group nogroup --mode 0755 cloud-platform /usr/local/bin
rm --force --recursive cloud-platform LICENSE README.md completions cloud-platform-cli.tar.gz
EOF

# Microsoft SQL ODBC and Tools
RUN <<EOF
curl --location --fail-with-body \
"https://packages.microsoft.com/keys/microsoft.asc" \
--output microsoft.asc

cat microsoft.asc | gpg --dearmor --output microsoft-prod.gpg

install -D --owner root --group root --mode 644 microsoft-prod.gpg /usr/share/keyrings/microsoft-prod.gpg

echo "deb [arch=amd64,arm64,armhf signed-by=/usr/share/keyrings/microsoft-prod.gpg] https://packages.microsoft.com/ubuntu/24.04/prod noble main" > /etc/apt/sources.list.d/mssql-release.list

apt-get update --yes

ACCEPT_EULA=Y apt-get install --yes \
"msodbcsql18=${MICROSOFT_SQL_ODBC_VERSION}" \
"mssql-tools18=${MICROSOFT_SQL_TOOLS_VERSION}"

apt-get clean --yes

rm --force --recursive /var/lib/apt/lists/* microsoft.asc microsoft-prod.gpg
EOF

USER ${CONTAINER_USER}
WORKDIR /home/${CONTAINER_USER}
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ This image is built on Ubuntu 24.04 LTS and includes the following software:

- [Cloud Platform CLI](https://github.com/ministryofjustice/cloud-platform-cli)

- [Microsoft ODBC driver for SQL Server](https://learn.microsoft.com/en-us/sql/connect/odbc/microsoft-odbc-driver-for-sql-server)

## Running Locally

### Build
Expand Down Expand Up @@ -204,6 +206,34 @@ Releases for Helm are maintained on [GitHub](https://github.com/helm/helm/releas

Releases for Cloud Platform CLI are maintained on [GitHub](https://github.com/ministryofjustice/cloud-platform-cli/releases).

### Microsoft ODBC driver for SQL Server

The latest version of Microsoft ODBC driver for SQL Server can be obtained by running:

```bash
docker run -it --rm --platform linux/amd64 public.ecr.aws/ubuntu/ubuntu:24.04

apt-get update --yes

apt-get install --yes curl gpg

curl --location --fail-with-body \
"https://packages.microsoft.com/keys/microsoft.asc" \
--output microsoft.asc

cat microsoft.asc | gpg --dearmor --output microsoft-prod.gpg

install -D --owner root --group root --mode 644 microsoft-prod.gpg /usr/share/keyrings/microsoft-prod.gpg

echo "deb [arch=amd64,arm64,armhf signed-by=/usr/share/keyrings/microsoft-prod.gpg] https://packages.microsoft.com/ubuntu/24.04/prod noble main" > /etc/apt/sources.list.d/mssql-release.list

apt-get update --yes

apt-cache policy msodbcsql18

apt-cache policy mssql-tools18
```

## Maintenance

Maintenance of this component is scheduled in this [workflow](https://github.com/ministryofjustice/analytical-platform/blob/main/.github/workflows/schedule-issue-cloud-development-environment-base.yml), which generates a maintenance ticket as per this [example](https://github.com/ministryofjustice/analytical-platform/issues/5905).
9 changes: 9 additions & 0 deletions test/container-structure-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ commandTests:
args: ["--version"]
expectedOutput: ["0.8.0"]

- name: "sqlcmd"
command: "sqlcmd"
args: ["-?"]
expectedOutput: ["Version 18.4.0001.1 Linux"]

fileExistenceTests:
- name: "/opt/analytical-platform"
path: "/opt/analytical-platform"
Expand Down Expand Up @@ -188,6 +193,10 @@ fileExistenceTests:
path: "/usr/local/cuda/lib64/libcudart.so.12"
shouldExist: true

- name: "/opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.4.so.1.1"
path: "/opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.4.so.1.1"
shouldExist: true

metadataTest:
user: "analyticalplatform"

Expand Down

0 comments on commit 1d8809f

Please sign in to comment.