Merge branch 'cicd' into dev
This commit is contained in:
commit
eda7102ded
43
.github/workflows/cicd.yml
vendored
Normal file
43
.github/workflows/cicd.yml
vendored
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
name: Build and Push to Registry
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ cicd ]
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: git.4nkweb.com
|
||||||
|
IMAGE_NAME: 4nk/ihm_client
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up SSH agent
|
||||||
|
uses: webfactory/ssh-agent@v0.9.1
|
||||||
|
with:
|
||||||
|
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Login to Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ secrets.USER }}
|
||||||
|
password: ${{ secrets.TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
ssh: default
|
||||||
|
build-args: |
|
||||||
|
ENV_VARS=${{ secrets.ENV_VARS }}
|
||||||
|
tags: |
|
||||||
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
||||||
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ gitea.sha }}
|
62
Dockerfile
62
Dockerfile
@ -1,13 +1,61 @@
|
|||||||
FROM node:20
|
# syntax=docker/dockerfile:1.4
|
||||||
|
FROM rust:1.82-alpine AS wasm-builder
|
||||||
|
WORKDIR /build
|
||||||
|
|
||||||
ENV TZ=Europe/Paris
|
# Installation des dépendances nécessaires pour la compilation
|
||||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
RUN apk update && apk add --no-cache \
|
||||||
|
git \
|
||||||
|
openssh-client \
|
||||||
|
curl \
|
||||||
|
nodejs \
|
||||||
|
npm \
|
||||||
|
build-base \
|
||||||
|
pkgconfig \
|
||||||
|
clang \
|
||||||
|
llvm \
|
||||||
|
musl-dev \
|
||||||
|
nginx
|
||||||
|
|
||||||
# use this user because he have uid et gid 1000 like theradia
|
# Installation de wasm-pack
|
||||||
USER node
|
RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
|
||||||
|
|
||||||
|
# Configuration SSH basique
|
||||||
|
RUN mkdir -p /root/.ssh && \
|
||||||
|
ssh-keyscan git.4nkweb.com >> /root/.ssh/known_hosts
|
||||||
|
|
||||||
|
# On se place dans le bon répertoire parent
|
||||||
|
WORKDIR /build
|
||||||
|
# Copie du projet ihm_client
|
||||||
|
COPY . ihm_client/
|
||||||
|
|
||||||
|
# Clonage du sdk_client au même niveau que ihm_client en utilisant la clé SSH montée
|
||||||
|
RUN --mount=type=ssh git clone -b cicd ssh://git@git.4nkweb.com/4nk/sdk_client.git
|
||||||
|
|
||||||
|
# Build du WebAssembly avec accès SSH pour les dépendances
|
||||||
|
WORKDIR /build/sdk_client
|
||||||
|
RUN --mount=type=ssh wasm-pack build --out-dir ../ihm_client/pkg --target bundler --dev
|
||||||
|
|
||||||
|
FROM node:20-alpine
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
CMD ["npm", "start"]
|
# Installation des dépendances nécessaires
|
||||||
# "--disable-host-check", "--host", "0.0.0.0", "--ssl", "--ssl-cert", "/ssl/certs/site.crt", "--ssl-key", "/ssl/private/site.dec.key"]
|
RUN apk update && apk add --no-cache git nginx
|
||||||
|
|
||||||
|
# Copie des fichiers du projet
|
||||||
|
COPY --from=wasm-builder /build/ihm_client/pkg ./pkg
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Installation des dépendances Node.js
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
# Copie de la configuration nginx
|
||||||
|
COPY nginx.dev.conf /etc/nginx/http.d/default.conf
|
||||||
|
|
||||||
|
# Script de démarrage
|
||||||
|
COPY start-dev.sh /start-dev.sh
|
||||||
|
RUN chmod +x /start-dev.sh
|
||||||
|
|
||||||
|
EXPOSE 3003 80
|
||||||
|
|
||||||
|
CMD ["/start-dev.sh"]
|
||||||
|
|
||||||
|
48
nginx.dev.conf
Normal file
48
nginx.dev.conf
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name localhost;
|
||||||
|
|
||||||
|
# Redirection des requêtes HTTP vers Vite
|
||||||
|
location / {
|
||||||
|
proxy_pass http://localhost:3003;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "Upgrade";
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /ws/ {
|
||||||
|
proxy_pass http://localhost:8090;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "Upgrade";
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
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 X-NginX-Proxy true;
|
||||||
|
proxy_read_timeout 86400;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /storage/ {
|
||||||
|
rewrite ^/storage(/.*)$ $1 break;
|
||||||
|
proxy_pass http://localhost:8080;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "Upgrade";
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /api/ {
|
||||||
|
proxy_pass http://localhost:8091;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
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;
|
||||||
|
|
||||||
|
# CORS headers
|
||||||
|
add_header Access-Control-Allow-Origin "*" always;
|
||||||
|
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS, PUT, DELETE" always;
|
||||||
|
add_header Access-Control-Allow-Headers "Authorization,Content-Type,Accept,X-Requested-With" always;
|
||||||
|
}
|
||||||
|
}
|
@ -5,7 +5,7 @@
|
|||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"build_wasm": "wasm-pack build --out-dir ../ihm_client_dev3/pkg ../sdk_client --target bundler --dev",
|
"build_wasm": "wasm-pack build --out-dir ../ihm_client/pkg ../sdk_client --target bundler --dev",
|
||||||
"start": "vite --host 0.0.0.0",
|
"start": "vite --host 0.0.0.0",
|
||||||
"build": "tsc && vite build",
|
"build": "tsc && vite build",
|
||||||
"deploy": "sudo cp -r dist/* /var/www/html/",
|
"deploy": "sudo cp -r dist/* /var/www/html/",
|
||||||
|
7
start-dev.sh
Normal file
7
start-dev.sh
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Démarrer nginx en arrière-plan
|
||||||
|
nginx
|
||||||
|
|
||||||
|
# Démarrer le serveur de développement Vite
|
||||||
|
npm run start
|
@ -57,7 +57,7 @@ export default defineConfig({
|
|||||||
fs: {
|
fs: {
|
||||||
cachedChecks: false,
|
cachedChecks: false,
|
||||||
},
|
},
|
||||||
port: 3004,
|
port: 3003,
|
||||||
proxy: {
|
proxy: {
|
||||||
'/storage': {
|
'/storage': {
|
||||||
target: 'https://demo.4nkweb.com',
|
target: 'https://demo.4nkweb.com',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user