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