Spaces:
Build error
Build error
| # 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"] | |