Skip to content

Commit 2467e23

Browse files
SamirTalwarhasura-bot
authored andcommitted
docker: Always use the official SQL Server image for testing.
Now that Docker for macOS supports using Rosetta for x86/amd64 emulation, we no longer need to use the `azure-sql-edge` image. We can always use the official `mcr.microsoft.com/mssql/server` one. This also means that we no longer need the separate healthcheck container, because the official image ships with `sqlcmd`. When this is merged, you will need to ensure you have enabled Rosetta emulation in the Docker settings to test against SQL Server on macOS. This requires macOS 13 (Ventura). PR-URL: hasura/graphql-engine-mono#10139 GitOrigin-RevId: 2225bf5f4c6d3632da1f29b2229c9b04ead5e34c
1 parent ad08230 commit 2467e23

File tree

13 files changed

+38
-139
lines changed

13 files changed

+38
-139
lines changed

Diff for: .envrc

-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@
33
# This file provides some tooling on an opt-in basis via `direnv`
44
# (https://direnv.net/)
55

6-
# We cannot use the proper MSSQL Server image on arm64, as it's not available.
7-
# Instead, we use `mcr.microsoft.com/azure-sql-edge`.
8-
if [[ "$(uname -m)" == 'arm64' ]]; then
9-
export MSSQL_IMAGE='mcr.microsoft.com/azure-sql-edge'
10-
fi
11-
126
# To use the functionality here, create an `.envrc.local` file in this folder
137
# that runs the functions you need.
148
# There is an example in `.envrc.local.example` you can start with

Diff for: .envrc.local.example

-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
# HASURA_BIGQUERY_SERVICE_KEY=$(cat ../bigquery-service-account.json)
2525
# export HASURA_BIGQUERY_SERVICE_KEY
2626

27-
### Enable to use the correct image for SQLServer on an M1
28-
### (the env var is used in our Docker Compose files)
29-
# export MSSQL_IMAGE='mcr.microsoft.com/azure-sql-edge'
30-
3127
### Export EE license key for running pro tests locally
3228
### This depends on a `ee-license-key.txt` living in the directory above
3329
### the `graphql-engine` repository

Diff for: docker-compose.yaml

+6-9
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,16 @@
2121
#
2222
# Facts:
2323
#
24-
# * The SERVICE PORTS numbering start at 65001, 65002, etc. to avoid bother
24+
# * The SERVICE PORTS numbering start at 65001, 65002, etc. to avoid bothering
2525
# existing instances of databases.
2626
#
2727
# * The login credentials are, where possible, all "hasura" to avoid unnecessary
2828
# mental overhead.
29+
#
30+
# * The SQL Server image will only work on macOS if you enable the relevant
31+
# settings. Open the Docker Desktop settings, enable "Use Virtualization
32+
# framework" in the "General" tab, and "Use Rosetta for x86/amd64 emulation on
33+
# Apple Silicon" in the "Features in development" tab.
2934

3035
version: "3.6"
3136

@@ -81,14 +86,6 @@ services:
8186
volumes:
8287
- mssql-data:/var/opt/mssql
8388

84-
sqlserver-healthcheck:
85-
extends:
86-
file: docker-compose/databases.yaml
87-
service: sqlserver-healthcheck
88-
depends_on:
89-
sqlserver:
90-
condition: service_started
91-
9289
dc-reference-agent:
9390
extends:
9491
file: dc-agents/docker-compose.yaml

Diff for: docker-compose/databases.yaml

+3-27
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,8 @@ services:
8181
- /var/lib/postgresql/data
8282

