From e8d7c5777fafddd55a1e12a2d0a69929aa74ee5e Mon Sep 17 00:00:00 2001 From: omaroughriss Date: Tue, 1 Jul 2025 16:19:17 +0200 Subject: [PATCH] Minor Update --- .github/workflows/cicd.yml | 4 +++- Dockerfile | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index bb55c40e..10df55a0 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -26,6 +26,8 @@ jobs: password: ${{ secrets.TOKEN }} - name: Build and push + env: + SSH_KEY: ${{ secrets.SSH_PRIVATE_KEY }} uses: docker/build-push-action@v5 with: context: . @@ -35,4 +37,4 @@ jobs: ENV_VARS=${{ secrets.ENV_VARS }} tags: | ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ gitea.sha }} \ No newline at end of file + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ gitea.sha }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 880169bc..77a9e1bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # Install dependencies only when needed FROM node:19-alpine AS deps -WORKDIR leCoffre-front +WORKDIR /app COPY package.json ./ @@ -12,7 +12,7 @@ RUN apk update && apk add openssh-client git ARG SSH_PRIVATE_KEY RUN mkdir -p /root/.ssh && \ - echo "${SSH_PRIVATE_KEY}" > /root/.ssh/id_rsa && \ + echo "${SSH_PRIVATE_KEY}" | base64 -d > /root/.ssh/id_rsa && \ chmod 600 /root/.ssh/id_rsa && \ eval "$(ssh-agent -s)" && \ ssh-add /root/.ssh/id_rsa && \ @@ -23,11 +23,11 @@ RUN npm install --frozen-lockfile # Rebuild the source code only when needed FROM node:19-alpine AS builder -WORKDIR leCoffre-front +WORKDIR /app -COPY --from=deps leCoffre-front/node_modules ./node_modules -COPY --from=deps leCoffre-front/package.json package.json -COPY --from=deps leCoffre-front/.env ./.env +COPY --from=deps /app/node_modules ./node_modules +COPY --from=deps /app/package.json package.json +COPY --from=deps /app/.env ./.env COPY tsconfig.json tsconfig.json COPY next.config.js next.config.js COPY src src @@ -37,16 +37,16 @@ RUN npm run build # Production image, copy all the files and run next FROM node:19-alpine AS production -WORKDIR leCoffre-front +WORKDIR /app RUN adduser -D lecoffreuser --uid 10000 && chown -R lecoffreuser . COPY public ./public -COPY --from=builder --chown=lecoffreuser leCoffre-front/node_modules ./node_modules -COPY --from=builder --chown=lecoffreuser leCoffre-front/.next ./.next -COPY --from=builder --chown=lecoffreuser leCoffre-front/next.config.js ./next.config.js -COPY --from=builder --chown=lecoffreuser leCoffre-front/package.json ./package.json -COPY --from=builder --chown=lecoffreuser leCoffre-front/.env ./.env +COPY --from=builder --chown=lecoffreuser /app/node_modules ./node_modules +COPY --from=builder --chown=lecoffreuser /app/.next ./.next +COPY --from=builder --chown=lecoffreuser /app/next.config.js ./next.config.js +COPY --from=builder --chown=lecoffreuser /app/package.json ./package.json +COPY --from=builder --chown=lecoffreuser /app/.env ./.env USER lecoffreuser