Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimizations for docker #337

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 32 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,48 @@
FROM m.daocloud.io/docker.io/library/node:20 AS builder
FROM m.daocloud.io/docker.io/library/node:20-bookworm-slim AS builder

WORKDIR /app

COPY ./packages/backend/dist /app

COPY ./packages/backend/package*.json ./
WORKDIR /build

RUN npm install --omit=dev --registry=https://registry.npmmirror.com
COPY . .

RUN npm rebuild
RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/* && \
apt-get update && apt-get install -y \
git \
python3 \
build-essential \
&& rm -rf /var/lib/apt/lists/* && \
npm install -g pnpm --registry=https://registry.npmmirror.com && \
pnpm config set registry https://registry.npmmirror.com && \
pnpm install && \
cd packages/backend && pnpm run build

# FROM m.daocloud.io/docker.io/library/debian:11-slim AS deb_extractor
WORKDIR /app

# RUN cd /tmp && \
# apt-get update && apt-get download libicu-dev && \
# mkdir /dpkg && \
# for deb in *.deb; do dpkg --extract $deb /dpkg || exit 10; done
RUN mv /build/packages/backend/dist/* /app/. && \
mv /build/packages/main/app/build/renderer /app/app && \
mv /build/packages/backend/package*.json . && \
pnpm install --prod && \
pnpm rebuild

# FROM gcr.io/distroless/nodejs20-debian12
FROM m.daocloud.io/docker.io/library/node:20-bookworm-slim

WORKDIR /app

COPY --from=builder /app /app

# create data dir and set permission of app and data dir for non-privileged user
RUN mkdir /data && \
chmod -R 777 /app && \
chmod -R 777 /data

# switch data dir
# TODO: use DATA_DIR env instead of hardcoded HOME
ENV HOME=/data

# COPY --from=deb_extractor /dpkg /
RUN apt-get update && apt-get install -y libicu-dev ffmpeg
RUN apt-get update && \
apt-get install -y libicu-dev ffmpeg && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

RUN npm install pm2 -g

Expand Down