configuration workflow CI

This commit is contained in:
Omar Oughriss 2025-06-30 12:18:06 +02:00
parent afa764b678
commit 0c141a10a4
2 changed files with 49 additions and 35 deletions

View File

@ -1,40 +1,19 @@
# Install dependencies only when needed
FROM node:19-alpine AS deps
FROM node:19-alpine
WORKDIR leCoffre
WORKDIR /app
RUN npm install -D prisma@4.11.0
COPY package.json ./
# Installation des dépendances
COPY package*.json ./
RUN npm install --production
RUN apk update && apk add openssh-client git
# Copie des fichiers source
COPY src ./src
#COPY id_rsa /root/.ssh/id_rsa
#RUN chmod 600 ~/.ssh/id_rsa
#RUN eval "$(ssh-agent -s)" && ssh-add /root/.ssh/id_rsa
#RUN ssh-keyscan github.com smart-chain-fr/leCoffre-resources.git >> /root/.ssh/known_hosts
# Création d'un utilisateur non-root
RUN adduser -D appuser --uid 10000 && \
chown -R appuser /app
USER appuser
RUN npm install --frozen-lockfile
COPY tsconfig.json tsconfig.json
COPY src src
RUN npx prisma generate
RUN npm run build
# Production image, copy all the files and run next
FROM node:19-alpine AS production
WORKDIR leCoffre
RUN adduser -D lecoffreuser --uid 10000 && chown -R lecoffreuser .
COPY --from=deps --chown=lecoffreuser leCoffre/node_modules ./node_modules
COPY --from=deps --chown=lecoffreuser leCoffre/dist dist
COPY --from=deps --chown=lecoffreuser leCoffre/package.json ./package.json
COPY --from=deps --chown=lecoffreuser leCoffre/src/common/databases ./src/common/databases
RUN apk update && apk add chromium
USER lecoffreuser
CMD ["npm", "run", "api:start"]
EXPOSE 3001
# Configuration du port et démarrage
EXPOSE 8080
CMD ["npm", "start"]

35
workflows/test.yml Normal file
View File

@ -0,0 +1,35 @@
name: Build and Push to Registry
on:
push:
branches: [ test ]
env:
REGISTRY: git.4nkweb.com
IMAGE_NAME: 4nk/lecoffre-back-mini
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- 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
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ gitea.sha }}