Update Dockerfile
This commit is contained in:
parent
8ec300ac5c
commit
c87bf44999
1 changed files with 24 additions and 21 deletions
27
Dockerfile
27
Dockerfile
|
|
@ -5,7 +5,6 @@ FROM node:${NODE_VERSION}-slim AS base-node
|
|||
WORKDIR /app
|
||||
ENV NODE_ENV="production"
|
||||
|
||||
# Install system dependencies for building native modules
|
||||
RUN apt-get update -qq && \
|
||||
apt-get install --no-install-recommends -y \
|
||||
build-essential \
|
||||
|
|
@ -24,27 +23,21 @@ COPY website/package.json website/package-lock.json* ./
|
|||
|
||||
RUN npm install --include=dev
|
||||
|
||||
# Copy source files
|
||||
COPY website/. ./
|
||||
|
||||
# Build the application
|
||||
RUN npm run build
|
||||
|
||||
FROM base-node AS build-websocket
|
||||
WORKDIR /websocket
|
||||
|
||||
# Install Bun
|
||||
RUN curl -fsSL https://bun.sh/install | bash
|
||||
ENV PATH="/root/.bun/bin:${PATH}"
|
||||
|
||||
# Copy websocket package files
|
||||
COPY website/websocket/package.json website/websocket/bun.lock* ./
|
||||
COPY website/websocket/tsconfig.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN bun install
|
||||
|
||||
# Copy websocket source
|
||||
COPY website/websocket/src ./src/
|
||||
|
||||
# Build websocket
|
||||
|
|
@ -56,22 +49,32 @@ COPY --from=build-main --chown=node:node /app/.svelte-kit/output ./build
|
|||
COPY --from=build-main --chown=node:node /app/node_modules ./node_modules
|
||||
COPY --from=build-main --chown=node:node /app/package.json ./package.json
|
||||
|
||||
# Copy cluster server
|
||||
COPY cluster-server.js ./cluster-server.js
|
||||
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
|
||||
|
||||
USER node
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["node", "cluster-server.js"]
|
||||
CMD ["pm2-runtime", "start", "ecosystem.config.js"]
|
||||
|
||||
FROM base-node AS production-websocket
|
||||
WORKDIR /websocket
|
||||
|
||||
# Install Bun in production stage
|
||||
RUN curl -fsSL https://bun.sh/install | bash
|
||||
ENV PATH="/root/.bun/bin:${PATH}"
|
||||
|
||||
# Copy built websocket from build stage
|
||||
COPY --from=build-websocket /websocket/dist ./dist
|
||||
COPY --from=build-websocket /websocket/package.json ./package.json
|
||||
|
||||
|
|
|
|||
Reference in a new issue