Skip to content

Commit

Permalink
Merge branch 'feat/japa-tests' into fix/deps
Browse files Browse the repository at this point in the history
  • Loading branch information
eL1x00r authored Feb 9, 2024
2 parents 01d1dc4 + 79cab9d commit 582722d
Show file tree
Hide file tree
Showing 24 changed files with 26,147 additions and 116 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
npm-debug.log
Dockerfile
.dockerignore
14 changes: 14 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Node.js CI
on: [push]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '20.x'
- run: npm ci
- run: npm test
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"discord.enabled": true
}
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM node:latest
# Set the working directory
RUN apt-get update && apt-get install -y --no-install-recommends dumb-init
WORKDIR /home/node/app
# Before switching to user 'node', ensure the directory exists and has the correct permissions
RUN mkdir -p /home/node/app/node_modules && mkdir /home/node/app/tapstore && chown -R node:node /home/node/app
# Copying with chown in a single line before npm install to avoid permission issues.
COPY --chown=node:node . .
# Install dependencies
RUN npm install
# Expose ports
EXPOSE 5099
EXPOSE 13337
# RUN chmod -R 777 /home/node/
USER node
ENV NODE_ENV production

CMD [ "dumb-init", "npm", "start" ]
11 changes: 11 additions & 0 deletions bin/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { configure, processCLIArgs, run } from '@japa/runner'
import { expect } from '@japa/expect'
import { apiClient } from '@japa/api-client'

processCLIArgs(process.argv.splice(2))
configure({
files: ['tests/**/*.spec.js'],
plugins: [expect(), apiClient('http://localhost:5099')],
})

run()
82 changes: 82 additions & 0 deletions docker-compose-metrics.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
version: '3.8'
networks:
monitoring:
driver: bridge

volumes:
prometheus_data: {}
grafana_storage: {}
tapstore: {}

services:
trac-core:
# image: tap-reader
build:
context: ./
dockerfile: Dockerfile
# expose:
# - 13337
# - 5099
ports:
- '13337:13337'
- '5099:5099'
networks:
- monitoring
# volumes:
# - 'tapstore:/home/node/app/tapstore'

grafana:
build:
context: ./grafana
dockerfile: Dockerfile
container_name: grafana
restart: unless-stopped
environment:
# - GF_SERVER_ROOT_URL=http://my.grafana.server/
- GF_INSTALL_PLUGINS=grafana-clock-panel
ports:
- '3000:3000'
volumes:
- 'grafana_storage:/var/lib/grafana'
networks:
- monitoring

node-exporter:
image: prom/node-exporter:latest
container_name: node-exporter
restart: unless-stopped
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/rootfs:ro
command:
- '--path.procfs=/host/proc'
- '--path.rootfs=/rootfs'
- '--path.sysfs=/host/sys'
- '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)'
expose:
- 9100
ports:
- '9100:9100'
networks:
- monitoring

prometheus:
image: prom/prometheus:latest
container_name: prometheus
restart: unless-stopped
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--web.enable-lifecycle'
ports:
- '9090:9090'
expose:
- 9090
networks:
- monitoring
23 changes: 23 additions & 0 deletions docker-compose-standalone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: '3.8'
networks:
monitoring:
driver: bridge

volumes:
tapstore: {}

services:
tapreader:
build:
context: ./
dockerfile: Dockerfile
# expose:
# - 13337
# - 5099
ports:
- '13337:13337'
- '5099:5099'
# networks:
# - monitoring
volumes:
- './tapstore:/home/node/app/tapstore:rw'
12 changes: 12 additions & 0 deletions grafana/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM grafana/grafana

# ENV GF_AUTH_DISABLE_LOGIN_FORM "true"
# ENV GF_AUTH_ANONYMOUS_ENABLED "true"
# ENV GF_AUTH_ANONYMOUS_ORG ROLE "Admin"

#Adding all the files to docker container.
ADD provisioning /etc/grafana/provisioning
ADD config.ini /etc/grafana/config.ini

# Adding all the dashboard files (JSON) to docker container
ADD dashboards /var/lib/grafana/dashboards
6 changes: 6 additions & 0 deletions grafana/config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[paths]
provisioning = /etc/grafana/provisioning
[server]
enable_gzip = true
[users]
default_theme = dark
Loading

0 comments on commit 582722d

Please sign in to comment.