Skip to content

Commit 69b5b54

Browse files
committed
Ensured that the Microsoft package repository is present in the post-create-command.sh script.
Signed-off-by: davem-bis <68955845+davem-bis@users.noreply.github.com>
1 parent 5f9ea72 commit 69b5b54

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

‎.devcontainer/post-create-command.sh‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
#!/bin/bash
22

3-
# This script is intended to be run by an Ubuntu dev container
3+
# This script is intended to be run by an Ubuntu development container
44

55
# Exit immediately if any command returns a non-zero code
66
set -e
77

88
# Install OS-level dependencies
99

10-
# Note that msodbcsql18 install requires the Microsoft APT repo to be available to this script. If this script is used
11-
# in conjunction with a container image from the Microsoft container registry this should already be the case.
12-
ALL_DEPENDENCIES="libpq-dev netcat-traditional unixodbc-dev default-jdk msodbcsql18"
10+
## Ensure that the Microsoft package repository is available as it is required for msodbcsql18. Note that the repository
11+
## may have already been added by a development container feature (e.g. docker-in-docker or java).
12+
if apt-cache policy | grep -q 'packages.microsoft.com'; then
13+
echo "Microsoft package repository already present"
14+
else
15+
echo "Microsoft package repository not present, it will be added."
16+
17+
# ref: https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server
18+
curl -sSL -O https://packages.microsoft.com/config/ubuntu/$(grep VERSION_ID /etc/os-release | cut -d '"' -f 2)/packages-microsoft-prod.deb
19+
sudo dpkg -i packages-microsoft-prod.deb
20+
rm packages-microsoft-prod.deb
21+
fi
1322

23+
ALL_DEPENDENCIES="libpq-dev netcat-traditional unixodbc-dev default-jdk msodbcsql18"
1424
sudo apt-get clean && sudo apt-get -y update && sudo ACCEPT_EULA='Y' apt-get -y install $ALL_DEPENDENCIES
1525

1626
# Install Python dependencies

0 commit comments

Comments
 (0)