diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..1c5380b --- /dev/null +++ b/.gitea/workflows/build.yml @@ -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 diff --git a/DataSentinel/Dockerfile b/DataSentinel/Dockerfile new file mode 100644 index 0000000..bb607cc --- /dev/null +++ b/DataSentinel/Dockerfile @@ -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 diff --git a/DataSentinel/nginx.conf b/DataSentinel/nginx.conf new file mode 100644 index 0000000..7d3db24 --- /dev/null +++ b/DataSentinel/nginx.conf @@ -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; +}