From 45350e7a2b383aac1f4b4843c2ac6d422a2e083a Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Tue, 13 Jan 2026 19:15:44 +0000 Subject: [PATCH] Add Dockerfile and build automation --- .dockerignore | 138 +++++++++++++++++++++++++++++++ .gitea/workflows/build-push.yaml | 39 +++++++++ Dockerfile | 27 ++++++ package-lock.json | 8 +- package.json | 5 +- 5 files changed, 212 insertions(+), 5 deletions(-) create mode 100644 .dockerignore create mode 100644 .gitea/workflows/build-push.yaml create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..2309cc8 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,138 @@ +# ---> Node +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp +.cache + +# vitepress build output +**/.vitepress/dist + +# vitepress cache directory +**/.vitepress/cache + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + diff --git a/.gitea/workflows/build-push.yaml b/.gitea/workflows/build-push.yaml new file mode 100644 index 0000000..aeaa5ee --- /dev/null +++ b/.gitea/workflows/build-push.yaml @@ -0,0 +1,39 @@ +name: Build and Push container image +run-name: ${{ gitea.actor }} is building and pushing + +on: + create: + tags: "*" + +env: + GITEA_DOMAIN: git.fjla.uk + GITEA_REGISTRY_USER: owlbot + RESULT_IMAGE_NAME: owlboard/data-ingress-pis + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + container: + image: catthehacker/ubuntu:act-latest + options: --privileged + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to Gitea Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.GITEA_DOMAIN }} + username: ${{ env.GITEA_REGISTRY_USER }} + password: ${{ secrets.REGISTRY_TOKEN }} + - name: Build and Push image + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + push: true + tags: | + ${{ env.GITEA_DOMAIN }}/${{ env.RESULT_IMAGE_NAME }}:${{ gitea.ref_name }} + ${{ env.GITEA_DOMAIN }}/${{ env.RESULT_IMAGE_NAME }}:latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..29be560 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM node:25-slim AS builder + +WORKDIR /app + +COPY .npmrc ./ +COPY package*.json ./ +RUN npm ci + +COPY . . + +RUN npm run build + + +FROM node:25-slim AS runner + +ENV NODE_ENV=production + +WORKDIR /app + +COPY package*.json ./ +RUN npm ci --omit=dev + +COPY --from=builder /app/dist ./dist + +USER node + +CMD ["node", "dist/index.js"] \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index a799d87..509a77b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@aws-sdk/client-s3": "^3.964.0", "@aws-sdk/lib-storage": "^3.964.0", - "@owlboard/backend-data-contracts": "^0.1.0", + "@owlboard/backend-data-contracts": "^0.1.9", "mongodb": "^7.0.0", "nats": "^2.29.3", "readline": "^1.3.0", @@ -1395,9 +1395,9 @@ } }, "node_modules/@owlboard/backend-data-contracts": { - "version": "0.1.0", - "resolved": "https://git.fjla.uk/api/packages/OwlBoard/npm/%40owlboard%2Fbackend-data-contracts/-/0.1.0/backend-data-contracts-0.1.0.tgz", - "integrity": "sha512-6cJg7l7i8+iogU5nzvXct1+MQLmqgwcC3I7aS8MAHiDE3ymnLBhpaFKNfz6zkG39KQbA0XGhtoQD1dlKZzLXfw==", + "version": "0.1.9", + "resolved": "https://git.fjla.uk/api/packages/OwlBoard/npm/%40owlboard%2Fbackend-data-contracts/-/0.1.9/backend-data-contracts-0.1.9.tgz", + "integrity": "sha512-sKIogfclUKSwIvcPFQmJfpVMGLR1XbqMhyL1qNlKFWqWqATCrgKdboArwj5AfTjEC8hDUp8x0ffaRL+hQphXoQ==", "license": "ISC" }, "node_modules/@smithy/abort-controller": { diff --git a/package.json b/package.json index 50d56b4..f383a3e 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,9 @@ "main": "index.js", "type": "module", "scripts": { + "prebuild": "rm -rf ./dist", + "build": "tsc", + "start": "node dist/index.js", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { @@ -21,7 +24,7 @@ "dependencies": { "@aws-sdk/client-s3": "^3.964.0", "@aws-sdk/lib-storage": "^3.964.0", - "@owlboard/backend-data-contracts": "^0.1.0", + "@owlboard/backend-data-contracts": "^0.1.9", "mongodb": "^7.0.0", "nats": "^2.29.3", "readline": "^1.3.0",