fix docker build and lint github workflows for dlt-connector

This commit is contained in:
einhornimmond 2025-10-22 09:28:19 +02:00
parent ed94bb7ea0
commit 617b1d6ad5
7 changed files with 149 additions and 26 deletions

View File

@ -25,7 +25,6 @@ jobs:
run: |
cd ./config-schema
biome ci .
echo $?
echo "success=$([ $? -eq 0 ] && echo true || echo false)" >> $GITHUB_OUTPUT
- name: Lint - Shared
id: shared
@ -57,6 +56,12 @@ jobs:
cd ./dht-node
biome ci .
echo "success=$([ $? -eq 0 ] && echo true || echo false)" >> $GITHUB_OUTPUT
- name: Lint - DLT Connector
id: dlt-connector
run: |
cd ./dlt-connector
biome ci .
echo "success=$([ $? -eq 0 ] && echo true || echo false)" >> $GITHUB_OUTPUT
- name: Lint - Federation
id: federation
run: |
@ -112,6 +117,14 @@ jobs:
- name: Check result from previous step
run: if [ "${{ needs.lint.outputs.dht-node }}" != "true" ]; then exit 1; fi
lint_dlt_connector:
name: Lint - DLT Connector
needs: lint
runs-on: ubuntu-latest
steps:
- name: Check result from previous step
run: if [ "${{ needs.lint.outputs.dlt-connector }}" != "true" ]; then exit 1; fi
lint_federation:
name: Lint - Federation
needs: lint

View File

@ -30,27 +30,7 @@ jobs:
uses: actions/checkout@v3
- name: Build 'test' image
run: |
docker build --target test -t "gradido/dlt-connector:test" -f dlt-connector/Dockerfile .
docker save "gradido/dlt-connector:test" > /tmp/dlt-connector.tar
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: docker-dlt-connector-test
path: /tmp/dlt-connector.tar
lint:
name: Lint - DLT Connector
if: needs.files-changed.outputs.dlt_connector == 'true'
needs: files-changed
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Lint
run: cd dlt-connector && yarn && yarn run lint
run: docker build --target test -t "gradido/dlt-connector:test" -f dlt-connector/Dockerfile .
unit_test:
name: Unit Tests - DLT Connector
@ -60,6 +40,14 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: install bun
uses: oven-sh/setup-bun@v2
with:
bun-version-file: '.bun-version'
- name: DLT-Connector | Unit tests
run: cd dlt-connector && yarn && yarn test
- name: install dependencies
run: cd dlt-connector && bun install --frozen-lockfile
- name: typecheck && unit test
run: cd dlt-connector && bun typecheck && bun test

119
dlt-connector/Dockerfile Normal file
View File

