assets
This commit is contained in:
@@ -10,9 +10,7 @@ COPY src ./src
|
|||||||
|
|
||||||
RUN npm run build && npm prune --omit=dev
|
RUN npm run build && npm prune --omit=dev
|
||||||
|
|
||||||
# app/public/index.html has content for video preview
|
COPY assets ./assets
|
||||||
# TODO move all static files (html, mappers) to a separate folder "assets"
|
|
||||||
COPY public ./public
|
|
||||||
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
CMD ["node", "dist/index.js"]
|
CMD ["node", "dist/index.js"]
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import { dirname, join } from 'node:path'
|
||||||
|
import { fileURLToPath } from 'node:url'
|
||||||
|
|
||||||
import { postCloudIngest } from '../cloud-ingest.js'
|
import { postCloudIngest } from '../cloud-ingest.js'
|
||||||
import { log } from '../helpers/log.js'
|
import { log } from '../helpers/log.js'
|
||||||
import { createMetricMapper, type MappedMetric } from '../mapping.js'
|
import { createMetricMapper, type MappedMetric } from '../mapping.js'
|
||||||
@@ -5,8 +8,13 @@ import type { TopicHandler } from '../types.js'
|
|||||||
|
|
||||||
const REGISTER_COUNT = 125
|
const REGISTER_COUNT = 125
|
||||||
|
|
||||||
|
const defaultMappingFile = join(
|
||||||
|
dirname(fileURLToPath(import.meta.url)),
|
||||||
|
'../../assets/edge5-modbus.json',
|
||||||
|
)
|
||||||
|
|
||||||
const mapper = createMetricMapper({
|
const mapper = createMetricMapper({
|
||||||
filePath: process.env.EDGE5_MODBUS_V2_MAPPING_FILE as string,
|
filePath: process.env.EDGE5_MODBUS_V2_MAPPING_FILE ?? defaultMappingFile,
|
||||||
})
|
})
|
||||||
|
|
||||||
function parseValues(payload: Buffer): number[] {
|
function parseValues(payload: Buffer): number[] {
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import { fileURLToPath } from 'node:url'
|
|||||||
import { log } from '../helpers/log.js'
|
import { log } from '../helpers/log.js'
|
||||||
|
|
||||||
const httpPort = Number(process.env.HTTP_PORT)
|
const httpPort = Number(process.env.HTTP_PORT)
|
||||||
const publicDir = join(dirname(fileURLToPath(import.meta.url)), '../../public')
|
const assetsDir = join(dirname(fileURLToPath(import.meta.url)), '../../assets')
|
||||||
const indexPath = join(publicDir, 'index.html')
|
const indexPath = join(assetsDir, 'index.html')
|
||||||
|
|
||||||
createServer(async (req, res) => {
|
createServer(async (req, res) => {
|
||||||
const path = req.url?.split('?')[0]
|
const path = req.url?.split('?')[0]
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export type MetricMapper = {
|
|||||||
|
|
||||||
type MetricMapperOptions = {
|
type MetricMapperOptions = {
|
||||||
// filePath contract:
|
// filePath contract:
|
||||||
// - built-in mappings are passed as URL via new URL('../mappings/*.json', import.meta.url);
|
// - built-in mappings live in app/assets/*.json (resolved relative to dist/ at runtime);
|
||||||
// - env overrides are expected as absolute paths inside the runtime container.
|
// - env overrides are expected as absolute paths inside the runtime container.
|
||||||
filePath: string | URL
|
filePath: string | URL
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ services:
|
|||||||
CLOUD_INGEST_URL: ${CLOUD_INGEST_URL}
|
CLOUD_INGEST_URL: ${CLOUD_INGEST_URL}
|
||||||
CLOUD_INGEST_API_KEY: ${CLOUD_INGEST_API_KEY}
|
CLOUD_INGEST_API_KEY: ${CLOUD_INGEST_API_KEY}
|
||||||
DEMO_CLOUD_INGEST_URL: ${DEMO_CLOUD_INGEST_URL}
|
DEMO_CLOUD_INGEST_URL: ${DEMO_CLOUD_INGEST_URL}
|
||||||
EDGE5_MODBUS_V2_MAPPING_FILE: ${EDGE5_MODBUS_V2_MAPPING_FILE:-/app/src/mappings/edge5-modbus.json}
|
EDGE5_MODBUS_V2_MAPPING_FILE: ${EDGE5_MODBUS_V2_MAPPING_FILE:-/app/assets/edge5-modbus.json}
|
||||||
networks:
|
networks:
|
||||||
- default
|
- default
|
||||||
- proxy
|
- proxy
|
||||||
|
|||||||
Reference in New Issue
Block a user