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
|
# Use the official Node.js image as the base image
|
||||||
FROM node:14
|
FROM node:14
|
||||||
|
|
||||||
# Set the working directory
|
# Create app directory
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
# Copy package.json and package-lock.json
|
# Install app dependencies
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
|
||||||
# Install dependencies
|
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|
||||||
# Copy the rest of the application code
|
# Copy app source code
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
# Run the build script to update the version number
|
||||||
|
RUN node build.js
|
||||||
|
|
||||||
# Expose the port the app runs on
|
# Expose the port the app runs on
|
||||||
EXPOSE 3044
|
EXPOSE 3044
|
||||||
|
|
||||||
# Set the DEBUG environment variable
|
# Set the DEBUG environment variable
|
||||||
ENV DEBUG=app
|
ENV DEBUG=app
|
||||||
|
|
||||||
# Command to run the application
|
# Command to run the app
|
||||||
CMD ["node", "server.js"]
|
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:
|
services:
|
||||||
org-todo-pwa:
|
org-todo-pwa:
|
||||||
image: org-todo-pwa
|
|
||||||
build: .
|
build: .
|
||||||
ports:
|
ports:
|
||||||
- "3044:3044"
|
- "3044:3044"
|
||||||
@@ -26,5 +25,4 @@ services:
|
|||||||
- "traefik.http.routers.plan.tls=true"
|
- "traefik.http.routers.plan.tls=true"
|
||||||
- "traefik.http.routers.plan.tls.certresolver=myhttpchallenge"
|
- "traefik.http.routers.plan.tls.certresolver=myhttpchallenge"
|
||||||
- "traefik.http.routers.plan.rule=Host(`todo.casablanca.wahlberg.se`)"
|
- "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",
|
"version": "1.0.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "app.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
|
"build": "node build.js"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"basic-auth": "^2.0.1",
|
"basic-auth": "^2.0.1",
|
||||||
"body-parser": "^1.20.3",
|
"body-parser": "^1.19.0",
|
||||||
"connect-sqlite3": "^0.9.15",
|
"connect-sqlite3": "^0.9.11",
|
||||||
"cookie-parser": "^1.4.7",
|
"cookie-parser": "^1.4.5",
|
||||||
"debug": "^4.4.0",
|
"debug": "^4.3.1",
|
||||||
"dotenv": "^16.4.7",
|
"dotenv": "^8.2.0",
|
||||||
"express": "^4.21.2",
|
"express": "^4.17.1",
|
||||||
"express-session": "^1.18.1",
|
"express-session": "^1.17.1",
|
||||||
"fs": "^0.0.1-security",
|
"fs": "^0.0.1-security",
|
||||||
"winston": "^3.17.0"
|
"winston": "^3.17.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,17 @@ h1 {
|
|||||||
|
|
||||||
#responseMessage {
|
#responseMessage {
|
||||||
text-align: center;
|
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 {
|
.menu {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|||||||
@@ -61,6 +61,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<button class="btn waves-effect waves-light" type="submit">Spara uppgift</button>
|
<button class="btn waves-effect waves-light" type="submit">Spara uppgift</button>
|
||||||
<p id="responseMessage"></p>
|
<p id="responseMessage"></p>
|
||||||
|
<p id="version"><!-- VERSION_PLACEHOLDER --></p>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user