# Install workspace dependencies. FROM node:22-alpine AS deps RUN corepack enable RUN apk add --no-cache python3 make g++ WORKDIR /app COPY pnpm-lock.yaml pnpm-workspace.yaml package.json ./ COPY packages/shared/package.json packages/shared/ COPY packages/server/package.json packages/server/ COPY packages/client/package.json packages/client/ RUN pnpm install --frozen-lockfile # Build all workspace packages. FROM deps AS build COPY packages/shared/ packages/shared/ COPY packages/server/ packages/server/ COPY packages/client/ packages/client/ RUN pnpm --filter @music-together/shared run build RUN pnpm --filter @music-together/server run build RUN pnpm --filter @music-together/client run build # Run the production server, which also serves the client bundle. FROM node:22-alpine AS production RUN corepack enable RUN apk add --no-cache python3 make g++ vips WORKDIR /app COPY pnpm-lock.yaml pnpm-workspace.yaml package.json ./ COPY packages/shared/package.json packages/shared/ COPY packages/server/package.json packages/server/ COPY packages/client/package.json packages/client/ RUN pnpm install --frozen-lockfile --prod --filter @music-together/server... COPY --from=build /app/packages/server/dist packages/server/dist COPY --from=build /app/packages/client/dist packages/client/dist COPY --from=build /app/packages/shared/dist packages/shared/dist RUN sed -i 's|./src/index.ts|./dist/index.js|g' packages/shared/package.json RUN mkdir -p /data EXPOSE 3001 ENV NODE_ENV=production ENV DATABASE_URL=file:/data/music-together.db VOLUME ["/data"] CMD ["node", "packages/server/dist/index.js"]