Files
unleash/Dockerfile
T
Christopher Kolstad 78eb6ad911 task: migrate to pnpm (#11898)
Things worth noticing (+14075, -20262 most of this is due to yarn.lock
being deleted, and a new package manager tool being checked in)

## Code changes (actual changes to ts files)
### Not interesting
- being explicit about test imports in frontend rather than using
tsconfig globals to resolve `describe`, `it`, `test`, `expect` et al.
### Interesting
- Type signatures resolutions have changed a slightly bit, so some of
our Knex queries needed to be extracted for tsc to manage to type
analyse and pass type checking. All tests are green, so I'm assuming I
managed to reproduce the behaviour, in particular
src/lib/features/project/project-read-model.ts has some extra variables
to pass typechecking.


### Other considerations
- Do we still build the way we did? (pnpm pack produces the same
files/artifact as yarn pack)
- Will this merge cleanly with enterprise (which runs prepack)?

#### Known unknowns
- I've changed our vite.config.mts in frontend to use vite's own built
in tsconfigpaths, but Thomas pointed out that he tried that already and
ran into some issue when enterprise used the dependency, so we'll need
to double check that it works, and be ready to rollback to using the
deprecated plugin (and accept that vite gives us a warning that this is
now native functionality).

### Build failures
- Expected is openapi validation on main, we've changed to using pnpm
action rather than yarn action so it won't recognize yarn as a
packageManager on main
- dependency scanner, due to how pnpm resolves dependencies, we now have
a more direct dependencies, which our scanner apparently is scoring too
low for it to be OK with them. These were already a dependency, just
transitively rather than direct, so I'm comfortable with this.
2026-05-06 12:17:17 +02:00

41 lines
860 B
Docker

ARG NODE_VERSION=22.22-alpine3.23
FROM node:$NODE_VERSION AS builder
WORKDIR /unleash
COPY . /unleash
RUN corepack enable
RUN pnpm install --frozen-lockfile --ignore-scripts && pnpm prepare:backend && pnpm local:package
# frontend/build should already exist (it needs to be built in the local filesystem but in case of a fresh build we'll build it here)
RUN pnpm build:frontend:if-needed
RUN mkdir -p /unleash/build/frontend && mv /unleash/frontend/build /unleash/build/frontend/build
RUN CI=true pnpm prune --prod --ignore-scripts
FROM node:$NODE_VERSION
ENV NODE_ENV=production
ENV TZ=UTC
WORKDIR /unleash
COPY --from=builder /unleash/build /unleash/
COPY --from=builder /unleash/node_modules /unleash/node_modules
RUN rm -rf /usr/local/lib/node_modules/npm/
RUN apk upgrade --no-cache
EXPOSE 4242
USER node
CMD ["node", "dist/server.js"]