Skip to content

Commit

Permalink
ci: use docker compose to run sql server with custom tls certificat…
Browse files Browse the repository at this point in the history
…e in GitHub Actions. (#1523)
  • Loading branch information
arthurschreiber committed Mar 22, 2023
1 parent 4359f58 commit ac23db7
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 60 deletions.
5 changes: 4 additions & 1 deletion .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ services:
- mssql

mssql:
image: "mcr.microsoft.com/mssql/server:2022-latest"
build: "./mssql"

restart: unless-stopped

environment:
- "ACCEPT_EULA=Y"
- "SA_PASSWORD=yourStrong(!)Password"

ports:
- "1433:1433"
3 changes: 1 addition & 2 deletions .devcontainer/test-connection.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
},
"options": {
"port": 1433,
"database": "master",
"trustServerCertificate": true
"database": "master"
}
}
}
22 changes: 11 additions & 11 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,6 @@ jobs:
node-version: [14.x, 16.x, 18.x]
fail-fast: false

services:
sqlserver:
image: mcr.microsoft.com/mssql/server
ports:
- 1433:1433
env:
ACCEPT_EULA: "Y"
SA_PASSWORD: "yourStrong(!)Password"

steps:
- uses: actions/checkout@v3

Expand All @@ -85,9 +76,18 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: Generate TLS Certificate
run: |
openssl req -x509 -newkey rsa:2048 -nodes -sha256 -subj '/CN=localhost' -keyout ./test/fixtures/localhost.key -out ./test/fixtures/localhost.crt
- name: Start containers
run: |
docker-compose -f "test/docker-compose.linux.yml" up --detach
- name: Set up CI configuration
run: |
mkdir ~/.tedious
echo '{
"config": {
"server": "localhost",
Expand All @@ -101,10 +101,10 @@ jobs:
"options": {
"port": 1433,
"database": "master",
"trustServerCertificate": true
"encrypt": true
}
}
}' > ~/.tedious/test-connection.json
}' | jq --arg certificate "$(cat ./test/fixtures/localhost.crt)" '.config.options.cryptoCredentialsDetails.ca |= $certificate' > ~/.tedious/test-connection.json
- name: Upgrade npm
run: npm install -g npm
Expand Down
6 changes: 6 additions & 0 deletions test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM mcr.microsoft.com/mssql/server:2022-latest

USER mssql
COPY --chown=mssql:root ./fixtures/mssql.conf /var/opt/mssql/mssql.conf
COPY --chown=mssql:root ./fixtures/localhost.crt /var/opt/mssql/localhost.crt
COPY --chown=mssql:root ./fixtures/localhost.key /var/opt/mssql/localhost.key
14 changes: 14 additions & 0 deletions test/docker-compose.linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3'

services:
mssql:
build: "."

restart: unless-stopped

environment:
- "ACCEPT_EULA=Y"
- "SA_PASSWORD=yourStrong(!)Password"

ports:
- "1433:1433"
Empty file added test/fixtures/.gitkeep
Empty file.
18 changes: 0 additions & 18 deletions test/fixtures/localhost.crt

This file was deleted.

28 changes: 0 additions & 28 deletions test/fixtures/localhost.key

This file was deleted.

3 changes: 3 additions & 0 deletions test/fixtures/mssql.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[network]
tlscert = /var/opt/mssql/localhost.crt
tlskey = /var/opt/mssql/localhost.key

0 comments on commit ac23db7

Please sign in to comment.