Update Dockerfile, docker-compose, and package.json; add versioning script and styles for version display
Fix #21
This commit is contained in:
13
Dockerfile
13
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"]
|
||||
17
build.js
Normal file
17
build.js
Normal file
@@ -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(/<!-- VERSION_PLACEHOLDER -->/g, `Version: ${version}`);
|
||||
|
||||
// Write the updated HTML back to the file
|
||||
fs.writeFileSync(indexPath, indexHtml);
|
||||
|
||||
console.log(`Version number updated to: ${version}`);
|
||||
@@ -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"
|
||||
|
||||
- "traefik.http.routers.plan.entrypoints=websecure"
|
||||
23
package.json
23
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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
</div>
|
||||
<button class="btn waves-effect waves-light" type="submit">Spara uppgift</button>
|
||||
<p id="responseMessage"></p>
|
||||
<p id="version"><!-- VERSION_PLACEHOLDER --></p>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user