Skip to content

Commit 8694f6c

Browse files
Master
see auth0#741 By submitting a PR to this repository, you agree to the terms within the [Auth0 Code of Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md). Please see the [contributing guidelines](https://github.com/auth0/.github/blob/master/CONTRIBUTING.md) for how to create and submit a high-quality PR for this repo. ### Description > Describe the purpose of this PR along with any background information and the impacts of the proposed change. For the benefit of the community, please do not assume prior context. > > Provide details that support your chosen implementation, including: breaking changes, alternatives considered, changes to the API, etc. > > If the UI is being changed, please provide screenshots. ### References > Include any links supporting this change such as a: > > - GitHub Issue/PR number addressed or fixed > - Auth0 Community post > - StackOverflow post > - Support forum thread > - Related pull requests/issues from other repos > > If there are no references, simply delete this section. ### Testing > Describe how this can be tested by reviewers. Be specific about anything not tested and reasons why. If this library has unit and/or integration testing, tests should be added for new functionality and existing tests should complete without errors. > > Please include any manual steps for testing end-to-end or functionality not covered by unit/integration tests. > > Also include details of the environment this PR was developed in (language/platform/browser version). - [ ] This change adds test coverage for new/changed/fixed functionality ### Checklist - [ ] I have added documentation for new/changed functionality in this PR or in auth0.com/docs - [ ] All active GitHub checks for tests, formatting, and security are passing - [ ] The correct base branch is being used, if not the default branch
1 parent a46097e commit 8694f6c

File tree

7 files changed

+198
-0
lines changed

7 files changed

+198
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM mcr.microsoft.com/devcontainers/dotnet:1-8.0-bookworm
2+
3+
# Install SQL Tools: SQLPackage and sqlcmd
4+
COPY mssql/installSQLtools.sh installSQLtools.sh
5+
RUN bash ./installSQLtools.sh \
6+
&& apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts
7+
8+
# [Optional] Uncomment this section to install additional OS packages.
9+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
10+
# && apt-get -y install --no-install-recommends <your-package-list-here>
11+
12+
# [Optional] Uncomment this line to install global node packages.
13+
RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install 21 && nvm use 21 && npm install -g typescript" 2>&1
14+
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1

.devcontainer/devcontainer.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/dotnet-mssql
3+
{
4+
"name": ".NET (C#), Node.js (TypeScript) & MS SQL",
5+
"dockerComposeFile": "docker-compose.yml",
6+
"service": "app",
7+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
8+
9+
// Features to add to the dev container. More info: https://containers.dev/features.
10+
// "features": {},
11+
12+
// Configure tool-specific properties.
13+
"customizations": {
14+
// Configure properties specific to VS Code.
15+
"vscode": {
16+
// Set *default* container specific settings.json values on container create.
17+
"settings": {
18+
"mssql.connections": [
19+
{
20+
"server": "localhost,1433",
21+
"database": "",
22+
"authenticationType": "SqlLogin",
23+
"user": "sa",
24+
"password": "P@ssw0rd",
25+
"emptyPasswordInput": false,
26+
"savePassword": false,
27+
"profileName": "mssql-container"
28+
}
29+
]
30+
},
31+
32+
// Add the IDs of extensions you want installed when the container is created.
33+
"extensions": [
34+
"ms-dotnettools.csharp",
35+
"ms-mssql.mssql",
36+
"ms-vscode.js-debug-nightly"
37+
]
38+
}
39+
},
40+
41+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
42+
// "forwardPorts": [5000, 5001],
43+
// "portsAttributes": {
44+
// "5001": {
45+
// "protocol": "https"
46+
// }
47+
// }
48+
49+
// postCreateCommand.sh parameters: $1=SA password, $2=dacpac path, $3=sql script(s) path
50+
"postCreateCommand": "bash .devcontainer/mssql/postCreateCommand.sh 'P@ssw0rd' './bin/Debug/' './.devcontainer/mssql/'",
51+
"features": {
52+
"ghcr.io/itsmechlark/features/1password:1": {
53+
"version": "latest"
54+
}
55+
}
56+
57+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
58+
// "remoteUser": "root"
59+
}