8383
sqlserver:
84-
# We cannot use this image on arm64, as it's not available.
85-
# Instead, we use `mcr.microsoft.com/azure-sql-edge`.
86-
# This uses an environment variable so it can be overridden by scripts to
87-
# provide that image instead.
88-
image: ${MSSQL_IMAGE:-mcr.microsoft.com/mssql/server:2019-latest}
89-
init: true # azure-sql-edge doesn't shut down properly without this
84+
image: mcr.microsoft.com/mssql/server:2019-latest
85+
platform: linux/amd64
9086
ports:
9187
- 1433
9288
environment:
@@ -95,35 +91,15 @@ services:
9591
MSSQL_SA_PASSWORD: "Password!"
9692
volumes:
9793
- /var/opt/mssql
98-
99-
# We would prefer to attach the healthcheck directly to the `sqlserver` container.
100-
# However, while we can do this in the `mcr.microsoft.com/mssql/server` image,
101-
# it's not possible when running on macOS, as we don't use that image, but
102-
# instead `mcr.microsoft.com/azure-sql-edge`.
103-
# The `mcr.microsoft.com/azure-sql-edge` image does not provide `sqlcmd`.
104-
# We therefore need to run it in a separate container.
105-
# We can reconsider this once the MSSQL Server image can run on arm64.
106-
sqlserver-healthcheck:
107-
image: mcr.microsoft.com/mssql-tools
108-
platform: linux/amd64
109-
command:
110-
- sleep
111-
- inf
112-
init: true # handle signals correctly
11394
healthcheck:
11495
test:
11596
- CMD-SHELL
11697
- |
117-
/opt/mssql-tools/bin/sqlcmd -S 'sqlserver,1433' -U SA -P "Password!"
98+
/opt/mssql-tools/bin/sqlcmd -U SA -P "$$SA_PASSWORD"
11899
start_period: 5s
119100
interval: 5s
120101
timeout: 10s
121102
retries: 20
122-
# This is commented out because this file can be extended, and dependencies don't work for extensions.
123-
# Instead, ensure you also run this one.
124-
# depends_on:
125-
# sqlserver:
126-
# condition: service_started
127103

128104
mysql:
129105
image: mysql

