Skip to content

Commit cfcc3a1

Browse files
Merge pull request #775 from Datasance/iofog/merge
Datasance repo merge
2 parents ccf098c + 9f75fe7 commit cfcc3a1

476 files changed

Lines changed: 60799 additions & 25381 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ node_modules
99
*.pid
1010
/src/data/providers/*
1111
!/src/data/providers/sqlite.js
12+
!/src/data/providers/mysql.js
13+
!/src/data/providers/postgres.js
1214
!/src/data/providers/database-*.js
1315
/src/config/*-config.json
1416
.DS_Store
1517
iofogcontroller-*.tgz
16-
iofog-iofogcontroller-*.tgz
18+
iofog-iofogcontroller-*.tgz
19+
.env
20+
src/iofog-controller.pid

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

.github/workflows/ci.yaml

Lines changed: 92 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,93 @@
11
name: CI
22
on:
3-
push:
3+
push:
44
branches:
5-
- develop
6-
- release*
5+
- main
76
tags: [v*]
87
paths-ignore:
98
- README.md
109
- CHANGELOG.md
1110
- LICENSE
1211
pull_request:
13-
# Sequence of patterns matched against refs/heads
14-
branches:
15-
- develop
16-
- release*
12+
# Sequence of patterns matched against refs/heads
13+
branches:
14+
- main
1715
paths-ignore:
1816
- README.md
1917
- CHANGELOG.md
2018
- LICENSE
21-
2219
env:
23-
project: 'focal-freedom-236620'
24-
image: 'controller'
20+
IMAGE_NAME: 'controller'
21+
2522

2623

2724
jobs:
2825
Build:
29-
runs-on: ubuntu-latest
26+
runs-on: ubuntu-22.04
3027
permissions:
31-
contents: 'read'
32-
id-token: 'write'
33-
packages: 'write'
28+
actions: write
29+
checks: write
30+
contents: write
31+
deployments: write
32+
id-token: write
33+
issues: write
34+
discussions: write
35+
packages: write
36+
pages: write
37+
pull-requests: write
38+
repository-projects: write
39+
security-events: write
40+
statuses: write
3441
name: Preflight
3542
steps:
36-
- uses: actions/checkout@v3
37-
- uses: actions/setup-node@v3
43+
- uses: actions/checkout@v4
44+
- uses: actions/setup-node@v4
3845
with:
39-
node-version: 18
40-
- run: npm ci
46+
node-version: 24
47+
- name: Replace values
48+
shell: bash
49+
env:
50+
PAT: ${{ secrets.GITHUB_TOKEN }}
51+
run: |
52+
sed -i.back "s|PAT|${GITHUB_TOKEN}|g" .npmrc
53+
- run: npm config set @eclipse-iofog:registry https://npm.pkg.github.com/
54+
- run: npm install --build-from-source --force
4155
- run: npm run standard
4256
- run: |
4357
npm i -g better-npm-audit
4458
npx better-npm-audit audit -p
4559
46-
Tests:
47-
needs: Build
48-
runs-on: ubuntu-latest
60+
Publish:
61+
needs: [Build]
62+
runs-on: ubuntu-22.04
4963
permissions:
50-
contents: 'read'
51-
id-token: 'write'
52-
packages: 'write'
53-
issues: read
64+
actions: write
5465
checks: write
66+
contents: write
67+
deployments: write
68+
id-token: write
69+
issues: write
70+
discussions: write
71+
packages: write
72+
pages: write
5573
pull-requests: write
56-
strategy:
57-
matrix:
58-
node: [ 16, 17, 16, 19 ]
59-
name: Node ${{ matrix.node }} Test
60-
steps:
61-
- uses: actions/checkout@v3
62-
- name: Setup Node ${{ matrix.node }} Test
63-
uses: actions/setup-node@v3
64-
with:
65-
node-version: ${{ matrix.node }}
66-
- name: Cache Node Modules
67-
uses: actions/cache@v3
68-
with:
69-
path: |
70-
node_modules
71-
key: ${{ runner.os }}-controller-node_modules-${{ hashFiles('package-lock.json') }}
72-
restore-keys: |
73-
${{ runner.os }}-controller-node_modules-
74-
- run: npm ci
75-
- run: npm run test -- junit
76-
- run: npm run postman_test
77-
- name: Publish Test Results
78-
uses: EnricoMi/publish-unit-test-result-action@v2
79-
if: always()
80-
with:
81-
files: |
82-
*-results.xml
83-
84-
Publish:
85-
needs: [Build, Tests]
86-
runs-on: ubuntu-latest
87-
permissions:
88-
contents: 'read'
89-
id-token: 'write'
90-
packages: 'write'
74+
repository-projects: write
75+
security-events: write
76+
statuses: write
9177
name: Publish Controller
9278
steps:
93-
- uses: actions/checkout@v3
94-
- uses: actions/setup-node@v3
79+
- uses: actions/checkout@v4
80+
- uses: actions/setup-node@v4
9581
with:
96-
node-version: 18
97-
- run: npm ci
82+
node-version: 24
83+
- name: Replace values
84+
shell: bash
85+
env:
86+
PAT: ${{ secrets.GITHUB_TOKEN }}
87+
run: |
88+
sed -i.back "s|PAT|${PAT}|g" .npmrc
89+
- run: npm config set @eclipse-iofog:registry https://npm.pkg.github.com/
90+
- run: npm install --build-from-source --force
9891

9992
- name: npm version
10093
id: package-version
@@ -112,47 +105,51 @@ jobs:
112105
113106
- name: npm pack with version from package version
114107
run: |
115-
npm --no-git-tag-version version ${{ steps.version.outputs.pkg_version }}
116108
npm pack
109+
npm publish --registry=https://npm.pkg.github.com/
110+
111+
- name: 'Get Previous tag'
112+
id: previoustag
113+
uses: "WyriHaximus/github-action-get-previous-tag@v1"
114+
with:
115+
fallback: 0.0.0
116+
- name: Set image tag
117+
shell: bash
118+
id: tags
119+
run: |
120+
if [[ ${{ github.ref_name }} =~ ^v.* ]] ; then
121+
VERSION=${{ github.ref_name }}
122+
echo "VERSION=${VERSION:1}" >> "${GITHUB_OUTPUT}"
123+
else
124+
VERSION=${{ steps.previoustag.outputs.tag }}
125+
echo "VERSION=${VERSION:1}-${{ github.run_number }}" >> "${GITHUB_OUTPUT}"
126+
fi
127+
128+
- name: Set up QEMU
129+
uses: docker/setup-qemu-action@v3
130+
- name: Set up Docker Buildx
131+
uses: docker/setup-buildx-action@v3
132+
with:
133+
version: v0.29.1
134+
117135

118136
- name: Login to Github Container Registry
119137
uses: docker/login-action@v2
120138
with:
121139
registry: "ghcr.io"
122140
username: ${{ github.actor }}
123-
password: ${{ github.token }}
124-
141+
password: ${{ secrets.GITHUB_TOKEN }}
142+
125143
- name: Build and Push to ghcr
126144
uses: docker/build-push-action@v3
127145
id: build_push_ghcr
128146
with:
129-
file: Dockerfile.dev
147+
file: Dockerfile
148+
context: .
149+
platforms: linux/amd64, linux/arm64
130150
push: true
151+
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=Controller
131152
tags: |
132-
ghcr.io/eclipse-iofog/controller:${{ steps.version.outputs.pkg_version }}
133-
ghcr.io/eclipse-iofog/controller:latest
134-
build-args: PKG_VERSION=${{ steps.version.outputs.pkg_version }}
135-
136-
- name: Build and Push to GCR
137-
id: build_push_gcr
138-
uses: RafikFarhad/push-to-gcr-github-action@v5-beta
139-
with:
140-
gcloud_service_key: ${{ secrets.GCLOUD_SERVICE_KEY }}
141-
registry: gcr.io
142-
project_id: ${{ env.project }}
143-
image_name: ${{ env.image }}
144-
image_tag: latest,${{ steps.version.outputs.pkg_version }}
145-
dockerfile: Dockerfile.dev
146-
build_args: PKG_VERSION=${{ steps.version.outputs.pkg_version }}
147-
148-
- run: ls
149-
150-
- name: Publish package to packagecloud
151-
if: ${{ steps.build_push_gcr.outcome }} == 'success'
152-
uses: danielmundi/upload-packagecloud@v1
153-
with:
154-
PACKAGE-NAME: iofog-iofogcontroller-${{ steps.version.outputs.pkg_version }}.tgz
155-
PACKAGECLOUD-USERNAME: iofog
156-
PACKAGECLOUD-REPO: iofog-controller-snapshots
157-
PACKAGECLOUD-DISTRIB: node
158-
PACKAGECLOUD-TOKEN: ${{ secrets.packagecloud_token }}
153+
ghcr.io/eclipse-iofog/${{ env.IMAGE_NAME }}:${{ steps.tags.outputs.VERSION }}
154+
ghcr.io/eclipse-iofog/${{ env.IMAGE_NAME }}:latest
155+
ghcr.io/eclipse-iofog/${{ env.IMAGE_NAME }}:main

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ node_modules
99
*.pid
1010
/src/data/providers/*
1111
!/src/data/providers/sqlite.js
12+
!/src/data/providers/mysql.js
13+
!/src/data/providers/postgres.js
1214
!/src/data/providers/database-*.js
1315
/src/config/*-config.json
1416
.DS_Store
1517
iofogcontroller-*.tgz
1618
diagnostic/
17-
iofog-iofogcontroller-*.tgz
19+
iofog-iofogcontroller-*.tgz
20+
.npmrc
21+
.env
22+
src/iofog-controller.pid

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
//npm.pkg.github.com/:_authToken=PAT
2+
@Eclipse-iofog:registry=https://npm.pkg.github.com/

.nsprc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
{
2-
"1091459": {
3-
"notes": ""
4-
},
5-
"1091725": {
2+
"1112030": {
63
"notes": ""
74
}
85
}

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
24

Dockerfile

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
FROM node:24-bookworm AS builder
2+
3+
ARG PKG_VERSION
4+
# ARG GITHUB_TOKEN
5+
6+
WORKDIR /tmp
7+
8+
RUN npm i -g npm
9+
10+
COPY package.json .
11+
12+
COPY . .
13+
14+
RUN npm i --build-from-source --force
15+
16+
RUN npm version $PKG_VERSION --allow-same-version --no-git-tag-version
17+
18+
RUN npm pack
19+
20+
21+
FROM registry.access.redhat.com/ubi9/nodejs-24-minimal:latest
22+
23+
USER root
24+
# Install dependencies for logging and development
25+
RUN microdnf install -y g++ make && microdnf clean all
26+
27+
# Install Python and pip
28+
RUN microdnf install -y python3 && \
29+
ln -sf python3 /usr/bin/python && \
30+
python3 -m ensurepip && \
31+
pip3 install --no-cache --upgrade pip setuptools && \
32+
microdnf install shadow-utils && \
33+
microdnf clean all
34+
RUN microdnf install -y tzdata && microdnf clean all
35+
RUN microdnf -y remove microdnf
36+
RUN useradd --uid 10000 --create-home runner
37+
RUN mkdir -p /var/log/iofog-controller && \
38+
chown runner:runner /var/log/iofog-controller && \
39+
chmod 755 /var/log/iofog-controller
40+
USER 10000
41+
WORKDIR /home/runner
42+
43+
ENV NPM_CONFIG_PREFIX=/home/runner/.npm-global
44+
ENV NPM_CONFIG_CACHE=/home/runner/.npm
45+
ENV PATH=$PATH:/home/runner/.npm-global/bin
46+
47+
COPY --from=builder /tmp/eclipse-iofog-iofogcontroller-*.tgz /home/runner/iofog-controller.tgz
48+
49+
ENV PID_BASE=/home/runner
50+
51+
RUN npm i -g /home/runner/iofog-controller.tgz && \
52+
rm -rf /home/runner/iofog-controller.tgz && \
53+
iofog-controller config dev-mode --on
54+
55+
RUN rm -rf /home/runner/.npm-global/lib/node_modules/@eclipse-iofog/iofogcontroller/src/data/sqlite_files/*
56+
57+
COPY LICENSE /licenses/LICENSE
58+
LABEL org.opencontainers.image.description=controller
59+
LABEL org.opencontainers.image.source=https://github.com/eclipse-iofog/Controller
60+
LABEL org.opencontainers.image.licenses=EPL2.0
61+
CMD [ "node", "/home/runner/.npm-global/lib/node_modules/@eclipse-iofog/iofogcontroller/src/server.js" ]

0 commit comments

Comments
 (0)