Skip to content

Commit

Permalink
deployment tweaks
Browse files Browse the repository at this point in the history
Signed-off-by: Clemens Vasters <clemens@vasters.com>
  • Loading branch information
clemensv committed Jan 23, 2025
1 parent d0e6d8c commit 20e0048
Show file tree
Hide file tree
Showing 6 changed files with 575 additions and 129 deletions.
16 changes: 13 additions & 3 deletions mode-s/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
FROM python:3.11-slim

LABEL org.opencontainers.image.source = "https://github.com/clemensv/real-time-sources/tree/main/mode_s"
LABEL org.opencontainers.image.title = "USGS Instantaneous Values Service bridge to Kafka endpoints"
LABEL org.opencontainers.image.description = "This container is a bridge between USGS feeds and Kafka endpoints. It fetches entries from feeds and forwards them to the configured Kafka endpoints."
LABEL org.opencontainers.image.title = "Mode-S Data Poller"
LABEL org.opencontainers.image.description = "This container polls ADS-B data from dump1090 and sends it to Kafka endpoints."
LABEL org.opencontainers.image.documentation = "https://github.com/clemensv/real-time-sources/blob/main/mode_s/CONTAINER.md"
LABEL org.opencontainers.image.license = "MIT"

Expand All @@ -17,8 +17,18 @@ COPY . /app
RUN pip install .

# Define environment variables (default values)
ENV DUMP1090_HOST="localhost"
ENV DUMP1090_PORT="30005"
ENV REF_LAT="0"
ENV REF_LON="0"
ENV STATIONID="station1"
ENV KAFKA_BOOTSTRAP_SERVERS=""
ENV KAFKA_TOPIC=""
ENV SASL_USERNAME=""
ENV SASL_PASSWORD=""
ENV CONNECTION_STRING=""
ENV POLLING_INTERVAL="60"
ENV LOG_LEVEL="INFO"

