Compare commits

..

2 Commits

28315 changed files with 220 additions and 3227382 deletions

View File

@ -1,6 +1,17 @@
# ServiceManager # ServiceManager
## Structure
- `app/`: frontend + backend + infrastructure Docker de l'application.
- `node/`: code et artefacts du node (CLI/service).
## Lancer l'application
```bash
docker compose -f app/docker-compose.yml up --build
```
Monitoring your services from different machine on a same place. Monitoring your services from different machine on a same place.

33
app/Dockerfile Normal file
View File

@ -0,0 +1,33 @@
FROM --platform=$BUILDPLATFORM node:22-alpine AS frontend-builder
WORKDIR /frontend
COPY frontend/package.json frontend/package-lock.json ./
RUN npm ci --include=optional --legacy-peer-deps
COPY frontend/ .
RUN npm run build
FROM golang:1.24 AS backend-builder
WORKDIR /backend
COPY backend/go.mod backend/go.sum ./
RUN go mod download
COPY backend/ .
RUN go mod tidy
RUN go build -o backend .
FROM debian:bookworm-slim
WORKDIR /app
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates nginx \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /var/www/html/*
COPY --from=frontend-builder /frontend/dist /usr/share/nginx/html
COPY --from=backend-builder /backend/backend /app/backend
COPY --from=backend-builder /backend/sql /app/sql
COPY nginx.conf /etc/nginx/nginx.conf
COPY docker/start.sh /start.sh
RUN chmod +x /start.sh
EXPOSE 80
CMD ["/start.sh"]

View File

@ -5,43 +5,21 @@ services:
- ./backend/migrations:/migrations - ./backend/migrations:/migrations
networks: networks:
- app-net - app-net
# On attend que la DB soit prête pour lancer les migrations
command: -path=/migrations/ -database "postgres://admin:admin@db:5432/monitoring?sslmode=disable" up command: -path=/migrations/ -database "postgres://admin:admin@db:5432/monitoring?sslmode=disable" up
depends_on: depends_on:
db: db:
condition: service_healthy condition: service_healthy
backend: app:
build: ./backend build: .
container_name: backend container_name: sm-app
ports:
- "8082:80"
networks: networks:
- app-net - app-net
depends_on: depends_on:
migrate: migrate:
condition: service_completed_successfully condition: service_completed_successfully
frontend:
build: ./frontend
container_name: frontend
networks:
- app-net
depends_on:
- backend
# node:
# build: ./node
# container_name: node
# environment:
# - HOST_IP=192.168.1.75
# ports:
# - "8081:8081"
# networks:
# - app-net
# volumes:
# - node-data:/app
# depends_on:
# - backend
# restart: unless-stopped
db: db:
image: postgres:16-alpine image: postgres:16-alpine
container_name: db container_name: db
@ -61,24 +39,10 @@ services:
timeout: 5s timeout: 5s
retries: 5 retries: 5
nginx:
image: nginx:alpine
container_name: monitor-proxy
ports:
- "8082:80"
- "444:443"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
- frontend
- backend
networks:
- app-net
networks: networks:
app-net: app-net:
driver: bridge driver: bridge
volumes: volumes:
db-data: db-data:
node-data: node-data:

26
app/docker/start.sh Normal file
View File

@ -0,0 +1,26 @@
#!/bin/sh
set -eu
/app/backend &
backend_pid=$!
term_handler() {
kill -TERM "$backend_pid" 2>/dev/null || true
wait "$backend_pid" 2>/dev/null || true
exit 0
}
trap term_handler INT TERM
nginx -g 'daemon off;' &
nginx_pid=$!
while kill -0 "$backend_pid" 2>/dev/null && kill -0 "$nginx_pid" 2>/dev/null; do
sleep 1
done
kill -TERM "$backend_pid" 2>/dev/null || true
kill -TERM "$nginx_pid" 2>/dev/null || true
wait "$backend_pid" 2>/dev/null || true
wait "$nginx_pid" 2>/dev/null || true
exit 1

View File

@ -1,10 +1,10 @@
FROM node:22-alpine AS builder FROM --platform=$BUILDPLATFORM node:22-alpine AS builder
WORKDIR /app WORKDIR /app
COPY package.json package-lock.json ./ COPY package.json package-lock.json ./
RUN npm install --legacy-peer-deps RUN npm ci --include=optional --legacy-peer-deps
COPY . . COPY . .
@ -18,5 +18,4 @@ COPY --from=builder /app/dist /usr/share/nginx/html
EXPOSE 80 EXPOSE 80
CMD ["nginx", "-g", "daemon off;"] CMD ["nginx", "-g", "daemon off;"]

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Some files were not shown because too many files have changed in this diff Show More