@ -0,0 +1,119 @@
##################################################################################
# BASE ###########################################################################
##################################################################################
#FROM node:18.20.7-bookworm-slim as base
FROM oven/bun:1.3.0-slim as base
#FROM node:18.20.7-alpine3.21 as base
# change to alpine after sodium-native ship with native alpine build
# ENVs (available in production aswell, can be overwritten by commandline or env file)
## DOCKER_WORKDIR would be a classical ARG, but that is not multi layer persistent - shame
ENV DOCKER_WORKDIR="/app"
## We Cannot do `$(date -u +'%Y-%m-%dT%H:%M:%SZ')` here so we use unix timestamp=0
ENV BUILD_DATE="1970-01-01T00:00:00.00Z"
## We cannot do $(npm run version).${BUILD_NUMBER} here so we default to 0.0.0.0
ENV BUILD_VERSION="0.0.0.0"
## We cannot do `$(git rev-parse --short HEAD)` here so we default to 0000000
ENV BUILD_COMMIT="0000000"
## SET NODE_ENV
ENV NODE_ENV=production
## App relevant Envs
ENV PORT="4000"
## Timezone
ENV TZ=UTC
# Labels
LABEL org.label-schema.build-date="${BUILD_DATE}"
LABEL org.label-schema.name="gradido:dlt-connector"
LABEL org.label-schema.description="Gradido DLT Connector"
LABEL org.label-schema.usage="https://github.com/gradido/gradido/blob/master/README.md"
LABEL org.label-schema.url="https://gradido.net"
LABEL org.label-schema.vcs-url="https://github.com/gradido/gradido/tree/master/dlt-connector"
LABEL org.label-schema.vcs-ref="${BUILD_COMMIT}"
LABEL org.label-schema.vendor="Gradido Community"
LABEL org.label-schema.version="${BUILD_VERSION}"
LABEL org.label-schema.schema-version="1.0"
LABEL maintainer="support@gradido.net"
# Install Additional Software
## install: git
#RUN apk --no-cache add git
# Settings
## Expose Container Port
EXPOSE ${PORT}
## Workdir
RUN mkdir -p ${DOCKER_WORKDIR}
WORKDIR ${DOCKER_WORKDIR}
##################################################################################
# BUN ############################################################################
##################################################################################
#FROM base as bun-base
#RUN apt update && apt install -y --no-install-recommends ca-certificates curl bash unzip
#COPY .bun-version .bun-version
#RUN apk update && apk add --no-cache curl tar bash
#RUN BUN_VERSION=$(cat .bun-version) && \
# curl -fsSL https://bun.sh/install | bash -s "bun-v${BUN_VERSION}"
# Add bun's global bin directory to PATH
#ENV PATH="/root/.bun/bin:${PATH}"
##################################################################################
# Development ####################################################################
##################################################################################
FROM base AS development
# Run command
CMD /bin/sh -c "cd dlt-connector && bun install --no-cache --frozen-lockfile && bun dev"
##################################################################################
# Basic Image with bun setup and project and source code #########################
##################################################################################
FROM base as base-src
COPY --chown=app:app ./dlt-connector ./dlt-connector
##################################################################################
# Build ##########################################################################
##################################################################################
FROM base-src as build
RUN cd dlt-connector && bun install --no-cache --frozen-lockfile
RUN cd dlt-connector && bun typecheck && bun run build
##################################################################################
# TEST ###########################################################################
##################################################################################
FROM build as test
# Run command
CMD /bin/sh -c "cd dlt-connector && bun test"
##################################################################################
# install only node modules needed for running bundle ############################
##################################################################################
FROM base-src as production-node-modules
COPY ./scripts ./scripts
# add node_modules from production_node_modules
RUN cd dlt-connector && bun install --production --frozen-lockfile --no-cache \
&& rm -rf /tmp/* ~/.cache node_modules/.cache \
&& ../scripts/clean-prebuilds.sh
##################################################################################
# PRODUCTION (Does contain only "binary"- and static-files to reduce image size) #
##################################################################################
FROM base as production
# Copy "binary"-files from build image
COPY --chown=app:app --from=build ${DOCKER_WORKDIR}/dlt-connector/build/index.js ./index.js
# add node_modules from production_node_modules
COPY --chown=app:app --from=production-node-modules ${DOCKER_WORKDIR}/dlt-connector/node_modules ./node_modules
COPY ./dlt-connector/.env .
COPY ./dlt-connector/log4js-config.json .
# Run command
CMD ["bun", "index.js"]

View File

@ -12,6 +12,7 @@
"@sinclair/typebox": "^0.34.33",
"@sinclair/typemap": "^0.10.1",
"@types/bun": "^1.2.17",
"@types/uuid": "^8.3.4",
"dotenv": "^10.0.0",
"elysia": "1.3.8",
"graphql-request": "^7.2.0",
@ -271,6 +272,8 @@
"@types/stack-utils": ["@types/stack-utils@2.0.3", "", {}, "sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw=="],
"@types/uuid": ["@types/uuid@8.3.4", "", {}, "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw=="],
"@types/yargs": ["@types/yargs@17.0.33", "", { "dependencies": { "@types/yargs-parser": "*" } }, "sha512-WpxBCKWPLr4xSsHgz511rFJAM+wS28w2zEO1QDNY5zM/S8ok70NNfztH0xwhqKyaK0OHCbN98LDAZuy1ctxDkA=="],
"@types/yargs-parser": ["@types/yargs-parser@21.0.3", "", {}, "sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ=="],

View File

@ -25,6 +25,7 @@
"@sinclair/typebox": "^0.34.33",
"@sinclair/typemap": "^0.10.1",
"@types/bun": "^1.2.17",
"@types/uuid": "^8.3.4",
"dotenv": "^10.0.0",
"elysia": "1.3.8",
"graphql-request": "^7.2.0",

View File

@ -104,7 +104,7 @@ services:
- node_modules_dlt_connector:/app/node_modules
- turbo_cache:/tmp/turbo
# bind the local folder to the docker to allow live reload
- ./dlt-connector:/app
- .:/app
########################################################
# FEDERATION ###########################################

View File

@ -172,7 +172,6 @@ services:
- BUILD_VERSION
- BUILD_COMMIT
- NODE_ENV="production"
- DB_HOST=mariadb
# Application only envs
volumes:
# <host_machine_directory>:<container_directory> mirror bidirectional path in local context with path in Docker container