.devcontainer/docker-compose.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
version: '3'
2+
3+
services:
4+
app:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
9+
volumes:
10+
- ../..:/workspaces:cached
11+
12+
# Overrides default command so things don't shut down after the process ends.
13+
command: sleep infinity
14+
15+
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
16+
network_mode: service:db
17+
18+
# Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
19+
# user: root
20+
21+
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
22+
# (Adding the "ports" property to this file will not forward from a Codespace.)
23+
24+
db:
25+
image: mcr.microsoft.com/mssql/server:2019-latest
26+
restart: unless-stopped
27+
environment:
28+
SA_PASSWORD: P@ssw0rd
29+
ACCEPT_EULA: Y
30+
31+
# Add "forwardPorts": ["db:1433"] to **devcontainer.json** to forward MSSQL locally.
32+
# (Adding the "ports" property to this file will not forward from a Codespace.)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
echo "Installing mssql-tools"
3+
curl -sSL https://packages.microsoft.com/keys/microsoft.asc | (OUT=$(apt-key add - 2>&1) || echo $OUT)
4+
DISTRO=$(lsb_release -is | tr '[:upper:]' '[:lower:]')
5+
CODENAME=$(lsb_release -cs)
6+
echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-${DISTRO}-${CODENAME}-prod ${CODENAME} main" > /etc/apt/sources.list.d/microsoft.list
7+
apt-get update
8+
ACCEPT_EULA=Y apt-get -y install unixodbc-dev msodbcsql17 libunwind8 mssql-tools
9+
10+
echo "Installing sqlpackage"
11+
curl -sSL -o sqlpackage.zip "https://aka.ms/sqlpackage-linux"
12+
mkdir /opt/sqlpackage
13+
unzip sqlpackage.zip -d /opt/sqlpackage
14+
rm sqlpackage.zip
15+
chmod a+x /opt/sqlpackage/sqlpackage
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
dacpac="false"
3+
sqlfiles="false"
4+
SApassword=$1
5+
dacpath=$2
6+
sqlpath=$3
7+
8+
echo "SELECT * FROM SYS.DATABASES" | dd of=testsqlconnection.sql
9+
for i in {1..60};
10+
do
11+
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $SApassword -d master -i testsqlconnection.sql > /dev/null
12+
if [ $? -eq 0 ]
13+
then
14+
echo "SQL server ready"
15+
break
16+
else
17+
echo "Not ready yet..."
18+
sleep 1
19+
fi
20+
done
21+
rm testsqlconnection.sql
22+
23+
for f in $dacpath/*
24+
do
25+
if [ $f == $dacpath/*".dacpac" ]
26+
then
27+
dacpac="true"
28+
echo "Found dacpac $f"
29+
fi
30+
done
31+
32+
for f in $sqlpath/*
33+
do
34+
if [ $f == $sqlpath/*".sql" ]
35+
then
36+
sqlfiles="true"
37+
echo "Found SQL file $f"
38+
fi
39+
done
40+
41+
if [ $sqlfiles == "true" ]
42+
then
43+
for f in $sqlpath/*
44+
do
45+
if [ $f == $sqlpath/*".sql" ]
46+
then
47+
echo "Executing $f"
48+
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $SApassword -d master -i $f
49+
fi
50+
done
51+
fi
52+
53+
if [ $dacpac == "true" ]
54+
then
55+
for f in $dacpath/*
56+
do
57+
if [ $f == $dacpath/*".dacpac" ]
58+
then
59+
dbname=$(basename $f ".dacpac")
60+
echo "Deploying dacpac $f"
61+
/opt/sqlpackage/sqlpackage /Action:Publish /SourceFile:$f /TargetServerName:localhost /TargetDatabaseName:$dbname /TargetUser:sa /TargetPassword:$SApassword
62+
fi
63+
done
64+
fi

.devcontainer/mssql/setup.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CREATE DATABASE ApplicationDB;
2+
GO

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for more information:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
# https://containers.dev/guide/dependabot
6+
7+
version: 2
8+
updates:
9+
- package-ecosystem: "devcontainers"
10+
directory: "/"
11+
schedule:
12+
interval: weekly

0 commit comments

Comments
 (0)