From 8694f6c40c9a2f5f7a2f2a7f8d9a96cc11c1dae8 Mon Sep 17 00:00:00 2001 From: "Vilma Fulitod(marqueeseN)" Date: Sun, 28 Jul 2024 19:53:19 +0000 Subject: [PATCH] Master see #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 --- .devcontainer/Dockerfile | 14 ++++++ .devcontainer/devcontainer.json | 59 ++++++++++++++++++++++ .devcontainer/docker-compose.yml | 32 ++++++++++++ .devcontainer/mssql/installSQLtools.sh | 15 ++++++ .devcontainer/mssql/postCreateCommand.sh | 64 ++++++++++++++++++++++++ .devcontainer/mssql/setup.sql | 2 + .github/dependabot.yml | 12 +++++ 7 files changed, 198 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/docker-compose.yml create mode 100644 .devcontainer/mssql/installSQLtools.sh create mode 100644 .devcontainer/mssql/postCreateCommand.sh create mode 100644 .devcontainer/mssql/setup.sql create mode 100644 .github/dependabot.yml diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..164e365c --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,14 @@ +FROM mcr.microsoft.com/devcontainers/dotnet:1-8.0-bookworm + +# Install SQL Tools: SQLPackage and sqlcmd +COPY mssql/installSQLtools.sh installSQLtools.sh +RUN bash ./installSQLtools.sh \ + && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts + +# [Optional] Uncomment this section to install additional OS packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + +# [Optional] Uncomment this line to install global node packages. +RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install 21 && nvm use 21 && npm install -g typescript" 2>&1 +# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..337d1091 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,59 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/dotnet-mssql +{ + "name": ".NET (C#), Node.js (TypeScript) & MS SQL", + "dockerComposeFile": "docker-compose.yml", + "service": "app", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Configure tool-specific properties. + "customizations": { + // Configure properties specific to VS Code. + "vscode": { + // Set *default* container specific settings.json values on container create. + "settings": { + "mssql.connections": [ + { + "server": "localhost,1433", + "database": "", + "authenticationType": "SqlLogin", + "user": "sa", + "password": "P@ssw0rd", + "emptyPasswordInput": false, + "savePassword": false, + "profileName": "mssql-container" + } + ] + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ms-dotnettools.csharp", + "ms-mssql.mssql", + "ms-vscode.js-debug-nightly" + ] + } + }, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [5000, 5001], + // "portsAttributes": { + // "5001": { + // "protocol": "https" + // } + // } + + // postCreateCommand.sh parameters: $1=SA password, $2=dacpac path, $3=sql script(s) path + "postCreateCommand": "bash .devcontainer/mssql/postCreateCommand.sh 'P@ssw0rd' './bin/Debug/' './.devcontainer/mssql/'", + "features": { + "ghcr.io/itsmechlark/features/1password:1": { + "version": "latest" + } + } + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 00000000..1a8892aa --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,32 @@ +version: '3' + +services: + app: + build: + context: . + dockerfile: Dockerfile + + volumes: + - ../..:/workspaces:cached + + # Overrides default command so things don't shut down after the process ends. + command: sleep infinity + + # Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function. + network_mode: service:db + + # Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + # user: root + + # Use "forwardPorts" in **devcontainer.json** to forward an app port locally. + # (Adding the "ports" property to this file will not forward from a Codespace.) + + db: + image: mcr.microsoft.com/mssql/server:2019-latest + restart: unless-stopped + environment: + SA_PASSWORD: P@ssw0rd + ACCEPT_EULA: Y + + # Add "forwardPorts": ["db:1433"] to **devcontainer.json** to forward MSSQL locally. + # (Adding the "ports" property to this file will not forward from a Codespace.) diff --git a/.devcontainer/mssql/installSQLtools.sh b/.devcontainer/mssql/installSQLtools.sh new file mode 100644 index 00000000..0edc46a3 --- /dev/null +++ b/.devcontainer/mssql/installSQLtools.sh @@ -0,0 +1,15 @@ +#!/bin/bash +echo "Installing mssql-tools" +curl -sSL https://packages.microsoft.com/keys/microsoft.asc | (OUT=$(apt-key add - 2>&1) || echo $OUT) +DISTRO=$(lsb_release -is | tr '[:upper:]' '[:lower:]') +CODENAME=$(lsb_release -cs) +echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-${DISTRO}-${CODENAME}-prod ${CODENAME} main" > /etc/apt/sources.list.d/microsoft.list +apt-get update +ACCEPT_EULA=Y apt-get -y install unixodbc-dev msodbcsql17 libunwind8 mssql-tools + +echo "Installing sqlpackage" +curl -sSL -o sqlpackage.zip "https://aka.ms/sqlpackage-linux" +mkdir /opt/sqlpackage +unzip sqlpackage.zip -d /opt/sqlpackage +rm sqlpackage.zip +chmod a+x /opt/sqlpackage/sqlpackage diff --git a/.devcontainer/mssql/postCreateCommand.sh b/.devcontainer/mssql/postCreateCommand.sh new file mode 100644 index 00000000..4b9888ab --- /dev/null +++ b/.devcontainer/mssql/postCreateCommand.sh @@ -0,0 +1,64 @@ +#!/bin/bash +dacpac="false" +sqlfiles="false" +SApassword=$1 +dacpath=$2 +sqlpath=$3 + +echo "SELECT * FROM SYS.DATABASES" | dd of=testsqlconnection.sql +for i in {1..60}; +do + /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $SApassword -d master -i testsqlconnection.sql > /dev/null + if [ $? -eq 0 ] + then + echo "SQL server ready" + break + else + echo "Not ready yet..." + sleep 1 + fi +done +rm testsqlconnection.sql + +for f in $dacpath/* +do + if [ $f == $dacpath/*".dacpac" ] + then + dacpac="true" + echo "Found dacpac $f" + fi +done + +for f in $sqlpath/* +do + if [ $f == $sqlpath/*".sql" ] + then + sqlfiles="true" + echo "Found SQL file $f" + fi +done + +if [ $sqlfiles == "true" ] +then + for f in $sqlpath/* + do + if [ $f == $sqlpath/*".sql" ] + then + echo "Executing $f" + /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $SApassword -d master -i $f + fi + done +fi + +if [ $dacpac == "true" ] +then + for f in $dacpath/* + do + if [ $f == $dacpath/*".dacpac" ] + then + dbname=$(basename $f ".dacpac") + echo "Deploying dacpac $f" + /opt/sqlpackage/sqlpackage /Action:Publish /SourceFile:$f /TargetServerName:localhost /TargetDatabaseName:$dbname /TargetUser:sa /TargetPassword:$SApassword + fi + done +fi diff --git a/.devcontainer/mssql/setup.sql b/.devcontainer/mssql/setup.sql new file mode 100644 index 00000000..94fcd9ce --- /dev/null +++ b/.devcontainer/mssql/setup.sql @@ -0,0 +1,2 @@ +CREATE DATABASE ApplicationDB; +GO diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..f33a02cd --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for more information: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates +# https://containers.dev/guide/dependabot + +version: 2 +updates: + - package-ecosystem: "devcontainers" + directory: "/" + schedule: + interval: weekly