2025-05-30 12:24:21 +03:00
# syntax = docker/dockerfile:1
ARG NODE_VERSION=20
FROM node:${NODE_VERSION}-slim AS base-node
WORKDIR /app
ENV NODE_ENV="production"
RUN apt-get update -qq && \
2025-05-30 14:41:17 +03:00
apt-get install --no-install-recommends -y \
build-essential \
node-gyp \
pkg-config \
python-is-python3 \
curl \
ca-certificates \
unzip && \
rm -rf /var/lib/apt/lists/*
2025-05-30 12:24:21 +03:00
FROM base-node AS build-main
# Copy package files
COPY website/package.json website/package-lock.json* ./
2025-05-30 12:40:44 +03:00
RUN npm install --include=dev
2025-05-30 12:24:21 +03:00
COPY website/. ./
RUN npm run build
FROM base-node AS build-websocket
WORKDIR /websocket
RUN curl -fsSL https://bun.sh/install | bash
ENV PATH="/root/.bun/bin:${PATH}"
COPY website/websocket/package.json website/websocket/bun.lock* ./
COPY website/websocket/tsconfig.json ./
RUN bun install
COPY website/websocket/src ./src/
# Build websocket
RUN bun build src/main.ts --outdir dist --target bun
FROM base-node AS production-main
2025-05-30 14:00:57 +03:00
COPY --from=build-main --chown=node:node /app/.svelte-kit/output ./build
2025-05-30 12:24:21 +03:00
COPY --from=build-main --chown=node:node /app/node_modules ./node_modules
COPY --from=build-main --chown=node:node /app/package.json ./package.json
2025-05-30 14:41:17 +03:00
RUN npm install -g pm2
RUN echo 'module.exports = {\n\
apps: [{\n\
name: "rugplay-app",\n\
script: "./build/index.js",\n\
instances: "max",\n\
exec_mode: "cluster",\n\
env: {\n\
NODE_ENV: "production",\n\
PORT: 3000\n\
}\n\
}]\n\
};' > ecosystem.config.js
2025-05-30 12:24:21 +03:00
USER node
EXPOSE 3000
2025-05-30 14:41:17 +03:00
CMD ["pm2-runtime", "start", "ecosystem.config.js"]
2025-05-30 12:24:21 +03:00
FROM base-node AS production-websocket
WORKDIR /websocket
RUN curl -fsSL https://bun.sh/install | bash
ENV PATH="/root/.bun/bin:${PATH}"
COPY --from=build-websocket /websocket/dist ./dist
COPY --from=build-websocket /websocket/package.json ./package.json
EXPOSE 8080
2025-05-30 12:36:35 +03:00
CMD ["bun", "run", "dist/main.js"]