From ee4af9589d80923bb3f5cc81962114dd6368d534 Mon Sep 17 00:00:00 2001 From: danthe42 Date: Thu, 6 Nov 2025 18:04:28 +0100 Subject: [PATCH] xxxx --- .gitea/workflows/demo.yaml | 3 --- Dockerfile | 36 ++++++++++++++++++++++++++++++++++++ app.js | 23 +++++++++++++++++++++++ package-lock.json | 13 +++++++++++++ package.json | 11 +++++++++++ 5 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 Dockerfile create mode 100644 app.js create mode 100644 package-lock.json create mode 100644 package.json diff --git a/.gitea/workflows/demo.yaml b/.gitea/workflows/demo.yaml index f73dc00..c1e54fb 100644 --- a/.gitea/workflows/demo.yaml +++ b/.gitea/workflows/demo.yaml @@ -17,9 +17,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 with: - registry: gitea.goroid.io - username: danthe - password: Secret666 version: "lab:latest" driver: cloud endpoint: "danthe/default" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..daa4092 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,36 @@ +# syntax=docker/dockerfile:1 + +# Comments are provided throughout this file to help you get started. +# If you need more help, visit the Dockerfile reference guide at +# https://docs.docker.com/engine/reference/builder/ + +ARG NODE_VERSION=21.6.2 + +FROM node:${NODE_VERSION}-alpine + +# Use production node environment by default. +ENV NODE_ENV production + + +WORKDIR /usr/src/app + +# Download dependencies as a separate step to take advantage of Docker's caching. +# Leverage a cache mount to /root/.npm to speed up subsequent builds. +# Leverage a bind mounts to package.json and package-lock.json to avoid having to copy them into +# into this layer. +RUN --mount=type=bind,source=package.json,target=package.json \ + --mount=type=bind,source=package-lock.json,target=package-lock.json \ + --mount=type=cache,target=/root/.npm \ + npm ci --omit=dev + +# Run the application as a non-root user. +USER node + +# Copy the rest of the source files into the image. +COPY . . + +# Expose the port that the application listens on. +EXPOSE 8080 + +# Run the application. +CMD node app.js diff --git a/app.js b/app.js new file mode 100644 index 0000000..2f0dab0 --- /dev/null +++ b/app.js @@ -0,0 +1,23 @@ +const http = require('http'); + +const server = http.createServer((req, res) => { + res.writeHead(200, {'Content-Type': 'text/plain'}); + res.write(` + ## . + ## ## ## == + ## ## ## ## ## === +/""""""""""""""""\\___/ === +{ / ===- +\\______ O __/ + \\ \\ __/ + \\____\\_______/ + + +Hello from Docker! +`); + res.end(); +}); + +server.listen(8080, () => { + console.log('Server started!'); +}); diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..74255df --- /dev/null +++ b/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "helloworld-node-demo", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "helloworld-node-demo", + "version": "1.0.0", + "license": "ISC" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..1b8b881 --- /dev/null +++ b/package.json @@ -0,0 +1,11 @@ +{ + "name": "helloworld-node-demo", + "version": "1.0.0", + "description": "Hello World for Docker Init", + "main": "app.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC" +}