Browse Source

Merge pull request #307 from dockersamples/update-versions

Update versions
Michael Irwin 1 year ago
parent
commit
cdfd5e0b43
7 changed files with 290 additions and 433 deletions
  1. 7 9
      result/Dockerfile
  2. 266 391
      result/package-lock.json
  3. 3 4
      result/package.json
  4. 3 17
      result/server.js
  5. 1 1
      result/views/app.js
  6. 2 2
      result/views/socket.io.js
  7. 8 9
      vote/Dockerfile

+ 7 - 9
result/Dockerfile

@@ -1,22 +1,20 @@
 FROM node:18-slim
 
 # add curl for healthcheck
-RUN apt-get update \
-    && apt-get install -y --no-install-recommends \
-    curl \
-    tini \
-    && rm -rf /var/lib/apt/lists/*
+RUN apt-get update && \
+    apt-get install -y --no-install-recommends curl tini && \
+    rm -rf /var/lib/apt/lists/*
 
-WORKDIR /app
+WORKDIR /usr/local/app
 
 # have nodemon available for local dev use (file watching)
 RUN npm install -g nodemon
 
 COPY package*.json ./
 
-RUN npm ci \
- && npm cache clean --force \
- && mv /app/node_modules /node_modules
+RUN npm ci && \
+ npm cache clean --force && \
+ mv /usr/local/app/node_modules /node_modules
 
 COPY . .
 

File diff suppressed because it is too large
+ 266 - 391
result/package-lock.json


+ 3 - 4
result/package.json

@@ -10,12 +10,11 @@
   "license": "MIT",
   "dependencies": {
     "async": "^3.1.0",
-    "body-parser": "^1.19.0",
-    "cookie-parser": "^1.4.4",
-    "express": "^4.17.1",
+    "cookie-parser": "^1.4.6",
+    "express": "^4.18.2",
     "method-override": "^3.0.0",
     "pg": "^8.8.0",
-    "socket.io": "^2.5.0",
+    "socket.io": "^4.7.2",
     "stoppable": "^1.1.0"
   }
 }

+ 3 - 17
result/server.js

@@ -1,20 +1,14 @@
 var express = require('express'),
     async = require('async'),
-    pg = require('pg'),
     { Pool } = require('pg'),
-    path = require('path'),
     cookieParser = require('cookie-parser'),
-    bodyParser = require('body-parser'),
-    methodOverride = require('method-override'),
     app = express(),
     server = require('http').Server(app),
     io = require('socket.io')(server);
 
-io.set('transports', ['polling']);
-
 var port = process.env.PORT || 4000;
 
-io.sockets.on('connection', function (socket) {
+io.on('connection', function (socket) {
 
   socket.emit('message', { text : 'Welcome!' });
 
@@ -23,7 +17,7 @@ io.sockets.on('connection', function (socket) {
   });
 });
 
-var pool = new pg.Pool({
+var pool = new Pool({
   connectionString: 'postgres://postgres:postgres@db/postgres'
 });
 
@@ -70,15 +64,7 @@ function collectVotesFromResult(result) {
 }
 
 app.use(cookieParser());
-app.use(bodyParser());
-app.use(methodOverride('X-HTTP-Method-Override'));
-app.use(function(req, res, next) {
-  res.header("Access-Control-Allow-Origin", "*");
-  res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
-  res.header("Access-Control-Allow-Methods", "PUT, GET, POST, DELETE, OPTIONS");
-  next();
-});
-
+app.use(express.urlencoded());
 app.use(express.static(__dirname + '/views'));
 
 app.get('/', function (req, res) {

+ 1 - 1
result/views/app.js

@@ -1,5 +1,5 @@
 var app = angular.module('catsvsdogs', []);
-var socket = io.connect({transports:['polling']});
+var socket = io.connect();
 
 var bg1 = document.getElementById('background-stats-1');
 var bg2 = document.getElementById('background-stats-2');

File diff suppressed because it is too large
+ 2 - 2
result/views/socket.io.js


+ 8 - 9
vote/Dockerfile

@@ -1,20 +1,19 @@
 # Using official python runtime base image
-FROM python:3.9-slim
+FROM python:3.11-slim
 
 # add curl for healthcheck
-RUN apt-get update \
-    && apt-get install -y --no-install-recommends \
-    curl \
-    && rm -rf /var/lib/apt/lists/*
+RUN apt-get update && \
+    apt-get install -y --no-install-recommends curl && \
+    rm -rf /var/lib/apt/lists/*
 
 # Set the application directory
-WORKDIR /app
+WORKDIR /usr/local/app
 
 # Install our requirements.txt
-COPY requirements.txt /app/requirements.txt
-RUN pip install -r requirements.txt
+COPY requirements.txt ./requirements.txt
+RUN pip install --no-cache-dir -r requirements.txt
 
-# Copy our code from the current folder to /app inside the container
+# Copy our code from the current folder to the working directory inside the container
 COPY . .
 
 # Make port 80 available for links and/or publish

Some files were not shown because too many files changed in this diff