File size: 1,444 Bytes
eab050b
3d54be7
eab050b
 
 
 
 
 
 
edb5cd6
d0653c8
e250cf6
edb5cd6
d0653c8
9472cc8
61e5331
 
 
71f35dd
61e5331
edb5cd6
066fcc2
 
edb5cd6
 
 
 
 
 
61e5331
 
9472cc8
eab050b
 
 
 
 
 
 
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
# Use an official Node.js runtime as a parent image
FROM node:20-alpine

# Set the working directory in the container
WORKDIR /app

# Install pnpm
RUN npm install -g pnpm

# Copy root package.json and pnpm-workspace.yaml
COPY package.json pnpm-workspace.yaml ./

# Copy lib/ to make @workspace/api-spec and its dependencies available
COPY lib lib/

# First, install dependencies required to run the codegen for api-spec.
# This will install 'orval' which is a devDependency of @workspace/api-spec.
RUN pnpm install --filter=@workspace/api-spec --no-frozen-lockfile

# Now, run the codegen to generate @workspace/api-zod.
# This populates artifacts/api-zod/src/generated. This needs to happen BEFORE other packages try to link to api-zod.
RUN pnpm --filter=@workspace/api-spec run codegen

# After codegen, copy the 'artifacts' directory. Now, 'artifacts/api-zod' will contain the generated code,
# and 'artifacts/api-server' (with its package.json) will be present for the full install.
COPY artifacts artifacts/

# Perform a full pnpm install for all workspace packages.
# Now that @workspace/api-zod's source files are generated, pnpm can properly link it to @workspace/api-server.
RUN pnpm install --no-frozen-lockfile

# Build the api-server project.
RUN pnpm run build --filter=@workspace/api-server

# Expose the port the app runs on
EXPOSE 3000

# Define the command to run the app
CMD ["node", "./artifacts/api-server/build/index.mjs"]