diff --git a/Dockerfile b/Dockerfile index 4609219..8ee843a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,24 @@ # Use the official Node.js image as the base image FROM node:14 -# Set the working directory +# Create app directory WORKDIR /usr/src/app -# Copy package.json and package-lock.json +# Install app dependencies COPY package*.json ./ - -# Install dependencies RUN npm install -# Copy the rest of the application code +# Copy app source code COPY . . +# Run the build script to update the version number +RUN node build.js + # Expose the port the app runs on EXPOSE 3044 # Set the DEBUG environment variable ENV DEBUG=app -# Command to run the application +# Command to run the app CMD ["node", "server.js"] \ No newline at end of file diff --git a/build.js b/build.js new file mode 100644 index 0000000..b822637 --- /dev/null +++ b/build.js @@ -0,0 +1,17 @@ +const fs = require('fs'); +const path = require('path'); + +// Generate version number with timestamp +const version = new Date().toISOString().replace(/[-:.]/g, '').slice(0, 15); + +// Read the HTML file +const indexPath = path.join(__dirname, 'public', 'index.html'); +let indexHtml = fs.readFileSync(indexPath, 'utf8'); + +// Replace the version placeholder with the generated version number +indexHtml = indexHtml.replace(//g, `Version: ${version}`); + +// Write the updated HTML back to the file +fs.writeFileSync(indexPath, indexHtml); + +console.log(`Version number updated to: ${version}`); \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 829c7f5..0f16747 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,6 @@ version: '3.8' services: org-todo-pwa: - image: org-todo-pwa build: . ports: - "3044:3044" @@ -26,5 +25,4 @@ services: - "traefik.http.routers.plan.tls=true" - "traefik.http.routers.plan.tls.certresolver=myhttpchallenge" - "traefik.http.routers.plan.rule=Host(`todo.casablanca.wahlberg.se`)" - - "traefik.http.routers.plan.entrypoints=websecure" - \ No newline at end of file + - "traefik.http.routers.plan.entrypoints=websecure" \ No newline at end of file diff --git a/package.json b/package.json index a3f6159..cadd8d7 100644 --- a/package.json +++ b/package.json @@ -1,24 +1,25 @@ { - "name": "pwa", + "name": "org-todo-pwa", "version": "1.0.0", "description": "", - "main": "app.js", + "main": "main.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"Error: no test specified\" && exit 1", + "build": "node build.js" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "basic-auth": "^2.0.1", - "body-parser": "^1.20.3", - "connect-sqlite3": "^0.9.15", - "cookie-parser": "^1.4.7", - "debug": "^4.4.0", - "dotenv": "^16.4.7", - "express": "^4.21.2", - "express-session": "^1.18.1", + "body-parser": "^1.19.0", + "connect-sqlite3": "^0.9.11", + "cookie-parser": "^1.4.5", + "debug": "^4.3.1", + "dotenv": "^8.2.0", + "express": "^4.17.1", + "express-session": "^1.17.1", "fs": "^0.0.1-security", "winston": "^3.17.0" - } + } } diff --git a/public/css/style.css b/public/css/style.css index 7fd0bae..cf72209 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -16,7 +16,17 @@ h1 { #responseMessage { text-align: center; - color: green;} + color: green; +} + +/* Add styles for the version number */ +#version { + color: #888; /* Subtle gray color */ + font-size: 0.8em; /* Smaller font size */ + text-align: right; /* Align text to the right */ + margin: 0; /* Remove any default margin */ + padding: 0; /* Remove any default padding */ +} .menu { position: relative; diff --git a/public/index.html b/public/index.html index 4e99742..7b7508e 100644 --- a/public/index.html +++ b/public/index.html @@ -61,6 +61,7 @@

+