configuration workflow CI
This commit is contained in:
parent
afa764b678
commit
0c141a10a4
49
Dockerfile
49
Dockerfile
@ -1,40 +1,19 @@
|
|||||||
# Install dependencies only when needed
|
FROM node:19-alpine
|
||||||
FROM node:19-alpine AS deps
|
|
||||||
|
|
||||||
WORKDIR leCoffre
|
WORKDIR /app
|
||||||
|
|
||||||
RUN npm install -D prisma@4.11.0
|
# Installation des dépendances
|
||||||
COPY package.json ./
|
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
|
# Création d'un utilisateur non-root
|
||||||
#RUN chmod 600 ~/.ssh/id_rsa
|
RUN adduser -D appuser --uid 10000 && \
|
||||||
#RUN eval "$(ssh-agent -s)" && ssh-add /root/.ssh/id_rsa
|
chown -R appuser /app
|
||||||
#RUN ssh-keyscan github.com smart-chain-fr/leCoffre-resources.git >> /root/.ssh/known_hosts
|
USER appuser
|
||||||
|
|
||||||
RUN npm install --frozen-lockfile
|
# Configuration du port et démarrage
|
||||||
|
EXPOSE 8080
|
||||||
COPY tsconfig.json tsconfig.json
|
CMD ["npm", "start"]
|
||||||
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
|
|
35
workflows/test.yml
Normal file
35
workflows/test.yml
Normal 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 }}
|
Loading…
x
Reference in New Issue
Block a user