Skip to content

Commit 62d3340

Browse files
authored
Feature/app container (#62)
* Add DockerFile to define application container * Add npm script for dockerfile to call * Update compose file to create `App` container e54751 * Update overlay service to listen to `0.0.0.0` in container * Remove debugging code from docker files * Remove docker command from npm start script
1 parent cd9be47 commit 62d3340

File tree

4 files changed

+60
-17
lines changed

4 files changed

+60
-17
lines changed

bot/overlay/overlay.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface IOverlayServer {
1313
@injectable()
1414
export default class OverlayServer {
1515
private server: Server;
16-
private host = 'localhost';
16+
private host = '0.0.0.0';
1717
private port = 8070;
1818
private rootPath = `local-cache/audio/8ball`;
1919

compose.yaml

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
version: '3.8'
22
services:
3-
# app:
4-
# build:
5-
# context: . # Context should only operate on a File System context based on the root directory
6-
# target: dev
7-
# # image: node:18-alpine
8-
# # working_dir: /app
9-
# depends_on:
10-
# postgres:
11-
# condition: service_healthy
12-
# volumes:
13-
# - ./:/app
14-
# - D:/DataWorkspaces/stream-assist-bot/logs:/app/logs
15-
# - D:/DataWorkspaces/stream-assist-bot/cache/:/app/local-cache/
3+
app:
4+
build:
5+
context: . # Context should only operate on a File System context based on the root directory
6+
target: dev
7+
working_dir: /app
8+
depends_on:
9+
postgres:
10+
condition: service_healthy
11+
ports:
12+
- 8080:8080 # WebSocker Server Port
13+
- 8070:8070 # Overlay Server Port
14+
environment:
15+
POSTGRES_HOST: postgres
16+
POSTGRES_PORT: 5432
17+
volumes:
18+
- ./:/app
19+
- D:/DataWorkspaces/stream-assist-bot/logs:/app/logs
20+
- D:/DataWorkspaces/stream-assist-bot/cache/:/app/local-cache/
1621
postgres:
1722
image: postgres
1823
restart: always
@@ -24,7 +29,7 @@ services:
2429
POSTGRES_DB: stream-assist-bot
2530
POSTGRES_PASSWORD: Vsnyi&FN^oLXUVqdjm9v4
2631
ports:
27-
- '6432:5432' # Expose the default postgres port
32+
- 6432:5432 # Expose the default postgres port
2833
healthcheck:
2934
test: [ "CMD", "pg_isready" ]
3035
interval: 10s

dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# syntax=docker/dockerfile:1
2+
3+
ARG NODE_VERSION=18.0.0
4+
5+
FROM node:${NODE_VERSION}-alpine as base
6+
WORKDIR /usr/src/app
7+
8+
FROM base as dev
9+
# install postgress client to debug db connection
10+
# RUN apk --update add postgresql-client
11+
RUN --mount=type=bind,source=package.json,target=package.json \
12+
--mount=type=bind,source=package-lock.json,target=package-lock.json \
13+
--mount=type=cache,target=/root/.npm \
14+
npm ci --include=dev
15+
USER node
16+
COPY . .
17+
CMD npm run dev
18+
19+
# FROM base as prod
20+
# ENV NODE_ENV production
21+
# RUN --mount=type=bind,source=package.json,target=package.json \
22+
# --mount=type=bind,source=package-lock.json,target=package-lock.json \
23+
# --mount=type=cache,target=/root/.npm \
24+
# npm ci --omit=dev
25+
# USER node
26+
# COPY . .
27+
# CMD node src/index.js
28+
29+
# FROM base as test
30+
# ENV NODE_ENV test
31+
# RUN --mount=type=bind,source=package.json,target=package.json \
32+
# --mount=type=bind,source=package-lock.json,target=package-lock.json \
33+
# --mount=type=cache,target=/root/.npm \
34+
# npm ci --include=dev
35+
# USER node
36+
# COPY . .
37+
# RUN npm run test

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
"sequelize-cli": "^6.6.2"
4545
},
4646
"scripts": {
47-
"start": "docker compose up -d && ts-node app.ts",
47+
"start": "ts-node app.ts",
48+
"dev": "ts-node app.ts",
4849
"test": "mocha -r ts-node/register **/*.spec.ts"
4950
},
5051
"keywords": [
@@ -54,4 +55,4 @@
5455
],
5556
"author": "Bryan Wood",
5657
"license": "GPLv3"
57-
}
58+
}

0 commit comments

Comments
 (0)