Diff for: frontend/docker/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ You may also need to flip the [feature flags here](http://localhost:4200/setting
2121

2222
## MSSQL / SQL Server
2323

24-
In order to initialize and populate a MSSQL demo database automatically, we making use of the `mssql-tools` image. This image runs a few commands against the `mssql` image to create the demo data.
24+
In order to initialize and populate a MSSQL demo database automatically, we making use of the `mssql-init` container. This image runs a few commands against the `mssql` image to create the demo data.
2525

2626
This scripting is done in `docker/DataSources/mssql/run-initialization.sh`.
2727

Diff for: frontend/docker/docker-compose.template.yml

+17-15
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ services:
3535
- '8100:8100'
3636
volumes:
3737
- ./DataSources/sqlite.db:/sqlite.db
38+
# The SQL Server image will only work on macOS if you enable the relevant
39+
# settings. Open the Docker Desktop settings, enable "Use Virtualization
40+
# framework" in the "General" tab, and "Use Rosetta for x86/amd64 emulation on
41+
# Apple Silicon" in the "Features in development" tab.
3842
mssql:
3943
container_name: 'mssql'
4044
user: root
@@ -43,14 +47,23 @@ services:
4347
volumes:
4448
- mssql-database-data:/var/opt/mssql
4549
stdin_open: true
46-
image: mcr.microsoft.com/azure-sql-edge:latest
47-
# if not running Apple Silicon (M1/M2 etc), you can use this:
48-
#image: mcr.microsoft.com/mssql/server:2022-latest
49-
init: true # azure-sql-edge doesn't shut down properly without this
50+
image: &mssql-image mcr.microsoft.com/mssql/server:2019-latest
51+
platform: linux/amd64
5052
environment:
5153
ACCEPT_EULA: 'Y'
5254
SA_PASSWORD: 'Password!'
5355
MSSQL_SA_PASSWORD: 'Password!'
56+
mssql-init:
57+
depends_on:
58+
- mssql
59+
container_name: 'mssql-init'
60+
image: *mssql-image
61+
platform: linux/amd64
62+
command:
63+
- /opt/mssql_scripts/run-initialization.sh
64+
stdin_open: true
65+
volumes:
66+
- ./DataSources/mssql:/opt/mssql_scripts
5467
mongo:
5568
image: mongo
5669
restart: always
@@ -62,17 +75,6 @@ services:
6275
- '27017:27017'
6376
command: mongod --setParameter enableLocalhostAuthBypass=0 --dbpath=/data/db --bind_ip_all --port 27017
6477

65-
# sqlcmd (tools) are not included in the arm64 image
66-
mssql-tools:
67-
depends_on:
68-
- mssql
69-
container_name: 'mssql-tools'
70-
image: mcr.microsoft.com/mssql-tools:latest
71-
command: bash /opt/mssql_scripts/run-initialization.sh
72-
stdin_open: true
73-
volumes:
74-
- ./DataSources/mssql:/opt/mssql_scripts
75-
7678
graphql-engine:
7779
image: hasura/graphql-engine:latest
7880

Diff for: scripts/make/repl.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
.PHONY: repl-sqlserver
44
## repl-sqlserver: start a sqlserver docker image and connect to it using sqlcmd
55
repl-sqlserver:
6-
@docker compose up -d --wait sqlserver-healthcheck
6+
@docker compose up -d --wait sqlserver
77
@sqlcmd -S localhost,$(shell docker compose port sqlserver 1433 | sed -e 's#.*:\(\)#\1#') -U SA -P "Password!"
88

99
.PHONY: repl-postgres

Diff for: scripts/make/test-infrastructure.mk

-10
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,6 @@ API_TESTS_DOCKER_COMPOSE = docker compose --project-directory=./server/lib/api-t
22
API_TESTS_PRO_DOCKER_COMPOSE = docker compose --project-directory=./pro/server/lib/api-tests
33
PYTHON_TESTS_DOCKER_COMPOSE = docker compose --project-directory=./server/tests-py
44

5-
# Use the Azure SQL Edge image instead of the SQL Server image on arm64.
6-
# The latter doesn't work yet.
7-
ifeq ($(shell uname -m),arm64)
8-
MSSQL_IMAGE=mcr.microsoft.com/azure-sql-edge
9-
else
10-
MSSQL_IMAGE= # allow the Docker Compose file to set the image
11-
endif
12-
13-
export MSSQL_IMAGE
14-
155
TEST_MSSQL_CONNECTION_STRING = Driver={ODBC Driver 18 for SQL Server};Server=localhost,65003;Uid=sa;Pwd=Password!;Encrypt=optional
166
TEST_POSTGRES_URL = postgres://hasura:hasura@localhost:65002/hasura
177

Diff for: scripts/make/tests.mk

+4-4
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ test-unit: remove-tix-file
147147
.PHONY: test-integration-mssql
148148
## test-integration-mssql: run MS SQL Server integration tests
149149
test-integration-mssql: remove-tix-file
150-
docker compose up --build --detach --wait sqlserver-healthcheck
150+
docker compose up --build --detach --wait sqlserver
151151
HASURA_MSSQL_CONN_STR='$(TEST_MSSQL_CONNECTION_STRING)' \
152152
cabal run graphql-engine:test:graphql-engine-test-mssql
153153

@@ -162,7 +162,7 @@ test-integration-postgres: remove-tix-file
162162
## test-native-queries: run all tests for the Native Query feature
163163
test-native-queries:
164164
cabal build exe:graphql-engine-pro
165-
docker compose up --build --detach --wait postgres citus cockroach sqlserver-healthcheck
165+
docker compose up --build --detach --wait postgres citus cockroach sqlserver
166166
HSPEC_MATCH=NativeQueries make test-unit
167167
HSPEC_MATCH=NativeQueries \
168168
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PRO_PATH) \
@@ -183,7 +183,7 @@ test-native-queries-postgres:
183183
## test-native-queries-sqlserver: run all sqlserver tests for the Native Query feature
184184
test-native-queries-sqlserver: remove-tix-file
185185
cabal build exe:graphql-engine-pro
186-
docker compose up --build --detach --wait postgres sqlserver-healthcheck
186+
docker compose up --build --detach --wait postgres sqlserver
187187
HSPEC_MATCH=${HSPEC_MATCH:-"NativeQueries"}
188188
HASURA_TEST_BACKEND_TYPE=SQLServer \
189189
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PRO_PATH) \
@@ -203,7 +203,7 @@ test-native-queries-bigquery: remove-tix-file
203203
## test-stored-procedures-sqlserver: run all sqlserver tests for the Stored Procedure feature
204204
test-stored-procedures-sqlserver: remove-tix-file
205205
cabal build exe:graphql-engine-pro
206-
docker compose up --build --detach --wait postgres sqlserver-healthcheck
206+
docker compose up --build --detach --wait postgres sqlserver
207207
HASURA_TEST_BACKEND_TYPE=SQLServer \
208208
HSPEC_MATCH=StoredProcedures \
209209
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PRO_PATH) \

