Skip to content

Commit

Permalink
Merge branch '#2073-Sync-AWS-GreenGrass-Deployment' of https://github…
Browse files Browse the repository at this point in the history
….com/CGI-FR/IoT-Hub-Portal into #2073-Sync-AWS-GreenGrass-Deployment
  • Loading branch information
ssgueye2 committed May 30, 2023
2 parents e732724 + 9c67f6e commit b3c6469
Show file tree
Hide file tree
Showing 24 changed files with 79 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.238.0/containers/dotnet/.devcontainer/base.Dockerfile

# [Choice] .NET version: 6.0, 3.1, 6.0-bullseye, 3.1-bullseye, 6.0-focal, 3.1-focal
ARG VARIANT="6.0-bullseye-slim"
FROM mcr.microsoft.com/vscode/devcontainers/dotnet:0-${VARIANT}
ARG VARIANT="7.0-bullseye-slim"
FROM mcr.microsoft.com/vscode/devcontainers/dotnet:dev-${VARIANT}

# [Choice] Node.js version: none, lts/*, 18, 16, 14
ARG NODE_VERSION="none"
Expand Down
24 changes: 12 additions & 12 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
// https://github.com/microsoft/vscode-dev-containers/tree/v0.238.0/containers/dotnet
{
"name": "C# (.NET)",
"build": {
"dockerfile": "Dockerfile",
"args": {
// Update 'VARIANT' to pick a .NET Core version: 3.1, 6.0
// Append -bullseye or -focal to pin to an OS version.
"VARIANT": "6.0-bullseye",
// Options
"NODE_VERSION": "lts/*"
}
},
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
"dockerComposeFile": "docker-compose.yml",

// The 'service' property is the name of the service for the container that VS Code should
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
"service": "app",

// The 'workspaceFolder' property is the path VS Code should open by default when
// connected. Corresponds to a volume mount in .devcontainer/docker-compose.yml
"workspaceFolder": "/workspace",

// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
Expand All @@ -21,7 +22,6 @@
"ms-dotnettools.csharp",
"ms-dotnettools.vscode-dotnet-runtime",
"tintoy.msbuild-project-tools",
"jchannon.csharpextensions",
"fernandoescolar.vscode-solution-explorer"
]
}
Expand Down Expand Up @@ -51,7 +51,7 @@
// * If only using Remote - Containers with a local container, uncomment this line instead:
// "mounts": [ "source=${env:HOME}${env:USERPROFILE}/.aspnet/https,target=/home/vscode/.aspnet/https,type=bind" ],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "dotnet restore",
"postCreateCommand": "dotnet dev-certs https --trust && dotnet restore src/*.sln",
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
40 changes: 40 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: '3.4'

services:
database:
image: postgres:14-alpine
restart: always
environment:
POSTGRES_PASSWORD: postgrePassword
POSTGRES_DB: cgigeiotdemo
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "sh -c 'pg_isready -U postgres -d cgigeiotdemo'"]
interval: 10s
timeout: 5s
retries: 5

