This commit is contained in:
virus
2025-01-29 10:14:29 +01:00
parent 69d8ca94e7
commit 2528faf7ed
4 changed files with 22 additions and 14 deletions
+6 -5
View File
@@ -1,11 +1,12 @@
FROM node:14-alpine FROM node:22-alpine
RUN npm install --silent socket.io
RUN npm install --silent express
RUN mkdir /srv/public/ RUN mkdir /srv/public/
WORKDIR /srv/
RUN npm install socket.io
RUN npm install express
COPY ./app.js /srv/app.js COPY ./app.js /srv/app.js
COPY ./public/index.html /srv/public/index.html COPY ./public/index.html /srv/public/index.html
+12 -1
View File
@@ -1,11 +1,22 @@
const PORT = process.env.PORT || 8080; const PORT = process.env.PORT || 8080;
const PREFIX = process.env.PREFIX || '/ws'; 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('Socket.io listen on: http://localhost:' + PORT + '' + PREFIX + '/socket.io');
console.log('Publisher listen on: http://localhost:' + PORT + '' + PREFIX + '/pub/$roomID'); 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 app = require('express')();
const server = require('http').createServer(app); 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'); const bodyParser = require('body-parser');
+3 -8
View File
@@ -1,26 +1,21 @@
version: '3' version: '3'
services: services:
push: push:
image: registry.docker.tlfactory.pl/apps/push-stream-channels:0.1 image: docker.git.tlfactory.pl/apps/push-stream-channels:0.4
build: build:
context: . context: .
dockerfile: ./Dockerfile dockerfile: ./Dockerfile
restart: on-failure restart: on-failure
environment: environment:
- PORT=8080 - PORT=8080
- DEV=1
ports: ports:
- 80:8080 - 8201:8080
volumes: volumes:
- ./app.js:/srv/app.js - ./app.js:/srv/app.js
- ./public:/srv/public - ./public:/srv/public
networks:
- backend
php: php:
image: registry.docker.tlfactory.pl/apps/php-apache:7.4.20 image: registry.docker.tlfactory.pl/apps/php-apache:7.4.20
networks:
- backend
volumes: volumes:
- ./public/:/var/www/html - ./public/:/var/www/html
networks:
backend:
+1
View File
@@ -1,4 +1,5 @@
<script src="/ws/socket.io/socket.io.js"></script> <script src="/ws/socket.io/socket.io.js"></script>
<!-- <script src="/ws/socket.io/socket.io.min.js"></script>-->
<script> <script>
const socket = io("http://localhost", { const socket = io("http://localhost", {
path: '/ws/socket.io', path: '/ws/socket.io',