diff --git a/Dockerfile b/Dockerfile index 15f33c1..3d99a5e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 \ No newline at end of file +# Configuration du port et démarrage +EXPOSE 8080 +CMD ["npm", "start"] \ No newline at end of file diff --git a/workflows/test.yml b/workflows/test.yml new file mode 100644 index 0000000..4fb8b42 --- /dev/null +++ b/workflows/test.yml @@ -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 }} \ No newline at end of file