Skip to content

Commit 5d8dd0e

Browse files
committed
Migrated web socker server to docker
1 parent c7e5a20 commit 5d8dd0e

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.env
2+
.git
3+
.github
4+
node_modules/
5+
dist/

Dockerfile.wss

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Use an official Node.js runtime as a parent image
2+
FROM node:18
3+
4+
# Set the working directory inside the container
5+
WORKDIR /usr/src/app
6+
7+
ENV PATH /usr/src/app/node_modules/.bin:$PATH
8+
9+
# Copy the package.json and package-lock.json files into the container
10+
COPY ./wss/. .
11+
12+
# Install the project dependencies
13+
RUN npm ci
14+
15+
RUN npm run production
16+
17+
# Expose the port that the app runs on (assuming the app runs on port 3000)
18+
EXPOSE 8080
19+
20+
# Start the Node.js application
21+
CMD ["npm", "start"]
22+

compose.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ services:
2424
- redis
2525
networks:
2626
- app-network
27+
wss:
28+
build:
29+
context: ./
30+
dockerfile: Dockerfile.wss
31+
labels:
32+
- "traefik.http.routers.wss.rule=Host(`ws.tabletopper.local`)"
33+
env_file: "./wss/.env"
34+
depends_on:
35+
- mysql
36+
- reverse-proxy
37+
- redis
38+
networks:
39+
- app-network
2740
mysql:
2841
image: mysql:8.0
2942
environment:

wss/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"main": "dist/src/index.js",
23
"devDependencies": {
34
"@types/node": "^17.0.8",
45
"npm-watch": "^0.11.0",
@@ -12,7 +13,8 @@
1213
"make": "tsc",
1314
"test": "rm -rf ./dist && npm run make && node ./build/mover.js && node ./dist/src/index.js",
1415
"production": "npm run make && node ./build/mover.js",
15-
"watch": "npm-watch"
16+
"watch": "npm-watch",
17+
"start": "node ./dist/src/index.js"
1618
},
1719
"watch": {
1820
"test": {

0 commit comments

Comments
 (0)