From 2528faf7ed3c7c3a796c663b03d6a55ebfc07876 Mon Sep 17 00:00:00 2001 From: virus Date: Wed, 29 Jan 2025 10:14:29 +0100 Subject: [PATCH] ver-0.4 --- Dockerfile | 11 ++++++----- app.js | 13 ++++++++++++- docker-compose.yml | 11 +++-------- public/index.html | 1 + 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5958d30..7eb0a57 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,12 @@ -FROM node:14-alpine - -RUN npm install --silent socket.io - -RUN npm install --silent express +FROM node:22-alpine RUN mkdir /srv/public/ +WORKDIR /srv/ + +RUN npm install socket.io +RUN npm install express + COPY ./app.js /srv/app.js COPY ./public/index.html /srv/public/index.html diff --git a/app.js b/app.js index b153647..0d0728d 100644 --- a/app.js +++ b/app.js @@ -1,11 +1,22 @@ const PORT = process.env.PORT || 8080; const PREFIX = process.env.PREFIX || '/ws'; +const DEV = process.env.DEV || false; console.log('Socket.io listen on: http://localhost:' + PORT + '' + PREFIX + '/socket.io'); console.log('Publisher listen on: http://localhost:' + PORT + '' + PREFIX + '/pub/$roomID'); +if (DEV !== false) { + console.log('System is on DEV mode'); +} const app = require('express')(); const server = require('http').createServer(app); -const io = require('socket.io')(server, {path: PREFIX + '/socket.io'}); +var io; + +if (DEV !== false) { + io = require('socket.io')(server, {path: PREFIX + '/socket.io', cors: {origin: '*',}}); +} else { + io = require('socket.io')(server, {path: PREFIX + '/socket.io'}); +} + const bodyParser = require('body-parser'); diff --git a/docker-compose.yml b/docker-compose.yml index 59e083d..aeba3d9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,26 +1,21 @@ version: '3' services: push: - image: registry.docker.tlfactory.pl/apps/push-stream-channels:0.1 + image: docker.git.tlfactory.pl/apps/push-stream-channels:0.4 build: context: . dockerfile: ./Dockerfile restart: on-failure environment: - PORT=8080 + - DEV=1 ports: - - 80:8080 + - 8201:8080 volumes: - ./app.js:/srv/app.js - ./public:/srv/public - networks: - - backend php: image: registry.docker.tlfactory.pl/apps/php-apache:7.4.20 - networks: - - backend volumes: - ./public/:/var/www/html -networks: - backend: diff --git a/public/index.html b/public/index.html index d357113..af76e11 100644 --- a/public/index.html +++ b/public/index.html @@ -1,4 +1,5 @@ +