From ef689cf97e3108b2ac21ef70fe6a101af5ac695a Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Thu, 15 May 2025 10:37:21 +0200 Subject: [PATCH] fix docker build harder --- .github/workflows/docker.yml | 29 ++++++++--------------------- Dockerfile | 35 +++++++++++++++-------------------- 2 files changed, 23 insertions(+), 41 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 0558d59..5514c13 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -43,24 +43,11 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - name: Build and push Docker image with cache & retry - run: | - set -e - for i in {1..3}; do - echo "Attempt $i of 3" - docker buildx build \ - --push \ - --platform linux/amd64,linux/arm64 \ - --tag ${{ steps.meta.outputs.tags }} \ - --label ${{ steps.meta.outputs.labels }} \ - --cache-from=type=gha \ - --cache-to=type=gha,mode=max \ - . && break || echo "Build failed (attempt $i)" - if [ $i -eq 3 ]; then - echo "Docker build failed after 3 attempts. Exiting with error." - exit 1 - else - echo "Retrying in 10 seconds..." - sleep 10 - fi - done \ No newline at end of file + - name: Build and push Docker image + uses: docker/build-push-action@v3 + with: + context: . + push: true + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index 8edb0e1..c2e19d0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,33 +1,28 @@ FROM node:20 -# Install chromium dependencies in a separate layer (cacheable) -RUN apt-get update && apt-get install -y chromium && \ - apt-get clean && rm -rf /var/lib/apt/lists/* - -# Set working directory WORKDIR /fredy -# Copy only package.json + yarn.lock for dependency caching -COPY package.json yarn.lock ./ +COPY . /fredy -# Increase network timeout for npm registry -RUN yarn config set network-timeout 600000 && yarn install +RUN apt-get update && apt-get install -y chromium + +ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \ + PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium + +# Timeout fix für yarn hinzugefügt +RUN yarn config set network-timeout 600000 + +RUN yarn install -# Global tools (cached separately) RUN yarn global add pm2 -# Copy application source code (after deps, cache friendly) -COPY . . - -# Build step (assuming 'prod' is a build script) RUN yarn run prod -# Prepare runtime dirs RUN mkdir /db /conf && \ - chown 1000:1000 /db /conf && \ - chmod 777 -R /db/ && \ - ln -s /db /fredy/db && ln -s /conf /fredy/conf + chown 1000:1000 /db /conf && \ + chmod 777 -R /db/ && \ + ln -s /db /fredy/db && ln -s /conf /fredy/conf -# Expose port & set runtime command EXPOSE 9998 -CMD ["pm2-runtime", "index.js"] \ No newline at end of file + +CMD pm2-runtime index.js