ci: dockerise le front (build Vite/pnpm -> nginx) + workflow Gitea Actions

- DataSentinel/Dockerfile (node 22 + pnpm + nginx) + nginx.conf (SPA + headers sécurité)
- workflow build/push image avec VITE_API_URL=https://datasentinel-api.nfteam.ovh
This commit is contained in:
neckfire
2026-06-20 12:27:51 +02:00
parent 87c099433b
commit 4466b38f75
3 changed files with 68 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
name: Build & Deploy
on:
push:
branches: [main]
workflow_dispatch: {}
env:
IMAGE: git.nfteam.ovh/neckfire/datasentinel-front
VITE_API_URL: https://datasentinel-api.nfteam.ovh
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build & push image
run: |
set -e
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login git.nfteam.ovh -u "${{ secrets.REGISTRY_USER }}" --password-stdin
docker build --build-arg VITE_API_URL="${VITE_API_URL}" \
-t "${IMAGE}:latest" -t "${IMAGE}:${GITHUB_SHA::12}" ./DataSentinel
docker push --all-tags "${IMAGE}"
echo "pushed ${IMAGE}"
- name: Notify ntfy (success/failure)
if: always()
run: |
if [ "${{ job.status }}" = "success" ]; then EMOJI="white_check_mark"; PRIO="default"; else EMOJI="rotating_light"; PRIO="high"; fi
curl -s \
-H "Authorization: Bearer ${{ secrets.NTFY_TOKEN }}" \
-H "Title: ${GITHUB_REPOSITORY} — ${{ job.status }}" \
-H "Priority: ${PRIO}" \
-H "Tags: ${EMOJI}" \
-H "Click: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions" \
-d "${GITHUB_WORKFLOW} sur ${GITHUB_REF_NAME} (run #${GITHUB_RUN_NUMBER}) : ${{ job.status }}" \
"${{ secrets.NTFY_URL }}/${{ secrets.NTFY_TOPIC }}" || true
+15
View File
@@ -0,0 +1,15 @@
# Front Data Sentinel — build Vite (pnpm) puis service statique via nginx.
FROM node:22-alpine AS build
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN corepack enable && pnpm install --frozen-lockfile
COPY . .
# URL de l'API injectée au build (Vite inline les import.meta.env.VITE_*).
ARG VITE_API_URL
ENV VITE_API_URL=$VITE_API_URL
RUN pnpm build
FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
+14
View File
@@ -0,0 +1,14 @@
server {
listen 80;
root /usr/share/nginx/html;
index index.html;
# SPA : toutes les routes retombent sur index.html
location / {
try_files $uri $uri/ /index.html;
}
add_header X-Frame-Options "DENY" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
}