Skip to content

Commit

Permalink
Merge pull request #36 from ufosc/feature/refactor-services-buildout
Browse files Browse the repository at this point in the history
Refactor to monorepo architecture, add live data
  • Loading branch information
IkeHunter authored Sep 5, 2024
2 parents 8f3d7eb + 102f440 commit bab030d
Show file tree
Hide file tree
Showing 133 changed files with 7,113 additions and 4,565 deletions.
7 changes: 5 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
*

# Show only the files we need
!src/
!server/
!package.json
!package-lock.json
!tsconfig.json
!jest.config.ts
!jest.config.ts
!common/
!websocket/
!packages/
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = {
plugins: ['@typescript-eslint', 'prefer-arrow-functions', 'prettier'],
rules: {
'@typescript-eslint/consistent-type-imports': 'warn',
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-redeclare': 'off',
'@typescript-eslint/space-before-function-paren': 'off',
'@typescript-eslint/no-explicit-any': 'off',
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
- name: Build images
run: docker-compose build
- name: Run Test
run: docker-compose run --rm api sh -c "npm run test"
run: docker-compose run --rm server sh -c "npm run test"
14 changes: 7 additions & 7 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"files.associations": {
"*.sh.tpl": "shellscript",
"*.json.tpl": "JSON",
"*.conf.tpl": "NGINX Conf"
}
}
// {
// "files.associations": {
// "*.sh.tpl": "shellscript",
// "*.json.tpl": "JSON",
// "*.conf.tpl": "NGINX Conf"
// }
// }
35 changes: 0 additions & 35 deletions Dockerfile

This file was deleted.

8 changes: 4 additions & 4 deletions deploy/ec2.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ data "aws_ami" "amzn_linux_2" {
most_recent = true
owners = ["amazon"]

filter {
name = "name"
values = ["al2023-ami-2023.3.*-kernel-6.1-x86_64"]
}
# filter {
# name = "name"
# values = ["al2023-ami-2023.3.*-kernel-6.1-x86_64"]
# }

filter {
name = "architecture"
Expand Down
116 changes: 101 additions & 15 deletions docker-compose.network.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
version: "3.9"

services:
api:
server:
restart: always
build:
context: .
networks:
- cluster
context: ./
dockerfile: ./server/Dockerfile
container_name: server-jbx
environment:
- NODE_ENV=production
- PORT=8000
- NODE_ENV=network
- PORT=9000
- HOST=localhost
- JWT_SECRET_KEY=changeme
- TOKEN_HEADER_KEY=Authorization
- MONGO_URI=mongodb://root:changeme@mongodb:27017
- MONGO_URI=mongodb://root:changeme@mmongo-network-jbx:27017
- SP_ID=${SP_ID}
- SP_SECRET=${SP_SECRET}
- LOG_LEVEL=debug
- KAFKA_BROKERS=kafka-jbx:9092
ports:
- 8000:8000
- 9000:9000
depends_on:
- mongodb
- kafka
volumes:
- ./src:/app/src
- ./server:/app/server
- ./packages:/app/packages
networks:
- cluster
command: npm run dev:server

proxy:
build:
Expand All @@ -31,29 +36,110 @@ services:
networks:
- cluster
depends_on:
- api
- server
volumes:
- client-dist:/vol/client
environment:
- SERVER_URI=server-jbx:9000
- WEBSOCKET_URI=websocket-jbx:9001
attach: false

mongodb:
image: mongo:6.0.9
restart: always
container_name: mongo-network-jbx
ports:
- 27017:27017
networks:
- cluster
volumes:
- mongo-data:/data/db
environment:
- MONGO_INITDB_ROOT_USERNAME=root
- MONGO_INITDB_ROOT_PASSWORD=changeme
command: mongod --quiet --logpath /dev/null --bind_ip_all
networks:
- cluster

####################################
# Kafka Config
####################################
zookeeper:
image: confluentinc/cp-zookeeper:latest
container_name: zookeeper-jbx
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
ports:
- 2181:2181
networks:
- cluster
attach: false

kafka:
image: confluentinc/cp-kafka:latest
container_name: kafka-jbx
depends_on:
- zookeeper
ports:
- 9092:9092
- 29092:29092
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper-jbx:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092
# KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_AUTO_CREATE_TOPICS_ENABLE: true
networks:
- cluster
attach: false

kafka-api:
image: 'docker-spring-boot-postgres:latest'
build:
context: ./kafka-api
container_name: kafka-api-jbx
ports:
- 9090:8080
environment:
- SPRING_PROFILES_ACTIVE=dev
depends_on:
- kafka

####################################
# Web Socket Config
####################################
websocket:
build:
context: ./
dockerfile: ./websocket/Dockerfile
restart: always
ports:
- 9001:9001
container_name: websocket-jbx
volumes:
- ./websocket:/app/websocket
- ./packages:/app/packages
- ./package.json:/app/package.json
environment:
- HOST=0.0.0.0
- PORT=9001
- NODE_ENV=network
- LOG_LEVEL=debug
- KAFKA_BROKERS=kafka-jbx:9092
- KAFKA_GROUP_ID=websocket-jbx
- LOG_NS=websocket
# - BYPASS_AUTH=1
command: npm run dev:websocket
networks:
- cluster

volumes:
client-dist:
name: client-dist
mongo-data:

networks:
cluster:
name: jukebox_cluster
Expand Down
6 changes: 2 additions & 4 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3.9"

services:
api:
restart: always
Expand All @@ -22,7 +20,7 @@ services:
depends_on:
- mongodb
volumes:
- ./src:/app/src
- ./server:/app/server

proxy:
build:
Expand Down Expand Up @@ -55,7 +53,7 @@ volumes:
client-dist:
name: client-dist
mongo-data:

networks:
cluster:
name: jukebox_cluster
Expand Down
22 changes: 11 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
version: '3.9'

services:
api:
server:
restart: always
build:
context: .
dockerfile: ./Dockerfile.dev
context: ./
dockerfile: ./server/Dockerfile
args:
- NODE_ENV=development
environment:
Expand All @@ -19,22 +17,24 @@ services:
- MONGO_DB=db
- MONGO_USER=root
- MONGO_PASSWORD=changeme
- MONGO_URI=mongodb://root:changeme@mongo-jukebox:27017
- MONGO_URI=mongodb://root:changeme@mongo-jbx:27017
- SPOTIFY_CLIENT_ID=${SPOTIFY_CLIENT_ID}
- SPOTIFY_CLIENT_SECRET=${SPOTIFY_CLIENT_SECRET}
ports:
- 8000:8000
depends_on:
- mongo-jukebox
- mongodb
volumes:
- ./src:/app/src
- ./server:/app/server
- ./jest.config.ts:/app/jest.config.ts
- ./packages:/app/packages
# - ./dist:/app/dist
command: npm run dev
mongo-jukebox:

mongodb:
image: mongo:6.0.9
restart: always
container_name: mongo-jukebox
container_name: mongo-jbx
ports:
- 27017:27017
volumes:
Expand Down
Loading

0 comments on commit bab030d

Please sign in to comment.