app:
build:
context: .
dockerfile: Dockerfile
# [Optional] You can use build args to set options. e.g. 'VARIANT' below affects the image in the Dockerfile
args:
NODE_VERSION: lts/*

volumes:
# This is where VS Code should expect to find your project's source code and the value of "workspaceFolder" in .devcontainer/devcontainer.json
- ..:/workspace:cached

# Uncomment the next line to use Docker from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker-compose for details.
- /var/run/docker.sock:/var/run/docker.sock

# Overrides default command so things don't shut down after the process ends.
command: /bin/sh -c "while sleep 1000; do :; done"

depends_on:
database:
condition: service_healthy
volumes:
pgdata:
26 changes: 18 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
${{ steps.meta.outputs.tags }}

arm_templates:
name: Publish ARM templates
name: Publish cloud infrastructure templates
# The type of runner that the job will run on
runs-on: ubuntu-latest

Expand Down Expand Up @@ -112,24 +112,34 @@ jobs:
working-directory: arm-templates
run: |
rm -rf ./templates/
mkdir -p templates/iotedge-lorawan-starterkit
mkdir -p templates/azure/iotedge-lorawan-starterkit
touch ./templates/.gitkeep
cp -r ../IoT-Hub-Portal/templates/* ./templates/
cp -r ../iotedge-lorawan-starterkit/TemplateBicep/* ./templates/iotedge-lorawan-starterkit/
sed -r -i 's/..\/iotedge-lorawan-starterkit\/TemplateBicep\/main.bicep/.\/iotedge-lorawan-starterkit\/main.bicep/g' ./templates/portal_with_lorawan_and_starter_kit.bicep
cp -r ../iotedge-lorawan-starterkit/TemplateBicep/* ./templates/azure/iotedge-lorawan-starterkit/
sed -r -i 's/..\/iotedge-lorawan-starterkit\/TemplateBicep\/main.bicep/.\/iotedge-lorawan-starterkit\/main.bicep/g' ./templates/azure/portal_with_lorawan_and_starter_kit.bicep
- name: Update IoTHub Portal docker image tag in app_service.bicep
working-directory: arm-templates/templates
working-directory: arm-templates/templates/azure
run: sed -i 's/ghcr.io\/cgi-fr\/iothub-portal:latest/ghcr.io\/cgi-fr\/iothub-portal:${{ fromJSON(steps.version.outputs.json).labels['org.opencontainers.image.version'] }}/g' app_service.bicep

- name: Update IoTHub Portal docker image tag in awsdeploy.yml
working-directory: arm-templates/templates/aws
run: sed -i 's/\${AWS::AccountId}.dkr.ecr.\${AWS::Region}.amazonaws.com\/iot-hub-portal:latest/578920151383.dkr.ecr.eu-west-1.amazonaws.com\/iot-hub-portal:${{ fromJSON(steps.version.outputs.json).labels['org.opencontainers.image.version'] }}/g' awsdeploy.yml

- name: Generate ARM file
working-directory: arm-templates/templates
working-directory: arm-templates/templates/azure
run: az bicep build --file azuredeploy.bicep --outfile azuredeploy.json

- name: Upload templates to release assets
- name: Upload azure templates to release assets
uses: AButler/upload-release-assets@v2.0
with:
files: 'arm-templates/templates/azure/*.json'
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Upload aws templates to release assets
uses: AButler/upload-release-assets@v2.0
with:
files: 'arm-templates/templates/*.json'
files: 'arm-templates/templates/aws/*.yml'
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Create PR for template updates
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ local.settings.json
*.user
*.userosscache
*.sln.docstates
user-secrets.json

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
Expand Down
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/src/AzureIoTHub.Portal/Server/bin/Debug/net6.0/AzureIoTHub.Portal.Server.dll",
"program": "${workspaceFolder}/src/AzureIoTHub.Portal.Server/bin/Debug/net7.0/AzureIoTHub.Portal.Server.dll",
"args": [],
"cwd": "${workspaceFolder}/src/AzureIoTHub.Portal/Server/",
"cwd": "${workspaceFolder}/src/AzureIoTHub.Portal.Server/",
"stopAtEntry": false,
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
"serverReadyAction": {
Expand Down
6 changes: 3 additions & 3 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "process",
"args": [
"build",
"${workspaceFolder}/src/AzureIoTHub.Portal/Server/AzureIoTHub.Portal.Server.csproj",
"${workspaceFolder}/src/AzureIoTHub.Portal.Server/AzureIoTHub.Portal.Server.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
Expand All @@ -19,7 +19,7 @@
"type": "process",
"args": [
"publish",
"${workspaceFolder}/src/AzureIoTHub.Portal/Server/AzureIoTHub.Portal.Server.csproj",
"${workspaceFolder}/src/AzureIoTHub.Portal.Server/AzureIoTHub.Portal.Server.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
Expand All @@ -33,7 +33,7 @@
"watch",
"run",
"--project",
"${workspaceFolder}/src/AzureIoTHub.Portal/Server/AzureIoTHub.Portal.Server.csproj"
"${workspaceFolder}/src/AzureIoTHub.Portal.Server/AzureIoTHub.Portal.Server.csproj"
],
"problemMatcher": "$msCompile"
}
Expand Down
1 change: 1 addition & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFramework>net6.0</TargetFramework>
<NoWarn>1591</NoWarn>
<RestoreFallbackFolders>clear</RestoreFallbackFolders>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 0 additions & 2 deletions templates/aws/awsdeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,6 @@ Resources:
Fn::Sub: "${openIdScopeName}"
- Name: CloudProvider
Value: AWS
- Name: PortalName
Value: IoT Portal DEMO - AWS
ImageIdentifier:
Fn::Sub: "${AWS::AccountId}.dkr.ecr.${AWS::Region}.amazonaws.com/iot-hub-portal:latest"
ImageRepositoryType: ECR
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit b3c6469

Please sign in to comment.