Skip to content
This repository was archived by the owner on Aug 5, 2024. It is now read-only.

Commit 0f23f83

Browse files
committed
initial import
1 parent b9dfd75 commit 0f23f83

39 files changed

+6707
-8
lines changed

.devcontainer/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/java/.devcontainer/base.Dockerfile
2+
3+
# [Choice] Java version (use -bullseye variants on local arm64/Apple Silicon): 11, 17, 11-bullseye, 17-bullseye, 11-buster, 17-buster
4+
ARG VARIANT="17-bullseye"
5+
FROM mcr.microsoft.com/vscode/devcontainers/java:0-${VARIANT}
6+
7+
# [Option] Install Maven
8+
ARG INSTALL_MAVEN="false"
9+
ARG MAVEN_VERSION=""
10+
# [Option] Install Gradle
11+
ARG INSTALL_GRADLE="false"
12+
ARG GRADLE_VERSION=""
13+
RUN if [ "${INSTALL_MAVEN}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/sdkman/bin/sdkman-init.sh && sdk install maven \"${MAVEN_VERSION}\""; fi \
14+
&& if [ "${INSTALL_GRADLE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/sdkman/bin/sdkman-init.sh && sdk install gradle \"${GRADLE_VERSION}\""; fi
15+
16+
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
17+
ARG NODE_VERSION="none"
18+
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
19+
20+
# [Optional] Uncomment this section to install additional OS packages.
21+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
22+
# && apt-get -y install --no-install-recommends <your-package-list-here>
23+
24+
# [Optional] Uncomment this line to install global node packages.
25+
RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g swagger-ui-cli @openapitools/openapi-generator-cli" 2>&1

.devcontainer/devcontainer.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/java
3+
{
4+
"name": "Java",
5+
"build": {
6+
"dockerfile": "Dockerfile",
7+
"args": {
8+
// Update the VARIANT arg to pick a Java version: 11, 17
9+
// Append -bullseye or -buster to pin to an OS version.
10+
// Use the -bullseye variants on local arm64/Apple Silicon.
11+
"VARIANT": "17-bullseye",
12+
// Options
13+
"INSTALL_MAVEN": "true",
14+
"INSTALL_GRADLE": "false",
15+
"NODE_VERSION": "lts/*"
16+
}
17+
},
18+
19+
// Configure tool-specific properties.
20+
"customizations": {
21+
// Configure properties specific to VS Code.
22+
"vscode": {
23+
// Set *default* container specific settings.json values on container create.
24+
"settings": {
25+
},
26+
27+
// Add the IDs of extensions you want installed when the container is created.
28+
"extensions": [
29+
"vscjava.vscode-java-pack"
30+
]
31+
}
32+
},
33+
34+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
35+
// "forwardPorts": [],
36+
37+
// Use 'postCreateCommand' to run commands after the container is created.
38+
// "postCreateCommand": "java -version",
39+
40+
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
41+
"remoteUser": "vscode",
42+
"features": {
43+
"github-cli": "latest",
44+
"azure-cli": "latest"
45+
}
46+
}

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
9+
node_modules/
10+
dist
11+
local.settings.json
12+
.env
13+
pkg.zip
14+
tmp
15+
*.parameters.json

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"arrowParens": "avoid",
3+
"semi": false,
4+
"tabWidth": 4
5+
}

.vscode/extensions.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"recommendations": [
3+
]
4+
}

.vscode/launch.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "Launch Program",
11+
"skipFiles": [
12+
"<node_internals>/**"
13+
],
14+
"outputCapture": "std",
15+
"program": "run.js",
16+
"preLaunchTask": "tsc: build - tsconfig.json",
17+
"outFiles": [
18+
"${workspaceFolder}/dist/**/*.js"
19+
]
20+
}
21+
]
22+
}

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"debug.internalConsoleOptions": "neverOpen"
3+
}

.vscode/tasks.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"type": "shell",
6+
"label": "npm build (functions)",
7+
"command": "npm run build",
8+
"dependsOn": "npm install (functions)",
9+
"problemMatcher": "$tsc"
10+
},
11+
{
12+
"type": "shell",
13+
"label": "npm install (functions)",
14+
"command": "npm install"
15+
}
16+
]
17+
}

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
all:
2+
yarn build
3+
node run.js

README.md

Lines changed: 91 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,97 @@
1-
# Project
1+
# DeviceScript Development Gateway
22

3-
> This repo has been populated by an initial template to help get you started. Please
4-
> make sure to update the content to build a great experience for community-building.
3+
This project contains a prototype development gateway implementation
4+
for the built-in DeviceScript cloud integration.
55

6-
As the maintainer of this project, please make a few updates:
6+
| :exclamation: This implementation is for prototyping only and not meant for production. |
7+
| --------------------------------------------------------------------------------------- |
78

8-
- Improving this README.MD file to provide a great experience
9-
- Updating SUPPORT.MD with content about this project's support experience
10-
- Understanding the security reporting process in SECURITY.MD
11-
- Remove this section from the README
9+
## TODOs
10+
11+
- [ ] program deployment
12+
- [ ] figure out why methods don't work
13+
- [ ]
14+
15+
## Setup
16+
17+
The ARM template creates a Web App (F1 by default), Server farm, Application Insights, a Key Vault and a Storage.
18+
Once the ARM template has run, your DeviceScript development gateway will be ready to use.
19+
20+
- create a parameter file `azuredeploy.parameters.json` (it's .gitignored)
21+
22+
```json
23+
{
24+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
25+
"contentVersion": "1.0.0.0",
26+
"parameters": {
27+
"namePrefix": {
28+
"value": ""
29+
},
30+
"adminUserId": {
31+
"value": ""
32+
},
33+
"adminPassword": {
34+
"value": ""
35+
}
36+
}
37+
}
38+
```
39+
40+
- choose a name prefix and update it
41+
- find your user id and update `adminUserId` value
42+
43+
```bash
44+
az ad signed-in-user show --output yaml
45+
```
46+
47+
- create a new password and udpate `adminPassword`
48+
49+
```bash
50+
openssl rand -base64 32
51+
```
52+
53+
- create new resource group and run template and enter user id, admin password
54+
55+
```bash
56+
templateFile="azuredeploy.json"
57+
parametersFile="azuredeploy.parameters.json"
58+
az group create --name DeviceScriptCloud --location centralus --output yaml
59+
az deployment group create \
60+
--name devicescript \
61+
--resource-group DeviceScriptCloud \
62+
--template-file $templateFile \
63+
--parameters $parametersFile \
64+
--output yaml
65+
```
66+
67+
- clean up resources
68+
69+
```bash
70+
az group delete --name DeviceScriptCloud --output yaml
71+
```
72+
73+
Key vaults might have a soft-delete policy and you'll need to change the prefix or purge them.
74+
75+
- create a new `.env` file (it is git ignored) and include the key vault name and the local url
76+
77+
```txt
78+
KEY_VAULT_NAME="create key vault name"
79+
SELF_URL="http://0.0.0.0:7071"
80+
```
81+
82+
## Local development
83+
84+
- start a local instance using
85+
86+
```
87+
yarn dev
88+
```
89+
90+
- after running head to http://127.0.0.1:7071/swagger/ or otherwise the live site
91+
- Click Authorize
92+
- Use user/password from the `passwords` secret in the key vault
93+
94+
## Deployment
1295

1396
## Contributing
1497

0 commit comments

Comments
 (0)