Diff for: server/lib/api-tests/README.md

+5-39
Original file line numberDiff line numberDiff line change
@@ -311,43 +311,9 @@ brew install microsoft/mssql-release/mssql-tools@18
311311
brew unlink mssql-tools18 && brew link mssql-tools18
312312
```
313313

314-
### Microsoft SQL Server failures on Apple aarch64 chips
314+
### The MS SQL Server container fails to start
315315

316-
This applies to all Apple hardware that uses aarch64 chips, e.g. the MacBook M1
317-
or M2.
318-
319-
We have a few problems with Microsoft SQL Server on Apple aarch64:
320-
321-
1. Microsoft has not yet released SQL Server for aarch64. We need to use Azure
322-
SQL Edge instead.
323-
324-
You don't need to do anything if you're using the `make` commands; they
325-
will provide the correct image automatically.
326-
327-
If you run `docker compose` directly, make sure to set the environment
328-
variable yourself:
329-
330-
```sh
331-
export MSSQL_IMAGE='mcr.microsoft.com/azure-sql-edge'
332-
```
333-
334-
You can add this to your _.envrc.local_ file if you like.
335-
336-
2. Azure SQL Edge for aarch64 does not ship with the `sqlcmd` utility with
337-
which we use to setup the SQL Server schema.
338-
339-
If you need it, you can instead use the `mssql-tools` Docker image, for
340-
example:
341-
342-
```
343-
docker run --rm -it --platform=linux/amd64 --net=host mcr.microsoft.com/mssql-tools \
344-
/opt/mssql-tools/bin/sqlcmd -S localhost,65003 -U SA -P <password>
345-
```
346-
347-
To make this easier, you might want to define an alias:
348-
349-
```
350-
alias sqlcmd='docker run --rm -it --platform=linux/amd64 --net=host mcr.microsoft.com/mssql-tools /opt/mssql-tools/bin/sqlcmd'
351-
```
352-
353-
You can also install them directly with `brew install microsoft/mssql-release/mssql-tools`.
316+
The SQL Server image will only work on macOS if you enable the relevant
317+
settings. Open the Docker Desktop settings, enable "Use Virtualization
318+
framework" in the "General" tab, and "Use Rosetta for x86/amd64 emulation on
319+
Apple Silicon" in the "Features in development" tab.

Diff for: server/lib/api-tests/docker-compose.yaml

-8
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,6 @@ services:
5252
volumes:
5353
- mssql-data:/var/opt/mssql
5454

55-
sqlserver-healthcheck:
56-
extends:
57-
file: ../../../docker-compose/databases.yaml
58-
service: sqlserver-healthcheck
59-
depends_on:
60-
sqlserver:
61-
condition: service_started
62-
6355
dc-reference-agent:
6456
extends:
6557
file: ../../../dc-agents/docker-compose.yaml

Diff for: server/tests-py/docker-compose.yml

-8
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,3 @@ services:
2727
extends:
2828
file: ../../docker-compose/databases.yaml
2929
service: sqlserver
30-
31-
sqlserver-healthcheck:
32-
extends:
33-
file: ../../docker-compose/databases.yaml
34-
service: sqlserver-healthcheck
35-
depends_on:
36-
sqlserver:
37-
condition: service_started

Diff for: server/tests-py/run.sh

+1-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ set -o pipefail
1414

1515
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
1616

17-
DATABASES=(postgres citus sqlserver sqlserver-healthcheck)
17+
DATABASES=(postgres citus sqlserver)
1818

1919
(
2020
cd ../..
@@ -29,12 +29,6 @@ DATABASES=(postgres citus sqlserver sqlserver-healthcheck)
2929
# shellcheck disable=SC1091
3030
source .hasura-dev-python-venv/bin/activate
3131

32-
# Use the Azure SQL Edge image instead of the SQL Server image on arm64.
33-
# The latter doesn't work yet.
34-
if [[ "$(uname -m)" == 'arm64' ]]; then
35-
export MSSQL_IMAGE='mcr.microsoft.com/azure-sql-edge'
36-
fi
37-
3832
echo
3933
echo '*** Starting databases ***'
4034
docker compose up -d --wait "${DATABASES[@]}"

0 commit comments

Comments
 (0)