From e98b9ff6d7449c8f841c03e2467cde1101fa4c77 Mon Sep 17 00:00:00 2001 From: omaroughriss Date: Tue, 1 Jul 2025 15:55:24 +0200 Subject: [PATCH] Add private key in secrets --- .github/workflows/cicd.yml | 2 ++ Dockerfile | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 7379e3b3..d1c8456f 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -30,6 +30,8 @@ jobs: with: context: . push: true + build-args: | + SSH_PRIVATE_KEY=${{ secrets.SSH_PRIVATE_KEY }} tags: | ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ gitea.sha }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index bf54d6c8..4e17b189 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,10 +8,13 @@ COPY .env ./ RUN apk update && apk add openssh-client git -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 git.4nkweb.com >> /root/.ssh/known_hosts +ARG SSH_PRIVATE_KEY +RUN mkdir -p /root/.ssh && \ + echo "${SSH_PRIVATE_KEY}" > /root/.ssh/id_rsa && \ + chmod 600 /root/.ssh/id_rsa && \ + eval "$(ssh-agent -s)" && \ + ssh-add /root/.ssh/id_rsa && \ + ssh-keyscan git.4nkweb.com >> /root/.ssh/known_hosts RUN npm install --frozen-lockfile