Compare commits

..

7 Commits

Author SHA1 Message Date
0d91d559dc regroup frontend and backend in same file and in same Dockerfile 2026-03-07 19:35:55 +01:00
b5bc405771 regroup backend and frontend in app folder 2026-03-07 19:25:30 +01:00
66c72f46a2 Update README.md 2026-01-20 21:46:48 +00:00
fa024ff1f4 Remove ignored files from repo 2026-01-20 15:13:06 +01:00
8d6ecabdd2 Add gitattributes 2026-01-20 14:07:30 +00:00
50fc6d12a6 Update .gitignore 2026-01-20 14:06:35 +00:00
2b6b5706bb Update .gitignore 2026-01-20 14:04:41 +00:00
28355 changed files with 412 additions and 3268010 deletions

38
.gitattributes vendored Normal file
View File

@ -0,0 +1,38 @@
####################################
# Fin de ligne cohérente
####################################
* text=auto eol=lf
####################################
# Code tiers / dépendances
####################################
node_modules/** linguist-vendored
vendor/** linguist-vendored
third_party/** linguist-vendored
####################################
# Code généré / IA / outputs
####################################
generated/** linguist-generated
lovable-output/** linguist-generated
lovable-generated/** linguist-generated
*.ai linguist-generated
*.lovable linguist-generated
*.gen.* linguist-generated
####################################
# Binaires
####################################
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.ico binary
*.svg binary
####################################
# Forcer types de fichiers si nécessaire
####################################
*.ts linguist-language=TypeScript
*.go linguist-language=Go
*.rs linguist-language=Rust

80
.gitignore vendored
View File

@ -1,27 +1,79 @@
# ---> Go
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
####################################
# Système
####################################
.DS_Store
Thumbs.db
*.swp
*.tmp
*.log
####################################
# Node.js / Frontend
####################################
node_modules/
dist/
build/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
package-lock.json
.env
.env.local
.env.*.local
####################################
# Go
####################################
# Binaires
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Dependency directories (remove the comment below to include it)
# vendor/
# Go workspace
bin/
pkg/
# Go workspace file
# Modules
go.work
go.work.sum
# env file
.env
####################################
# Rust
####################################
target/
*.rs.bk
# Cargo.lock géré par toi si nécessaire
####################################
# Docker
####################################
docker-compose.override.yml
####################################
# CI / IDE
####################################
.vscode/
.idea/
*.iml
####################################
# Lovable / code généré par IA
####################################
# Dossiers générés
lovable-output/
lovable-generated/
.generated/
generated/
.ai/
.ai-output/
# Fichiers générés
*.lovable
*.prompt
*.completion
*.response
*.gen.*

101
README.md
View File

@ -1,2 +1,99 @@
# 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.
## Installation
docker-compose.yaml
```YAML
services:
migrate:
image: migrate/migrate
volumes:
# Attention : assure-toi que le dossier migrations est présent sur ton serveur
- ./migrations:/migrations
networks:
- app-net
command: -path=/migrations/ -database "postgres://admin:admin@db:5432/monitoring?sslmode=disable" up
depends_on:
db:
condition: service_healthy
backend:
image: gitea.anthonybouteiller.ovh/blomios/servicemanager-backend:latest
container_name: sm-api
networks:
- app-net
depends_on:
migrate:
condition: service_completed_successfully
# On expose les ports si nécessaire, sinon Nginx s'en occupe via le réseau interne
expose:
- "8080"
frontend:
image: gitea.anthonybouteiller.ovh/blomios/servicemanager-frontend:latest
container_name: sm-ui
networks:
- app-net
depends_on:
- backend
expose:
- "3000"
db:
image: postgres:16-alpine
container_name: db
environment:
POSTGRES_USER: admin
POSTGRES_PASSWORD: admin
POSTGRES_DB: monitoring
ports:
- "5432:5432"
volumes:
- db-data:/var/lib/postgresql/data
networks:
- app-net
healthcheck:
test: ["CMD-SHELL", "pg_isready -U admin -d monitoring"]
interval: 5s
timeout: 5s
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:
app-net:
driver: bridge
volumes:
db-data:
```

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
networks:
- 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
depends_on:
db:
condition: service_healthy
backend:
build: ./backend
container_name: backend
app:
build: .
container_name: sm-app
ports:
- "8082:80"
networks:
- app-net
depends_on:
migrate:
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:
image: postgres:16-alpine
container_name: db
@ -61,24 +39,10 @@ services:
timeout: 5s
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:
app-net:
driver: bridge
volumes:
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
COPY package.json package-lock.json ./
RUN npm install --legacy-peer-deps
RUN npm ci --include=optional --legacy-peer-deps
COPY . .
@ -18,5 +18,4 @@ COPY --from=builder /app/dist /usr/share/nginx/html
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