Skip to content

Commit

Permalink
Only Dockerfile.aas-server is affected: Merge branch 'development' of h…
Browse files Browse the repository at this point in the history
  • Loading branch information
fpethig committed Sep 9, 2024
2 parents b6eccd1 + acd45b6 commit ab988aa
Show file tree
Hide file tree
Showing 15 changed files with 1,877 additions and 1,135 deletions.
7 changes: 3 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@
"CONTENT_ROOT": "projects/aas-server/build",
"WEB_ROOT": "projects/aas-portal/dist",
"ASSETS": "projects/aas-server/src/assets",
// "USER_STORAGE": "mongodb://localhost:27017/aasportal-users",
// "USER_STORAGE": "mongodb://172.16.160.178:27017/aasportal-users",
// "TEMPLATE_STORAGE": "http://localhost:8080/templates",
// "AAS_INDEX": "mysql://172.16.160.171:3306",
// "USER_STORAGE": "mongodb://172.16.160.177:27017/aasportal-users",
// "TEMPLATE_STORAGE": "http://172.16.160.177:8080/templates",
// "AAS_INDEX": "mysql://172.16.160.177:3306",
"ENDPOINTS": "[\"file:///endpoints/samples?name=Samples\"]",
}
},
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Dockerfile to build server and client parts
FROM node:lts-alpine3.19 as build
FROM node:lts-alpine3.19 AS build
WORKDIR /usr/src/app
COPY . .
# RUN apk add g++ make py3-pip
RUN npm install
RUN node --no-warnings --loader ts-node/esm create-app-info.ts
RUN npm run build

FROM node:lts-alpine3.19 as aasportal
FROM node:lts-alpine3.19 AS aasportal
RUN apk upgrade --update-cache --available && apk add openssl && rm -rf /var/cache/apk/*
WORKDIR /usr/src/app
COPY package.json package.json
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.aas-portal
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Dockerfile to build server and client parts
FROM node:lts-alpine3.19 as build
FROM node:lts-alpine3.19 AS build
WORKDIR /usr/src/app
COPY . .
RUN npm install
RUN npm run aas-portal:build
FROM nginx:latest as aas-portal
FROM nginx:latest AS aas-portal
#possibility to check host & port availability of other containers via netcat
RUN apt-get update -y && apt-get install -y netcat-openbsd
COPY --from=build /usr/src/app/projects/aas-portal/dist/browser/ /usr/share/nginx/html/
Expand Down
6 changes: 5 additions & 1 deletion Dockerfile.aas-server
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RUN npm install
RUN node --no-warnings --loader ts-node/esm create-app-info.ts
RUN npm run aas-server:build

FROM node:lts-alpine3.19 as aas-server
FROM node:lts-alpine3.19 AS aas-server
RUN apk upgrade --update-cache --available && apk add openssl && rm -rf /var/cache/apk/*
WORKDIR /usr/src/app
COPY package.json package.json
Expand All @@ -22,6 +22,10 @@ ENV NODE_LOG=./log/debug.log
ENV NODE_SERVER_PORT=1337
ENV USER_STORAGE=mongodb://172.16.160.177:27017/aasportal-users
ENV AAS_INDEX=mysql://172.16.160.177:3306
<<<<<<< HEAD
=======
ENV TEMPLATE_STORAGE: http://172.16.160.177:8080/templates
>>>>>>> acd45b6be65e2f6471beebcdadbbf8a043b25821
ENV ENDPOINTS=["\"file:///endpoints/samples?name=Samples\""]
ENV NODE_ENV=production

Expand Down
20 changes: 19 additions & 1 deletion create-app-info.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { readFile, writeFile } from 'fs/promises';
import { readFile, writeFile, readdir } from 'fs/promises';
import path from 'path';
import { existsSync } from 'fs';
import { dirname, resolve, join } from 'path';
import { fileURLToPath } from 'url';
Expand Down Expand Up @@ -28,6 +29,7 @@ interface Library {
version: string;
description: string;
license: string;
licenseText: string;
homepage: string;
}

Expand All @@ -46,6 +48,7 @@ async function main(): Promise<void> {
appInfo.author = project.author;
appInfo.homepage = project.homepage;
appInfo.license = project.license;

appInfo.libraries = await readLibrariesAsync(project);

await write(file, appInfo);
Expand Down Expand Up @@ -73,6 +76,7 @@ async function readLibrariesAsync(project: Package): Promise<Library[]> {
version: pkg.version,
description: pkg.description,
license: pkg.license,
licenseText: await loadLicenseText(nodeModulesFolder, name),
homepage: pkg.homepage,
});
} catch (error) {
Expand All @@ -84,3 +88,17 @@ async function readLibrariesAsync(project: Package): Promise<Library[]> {

return libraries;
}

async function loadLicenseText(nodeModulesFolder: string, packageName: string): Promise<string> {
packageName = packageName.split('/')[0];
const folder = join(nodeModulesFolder, packageName);
for (const file of await readdir(folder, { withFileTypes: true, recursive: true })) {
if (file.isFile()) {
if (path.basename(file.name, path.extname(file.name)).toLowerCase() === 'license') {
return (await readFile(join(file.parentPath, file.name))).toString();
}
}
}

return '';
}
Loading

0 comments on commit ab988aa

Please sign in to comment.