Skip to content

Commit

Permalink
Update ws proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
gRoussac committed Jan 27, 2025
1 parent 5082810 commit 640c437
Show file tree
Hide file tree
Showing 28 changed files with 6,046 additions and 5,751 deletions.
3 changes: 2 additions & 1 deletion docker/Dockerfile.cicd
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FROM --platform=linux/amd64 node:22.13-alpine as build

ENV NODE_ENV "development"
ARG BUILD_CONFIGURATION=production
ARG BUILD_CONFIGURATION=docker
ENV BUILD_CONFIGURATION=$BUILD_CONFIGURATION

WORKDIR /app

Expand Down
4 changes: 3 additions & 1 deletion docker/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
FROM --platform=linux/amd64 node:22.13-alpine as build

ENV NODE_ENV "development"
ARG BUILD_CONFIGURATION=docker-dev
ENV BUILD_CONFIGURATION=$BUILD_CONFIGURATION

WORKDIR /app

Expand All @@ -22,6 +24,6 @@ RUN npm run build-proxy-conf
# Proxy localhost to gateway
RUN sed -i 's|http://localhost|http://172.17.0.1|g' proxy.conf.json

CMD npm run serve -- --configuration=docker
CMD npm run serve -- --configuration=$BUILD_CONFIGURATION

EXPOSE 4200
25 changes: 25 additions & 0 deletions docker/docker-compose.cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,31 @@ services:
networks:
- casper-network

ws-proxy:
container_name: ws-proxy
build:
context: ../
dockerfile: ./docker/ws-proxy.Dockerfile
tty: true
environment:
PORT: 4300

# Set allowed origins here with casper-webclient url
ALLOWED_HOSTS: |
localhost,
127.0.0.1,
172.17.0.1
# Set allowed origins here with casper-webclient url
ALLOWED_PORTS: |
28101,
7779
ports:
- 4300:4300
networks:
- casper-network

networks:
casper-network:
external: false
31 changes: 31 additions & 0 deletions docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,38 @@ services:
context: ../
ports:
- '4200:4200'
networks:
- casper-network

# Build and run image with Dockerfile
# docker build -t casper-webclient . --force-rm
# docker container run -t -i --rm -h casper-webclient -p 4200:4200 casper-webclient

ws-proxy:
container_name: ws-proxy
build:
context: ../
dockerfile: ./docker/ws-proxy.Dockerfile
tty: true
environment:
PORT: 4300

# Set allowed origins here with target url
ALLOWED_HOSTS: |
localhost,
127.0.0.1,
172.17.0.1
# Set allowed origins here with target port
ALLOWED_PORTS: |
28101,
7779
ports:
- 4300:4300
networks:
- casper-network

networks:
casper-network:
external: false
23 changes: 23 additions & 0 deletions docker/ws-proxy.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM node:14-alpine

# Set environment variables for production
ENV NODE_ENV=production
ENV NODE_PATH=/usr/local/lib/node_modules

# Optional: If you want to manage versions directly, use ARG
ARG version=latest

# Install dependencies globally
RUN npm install -g ws@$version

# Copy the server.js file into the container
COPY ./examples/frontend/angular/ws-proxy.js /app/ws-proxy.js

# Set the working directory for the container
WORKDIR /app

# Expose the port your app will run on
EXPOSE 4300

# Run the server when the container starts
CMD ["node", "ws-proxy.js"]
16 changes: 15 additions & 1 deletion examples/desktop/electron/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { app, BrowserWindow } = require('electron');
const url = require('url');
const path = require('path');
const { fork } = require('child_process');

let win;

Expand All @@ -27,4 +28,17 @@ function createWindow() {
);
}

app.on('ready', createWindow);
app.on('ready', () => {
const wsServerPath = path.resolve(__dirname, '../ws-proxy.js');
const wsProxyProcess = fork(wsServerPath);

// wsProxyProcess.on('message', (msg) => {
// console.log('Message from ws-proxy:', msg);
// });

wsProxyProcess.on('exit', (code) => {
console.log(`WebSocket server exited with code ${code}`);
});

createWindow();
});
Loading

0 comments on commit 640c437

Please sign in to comment.