mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
improve docker build
This commit is contained in:
6
.github/workflows/docker.yml
vendored
6
.github/workflows/docker.yml
vendored
@@ -18,6 +18,10 @@ jobs:
|
|||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
@@ -51,3 +55,5 @@ jobs:
|
|||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
|||||||
48
Dockerfile
48
Dockerfile
@@ -1,28 +1,46 @@
|
|||||||
FROM node:22
|
# Stage 1: build
|
||||||
|
FROM node:22-slim AS builder
|
||||||
|
|
||||||
WORKDIR /fredy
|
WORKDIR /fredy
|
||||||
|
|
||||||
COPY . /fredy
|
# Install Chromium without extra recommended packages and clean apt cache
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends chromium \
|
||||||
RUN apt-get update && apt-get install -y chromium
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
|
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
|
||||||
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
|
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
|
||||||
|
|
||||||
# Timeout fix für yarn hinzugefügt
|
# Copy manifest for better cache usage
|
||||||
RUN yarn config set network-timeout 600000
|
COPY package.json yarn.lock ./
|
||||||
|
|
||||||
RUN yarn install
|
# Increase yarn timeout, install deps and pm2 globally
|
||||||
|
RUN yarn config set network-timeout 600000 \
|
||||||
RUN yarn global add pm2
|
&& yarn install --frozen-lockfile \
|
||||||
|
&& yarn global add pm2
|
||||||
|
|
||||||
|
# Copy app sources and build production assets
|
||||||
|
COPY . .
|
||||||
RUN yarn run prod
|
RUN yarn run prod
|
||||||
|
|
||||||
RUN mkdir /db /conf && \
|
# Stage 2: runtime
|
||||||
chown 1000:1000 /db /conf && \
|
FROM node:22-slim AS runner
|
||||||
chmod 777 -R /db/ && \
|
|
||||||
ln -s /db /fredy/db && ln -s /conf /fredy/conf
|
WORKDIR /fredy
|
||||||
|
|
||||||
|
# Copy entire build directory from builder instead of individual folders
|
||||||
|
COPY --from=builder /fredy /fredy
|
||||||
|
# Copy Chromium executable
|
||||||
|
COPY --from=builder /usr/bin/chromium /usr/bin/chromium
|
||||||
|
|
||||||
|
# Create non-root user, prepare volumes and permissions
|
||||||
|
RUN groupadd -r app && useradd -r -g app app \
|
||||||
|
&& mkdir /db /conf \
|
||||||
|
&& chown app:app /db /conf \
|
||||||
|
&& chmod 777 /db /conf
|
||||||
|
|
||||||
|
USER app
|
||||||
|
|
||||||
EXPOSE 9998
|
EXPOSE 9998
|
||||||
|
|
||||||
CMD pm2-runtime index.js
|
# Run with pm2-runtime for proper process management
|
||||||
|
CMD ["pm2-runtime", "index.js"]
|
||||||
Reference in New Issue
Block a user