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 15:16:20 +03:00
apt-get install --no-install-recommends -y \
build-essential \
node-gyp \
pkg-config \
python-is-python3 \
curl \
ca-certificates \
2025-06-23 16:22:32 +02:00
unzip \
libc6 \
&& 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-06-23 16:22:32 +02:00
# Install dependencies with platform-specific binaries
RUN npm install --include=dev --platform=linux --arch=x64
2025-05-30 12:24:21 +03:00
2025-06-23 16:22:32 +02:00
# Copy the rest of the application
COPY website/. .
2025-05-30 12:24:21 +03:00
2025-06-23 16:22:32 +02:00
# Create .svelte-kit directory if it doesn't exist
RUN mkdir -p .svelte-kit
# Generate SvelteKit types and build
2025-06-25 15:46:19 +02:00
2025-05-30 12:24:21 +03:00
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/
RUN bun build src/main.ts --outdir dist --target bun
FROM base-node AS production-main
2025-05-30 15:16:20 +03:00
COPY --from=build-main --chown=node:node /app/build ./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
USER node
EXPOSE 3000
2025-06-24 18:13:50 +03:00
CMD ["node", "build"]
2025-05-30 12:24:21 +03:00
2025-06-24 18:13:50 +03:00
FROM oven/bun:1 AS production-websocket
2025-05-30 12:24:21 +03:00
WORKDIR /websocket
2025-06-24 18:13:50 +03:00
COPY --from=build-websocket --chown=bun:bun /websocket/dist ./dist
COPY --from=build-websocket --chown=bun:bun /websocket/package.json ./package.json
USER bun
2025-05-30 12:24:21 +03:00
EXPOSE 8080
2025-05-30 12:36:35 +03:00
CMD ["bun", "run", "dist/main.js"]