# Run the application
CMD ["python", "-m", "mode_s", "feed"]
CMD ["mode_s_kafka_bridge", "feed"]
299 changes: 202 additions & 97 deletions mode-s/azure-template.json
Original file line number Diff line number Diff line change
@@ -1,153 +1,258 @@
{
"parameters": {
"logAnalyticsWorkspaceId": {
"metadata": {
"description": "The Id of the Log Analytics workspace. In the portal, you find this under Settings -> Agents -> Windows/Linux Servers -> Agent Instructions."
},
"type": "string"
},
"imageName": {
"defaultValue": "ghcr.io/clemensv/real-time-sources-mode-s:latest",
"metadata": {
"description": "The name of the container image."
},
"type": "string"
},
"logAnalyticsWorkspaceKey": {
"metadata": {
"description": "The primary or secondary key of the Log Analytics workspace. In the portal, you find this under Settings -> Agents -> Windows/Linux Servers -> Agent Instructions."
},
"type": "securestring"
},
"connectionStringSecret": {
"metadata": {
"description": "The Microsoft Fabric Event Stream custom input endpoint or Azure Event Hubs connection string."
},
"type": "securestring"
},
"feedUrls": {
"defaultValue": "",
"metadata": {
"description": "Comma-separated list of feed URLs (RSS or OPML)"
},
"type": "string"
},
"appName": {
"defaultValue": "[if(empty(resourceGroup().name), 'mode-s', resourceGroup().name)]",
"maxLength": 64,
"metadata": {
"description": "The name of the container instance."
},
"type": "string"
}
},
"variables": {
"fileShareName": "fileshare",
"storageAccountName": "[concat(replace(parameters('appName'), '-', ''), 'stg')]"
"storageAccountName": "[concat(replace(parameters('appName'), '-', ''), 'stg')]",
"fileShareName": "fileshare"
},
"contentVersion": "1.0.0.0",
"resources": [
{
"sku": {
"name": "Standard_LRS"
},
"location": "[resourceGroup().location]",
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('storageAccountName')]",
"kind": "StorageV2",
"properties": {
"accessTier": "Hot"
},
"kind": "StorageV2",
"apiVersion": "2021-04-01",
"name": "[variables('storageAccountName')]",
"sku": {
"name": "Standard_LRS"
}
"type": "Microsoft.Storage/storageAccounts"
},
{
"location": "[resourceGroup().location]",
"type": "Microsoft.Storage/storageAccounts/fileServices",
"name": "[concat(variables('storageAccountName'), '/default/')]",
"properties": {
"protocolSettings": {
"smb": {
"enabled": true
}
}
},
"apiVersion": "2021-04-01",
"dependsOn": [
"[concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]"
],
"apiVersion": "2021-04-01",
"name": "[concat(variables('storageAccountName'), '/default/')]"
"type": "Microsoft.Storage/storageAccounts/fileServices"
},
{
"location": "[resourceGroup().location]",
"type": "Microsoft.Storage/storageAccounts/fileServices/shares",
"name": "[concat(variables('storageAccountName'), '/default/', variables('fileShareName'))]",
"properties": {
"shareQuota": 5120
},
"apiVersion": "2021-04-01",
"dependsOn": [
"[concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]"
],
"apiVersion": "2021-04-01",
"name": "[concat(variables('storageAccountName'), '/default/', variables('fileShareName'))]"
"type": "Microsoft.Storage/storageAccounts/fileServices/shares"
},
{
"name": "[parameters('appName')]",
"apiVersion": "2021-09-01",
"location": "[resourceGroup().location]",
"properties": {
"volumes": [
{
"azureFile": {
"storageAccountKey": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2019-06-01').keys[0].value]",
"shareName": "[variables('fileShareName')]",
"storageAccountName": "[variables('storageAccountName')]"
},
"name": "azurefilevolume"
}
],
"restartPolicy": "Always",
"osType": "Linux",
"diagnostics": {
"logAnalytics": {
"workspaceId": "[parameters('logAnalyticsWorkspaceId')]",
"workspaceKey": "[parameters('logAnalyticsWorkspaceKey')]"
}
},
"containers": [
{
"name": "[parameters('appName')]",
"properties": {
"image": "[parameters('imageName')]",
"resources": {
"requests": {
"memoryInGB": 1,
"cpu": 0.5
}
},
"volumeMounts": [
{
"name": "azurefilevolume",
"mountPath": "/mnt/fileshare"
"mountPath": "/mnt/fileshare",
"name": "azurefilevolume"
}
],
"image": "[parameters('imageName')]",
"environmentVariables": [
{
"name": "CONNECTION_STRING",
"secureValue": "[parameters('connectionStringSecret')]"
"value": "[parameters('dump1090Host')]",
"name": "DUMP1090_HOST"
},
{
"name": "LOG_LEVEL",
"value": "INFO"
"value": "[parameters('dump1090Port')]",
"name": "DUMP1090_PORT"
},
{
"name": "USGS_LAST_POLLED_FILE",
"value": "/mnt/fileshare/usgs_last_polled.json"
}
],
"resources": {
"requests": {
"memoryInGB": 1,
"cpu": 0.5
"value": "[parameters('refLat')]",
"name": "REF_LAT"
},
{
"value": "[parameters('refLon')]",
"name": "REF_LON"
},
{
"value": "[parameters('stationId')]",
"name": "STATIONID"
},
{
"secureValue": "[parameters('connectionStringSecret')]",
"name": "CONNECTION_STRING"
},
{
"value": "[parameters('kafkaBootstrapServers')]",
"name": "KAFKA_BOOTSTRAP_SERVERS"
},
{
"value": "[parameters('kafkaTopic')]",
"name": "KAFKA_TOPIC"
},
{
"value": "[parameters('saslUsername')]",
"name": "SASL_USERNAME"
},
{
"secureValue": "[parameters('saslPassword')]",
"name": "SASL_PASSWORD"
},
{
"value": "[parameters('pollingInterval')]",
"name": "POLLING_INTERVAL"
},
{
"value": "[parameters('logLevel')]",
"name": "LOG_LEVEL"
}
}
}
}
],
"restartPolicy": "Always",
"diagnostics": {
"logAnalytics": {
"workspaceKey": "[parameters('logAnalyticsWorkspaceKey')]",
"workspaceId": "[parameters('logAnalyticsWorkspaceId')]"
]
},
"name": "[parameters('appName')]"
}
},
"volumes": [
{
"name": "azurefilevolume",
"azureFile": {
"shareName": "[variables('fileShareName')]",
"storageAccountKey": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2019-06-01').keys[0].value]",
"storageAccountName": "[variables('storageAccountName')]"
}
}
],
"osType": "Linux"
]
},
"type": "Microsoft.ContainerInstance/containerGroups",
"apiVersion": "2021-09-01"
"name": "[parameters('appName')]"
}
],
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#"
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"dump1090Port": {
"metadata": {
"description": "TCP port dump1090 listens on."
},
"type": "string",
"defaultValue": "30005"
},
"stationId": {
"metadata": {
"description": "Station ID for event source attribution."
},
"type": "string",
"defaultValue": "station1"
},
"dump1090Host": {
"metadata": {
"description": "Hostname or IP address of dump1090."
},
"type": "string",
"defaultValue": "localhost"
},
"logAnalyticsWorkspaceId": {
"metadata": {
"description": "The Id of the Log Analytics workspace. In the portal, you find this under Settings -> Agents -> Windows/Linux Servers -> Agent Instructions."
},
"type": "string"
},
"saslPassword": {
"metadata": {
"description": "Password for SASL authentication."
},
"type": "securestring"
},
"connectionStringSecret": {
"metadata": {
"description": "The Microsoft Fabric Event Stream custom input endpoint or Azure Event Hubs connection string."
},
"type": "securestring"
},
"imageName": {
"metadata": {
"description": "The name of the container image."
},
"type": "string",
"defaultValue": "ghcr.io/clemensv/real-time-sources-mode-s:latest"
},
"refLat": {
"metadata": {
"description": "Latitude of the receiving antenna."
},
"type": "string",
"defaultValue": "0"
},
"refLon": {
"metadata": {
"description": "Longitude of the receiving antenna."
},
"type": "string",
"defaultValue": "0"
},
"saslUsername": {
"metadata": {
"description": "Username for SASL authentication."
},
"type": "string",
"defaultValue": ""
},
"logLevel": {
"metadata": {
"description": "Logging level."
},
"type": "string",
"defaultValue": "INFO"
},
"logAnalyticsWorkspaceKey": {
"metadata": {
"description": "The primary or secondary key of the Log Analytics workspace. In the portal, you find this under Settings -> Agents -> Windows/Linux Servers -> Agent Instructions."
},
"type": "securestring"
},
"appName": {
"metadata": {
"description": "The name of the container instance."
},
"maxLength": 64,
"type": "string",
"defaultValue": "[if(empty(resourceGroup().name), 'mode-s', resourceGroup().name)]"
},
"pollingInterval": {
"metadata": {
"description": "Polling interval in seconds."
},
"type": "string",
"defaultValue": "60"
},
"kafkaTopic": {
"metadata": {
"description": "Kafka topic to publish messages."
},
"type": "string",
"defaultValue": ""
},
"kafkaBootstrapServers": {
"metadata": {
"description": "Kafka bootstrap servers."
},
"type": "string",
"defaultValue": ""
}
}
}
Loading

0 comments on commit 20e0048

Please sign in to comment.