Skip to content

Commit

Permalink
add dev config for nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
MatiXxD committed Dec 9, 2024
1 parent 720424d commit c659282
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ go.work.sum
.prod.env

coverage.out.tmp
*/nginx/logs/
64 changes: 47 additions & 17 deletions docker/docker-compose.dev.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
networks:
prometheus:
prometheus-exporters:
app-network:
driver: bridge

services:
novamusic-user:
Expand All @@ -24,6 +26,7 @@ services:
networks:
- prometheus
- prometheus-exporters
- app-network

novamusic-playlist:
image: daronenko/novamusic-playlist:${PLAYLIST_VERSION}
Expand All @@ -44,6 +47,7 @@ services:
networks:
- prometheus
- prometheus-exporters
- app-network

novamusic-artist:
image: daronenko/novamusic-artist:${ARTIST_VERSION}
Expand All @@ -64,6 +68,7 @@ services:
networks:
- prometheus
- prometheus-exporters
- app-network

novamusic-album:
image: daronenko/novamusic-album:${ALBUM_VERSION}
Expand All @@ -84,6 +89,7 @@ services:
networks:
- prometheus
- prometheus-exporters
- app-network

novamusic-track:
image: daronenko/novamusic-track:${TRACK_VERSION}
Expand All @@ -104,6 +110,7 @@ services:
networks:
- prometheus
- prometheus-exporters
- app-network

novamusic-csat:
image: daronenko/novamusic-csat:${CSAT_VERSION}
Expand All @@ -126,6 +133,7 @@ services:
networks:
- prometheus
- prometheus-exporters
- app-network

novamusic-genre:
image: daronenko/novamusic-genre:${GENRE_VERSION}
Expand All @@ -146,6 +154,7 @@ services:
networks:
- prometheus
- prometheus-exporters
- app-network

postgres:
container_name: novamusic-postgres
Expand All @@ -166,7 +175,7 @@ services:
healthcheck:
test:
[
'CMD-SHELL',
"CMD-SHELL",
"sh -c 'pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}'",
]
interval: 2s
Expand Down Expand Up @@ -211,7 +220,7 @@ services:
- 8011:9001
command: server --console-address :9001 /data
healthcheck:
test: ['CMD', 'mc', 'ready', 'local']
test: ["CMD", "mc", "ready", "local"]
interval: 5s
timeout: 5s
retries: 5
Expand Down Expand Up @@ -251,11 +260,11 @@ services:
image: prom/node-exporter:latest
container_name: node-exporter
command:
- '--path.procfs=/host/proc'
- '--path.rootfs=/rootfs'
- '--path.sysfs=/host/sys'
- '--collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc)($$|/)'
- '--no-collector.rapl'
- "--path.procfs=/host/proc"
- "--path.rootfs=/rootfs"
- "--path.sysfs=/host/sys"
- "--collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc)($$|/)"
- "--no-collector.rapl"
restart: unless-stopped
expose:
- 9100
Expand All @@ -271,13 +280,13 @@ services:
container_name: prometheus
env_file: .dev.env
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus/'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--storage.tsdb.retention.time=365d'
- '--web.external-url=${PROMETHEUS_URL}'
- '--web.enable-admin-api'
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus/"
- "--web.console.libraries=/etc/prometheus/console_libraries"
- "--web.console.templates=/etc/prometheus/consoles"
- "--storage.tsdb.retention.time=365d"
- "--web.external-url=${PROMETHEUS_URL}"
- "--web.enable-admin-api"
restart: unless-stopped
expose:
- 9090
Expand Down Expand Up @@ -321,9 +330,9 @@ services:
- ./alertmanager/alertmanager.yml:/etc/alertmanager/alertmanager.yml
- ./alertmanager/telegram.tmpl:/etc/alertmanager/telegram.tmpl
command:
- '--config.file=/etc/alertmanager/alertmanager.yml'
- '--storage.path=/alertmanager'
- '--web.external-url=${ALERTMANAGER_EXTERNAL_URL}'
- "--config.file=/etc/alertmanager/alertmanager.yml"
- "--storage.path=/alertmanager"
- "--web.external-url=${ALERTMANAGER_EXTERNAL_URL}"
restart: unless-stopped
expose:
- 9093
Expand All @@ -332,6 +341,27 @@ services:
networks:
- prometheus

nginx:
image: nginx:latest
# restart: always
container_name: nginx
ports:
- 8080:80
volumes:
- ./nginx/dev.conf:/etc/nginx/nginx.conf
- ~/technopark/sem2/frontend/2024_2_NovaCode/dist:/var/www/dist
- ./nginx/logs:/var/log/nginx
networks:
- app-network
depends_on:
- novamusic-user
- novamusic-track
- novamusic-artist
- novamusic-album
- novamusic-playlist
- novamusic-csat
- novamusic-genre

volumes:
postgres-data:
minio-data:
Expand Down
114 changes: 114 additions & 0 deletions docker/nginx/dev.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
worker_processes 1;

pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

sendfile on;
tcp_nopush on;

proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=novamusic_cache:15m max_size=2g inactive=60s use_temp_path=off;

gzip on;
gzip_types text/plain text/css text/javascript text/xml application/json application/javascript;

upstream user_service {
server novamusic-user:8080;
}

upstream track_service {
server novamusic-track:8080;
}

upstream album_service {
server novamusic-album:8080;
}

upstream playlist_service {
server novamusic-playlist:8080;
}

upstream artist_service {
server novamusic-artist:8080;
}

upstream genre_service {
server novamusic-genre:8080;
}

upstream csat_service {
server novamusic-csat:8080;
}

server {
listen 80;
server_name localhost;

proxy_set_header Host $http_host;
proxy_set_header Origin $http_origin;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Content-Type $http_content_type;

location /api/v1/users {
proxy_pass http://user_service/api/v1/users;
}

location /api/v1/auth {
proxy_pass http://user_service/api/v1/auth;
}

location /api/v1/health {
proxy_pass http://user_service/api/v1/health;
}

location /api/v1/tracks {
proxy_pass http://track_service/api/v1/tracks;
}

location /api/v1/albums {
proxy_pass http://album_service/api/v1/albums;
}

location /api/v1/playlists {
proxy_pass http://playlist_service/api/v1/playlists;
}

location /api/v1/artists {
proxy_pass http://artist_service/api/v1/artists;
}

location /api/v1/genres {
proxy_pass http://genre_service/api/v1/genres;
}

location /api/v1/csat {
proxy_pass http://csat_service/api/v1/csat;
}

location / {
# proxy_cache novamusic_cache;
# proxy_cache_valid 200 30m;

root /var/www/dist;
index index.html;
try_files $uri /index.html;
}
}
}

0 comments on commit c659282

Please sign in to comment.