File size: 1,603 Bytes
00a912e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# 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"]