diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..21751ef --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +node_modules +client/node_modules +client/dist +dist +.git +.env +logs +generated +redis-data +test +docs diff --git a/.env.production.example b/.env.production.example index ac006f1..d3c6bcd 100644 --- a/.env.production.example +++ b/.env.production.example @@ -35,6 +35,14 @@ EMAIL_SECURE=true EMAIL_USER= EMAIL_PASS= EMAIL_FROM= +MAIL_PROVIDER= +NOVAMAILIO_MAIL_API_BASE= +NOVAMAILIO_MAIL_CREDENTIAL= +NOVAMAILIO_MAIL_FROM_NAME= +NOVAMAILIO_MAIL_FINGERPRINT= +NOVAMAILIO_MAIL_ORIGIN= +NOVAMAILIO_MAIL_REFERER= +NOVAMAILIO_MAIL_USER_AGENT= # Zulip ZULIP_CONFIG_MODE=dynamic diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ca54a7e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,47 @@ +FROM node:22-bookworm-slim AS build + +RUN npm install --global pnpm@9.15.4 +WORKDIR /app + +COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ +COPY client/package.json ./client/package.json +RUN pnpm install --frozen-lockfile + +COPY nest-cli.json tsconfig.json tsconfig.build.json ./ +COPY src ./src +RUN pnpm run build + +FROM node:22-bookworm-slim AS runtime + +ENV NODE_ENV=production +ENV SKIN_GENERATION_PYTHON=/opt/skin-generation-venv/bin/python +ENV PIP_INDEX_URL=https://mirrors.cloud.tencent.com/pypi/simple + +RUN sed -i 's|deb.debian.org|mirrors.cloud.tencent.com|g' /etc/apt/sources.list.d/debian.sources \ + && apt-get update \ + && apt-get install --yes --no-install-recommends ca-certificates python3 python3-venv \ + && rm -rf /var/lib/apt/lists/* + +RUN npm install --global pnpm@9.15.4 +WORKDIR /app + +COPY requirements-skin-generation.txt ./ +RUN python3 -m venv /opt/skin-generation-venv \ + && /opt/skin-generation-venv/bin/pip install --no-cache-dir --requirement requirements-skin-generation.txt + +COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ +COPY client/package.json ./client/package.json +RUN pnpm install --prod --frozen-lockfile && pnpm store prune + +COPY --from=build /app/dist ./dist +COPY scripts ./scripts + +RUN mkdir -p config generated/account-assets generated/skins logs redis-data \ + && chown -R node:node /app + +USER node +EXPOSE 3000 3001 +HEALTHCHECK --interval=15s --timeout=5s --start-period=30s --retries=4 \ + CMD node -e "fetch('http://127.0.0.1:3000/health').then(r=>{if(!r.ok)process.exit(1)}).catch(()=>process.exit(1))" + +CMD ["node", "dist/main.js"] diff --git a/requirements-skin-generation.txt b/requirements-skin-generation.txt new file mode 100644 index 0000000..c09c573 --- /dev/null +++ b/requirements-skin-generation.txt @@ -0,0 +1,3 @@ +numpy==2.0.2 +openai==2.14.0 +Pillow==11.3.0