mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
fix docker build harder
This commit is contained in:
29
.github/workflows/docker.yml
vendored
29
.github/workflows/docker.yml
vendored
@@ -43,24 +43,11 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
|
||||||
- name: Build and push Docker image with cache & retry
|
- name: Build and push Docker image
|
||||||
run: |
|
uses: docker/build-push-action@v3
|
||||||
set -e
|
with:
|
||||||
for i in {1..3}; do
|
context: .
|
||||||
echo "Attempt $i of 3"
|
push: true
|
||||||
docker buildx build \
|
platforms: linux/amd64,linux/arm64
|
||||||
--push \
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
--platform linux/amd64,linux/arm64 \
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
--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
|
|
||||||
|
|||||||
29
Dockerfile
29
Dockerfile
@@ -1,33 +1,28 @@
|
|||||||
FROM node:20
|
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
|
WORKDIR /fredy
|
||||||
|
|
||||||
# Copy only package.json + yarn.lock for dependency caching
|
COPY . /fredy
|
||||||
COPY package.json yarn.lock ./
|
|
||||||
|
|
||||||
# Increase network timeout for npm registry
|
RUN apt-get update && apt-get install -y chromium
|
||||||
RUN yarn config set network-timeout 600000 && yarn install
|
|
||||||
|
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
|
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
|
RUN yarn run prod
|
||||||
|
|
||||||
# Prepare runtime dirs
|
|
||||||
RUN mkdir /db /conf && \
|
RUN mkdir /db /conf && \
|
||||||
chown 1000:1000 /db /conf && \
|
chown 1000:1000 /db /conf && \
|
||||||
chmod 777 -R /db/ && \
|
chmod 777 -R /db/ && \
|
||||||
ln -s /db /fredy/db && ln -s /conf /fredy/conf
|
ln -s /db /fredy/db && ln -s /conf /fredy/conf
|
||||||
|
|
||||||
# Expose port & set runtime command
|
|
||||||
EXPOSE 9998
|
EXPOSE 9998
|
||||||
CMD ["pm2-runtime", "index.js"]
|
|
||||||
|
CMD pm2-runtime index.js
|
||||||
|
|||||||
Reference in New Issue
Block a user