Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fair-horses-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@labdigital/commercetools-mock": patch
---

Update build process for the docker version
29 changes: 13 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
FROM node:18-alpine AS builder
ENV PNPM_VERSION=9.0.2
FROM node:22-alpine AS builder
ENV PNPM_VERSION=10.24.0

RUN corepack enable && \
corepack prepare pnpm@${PNPM_VERSION} --activate && \
pnpm config set store-dir /pnpm-store

RUN mkdir -p /app && chown node:node /app

USER node

WORKDIR /app

# Files required by pnpm install
COPY package.json pnpm-lock.yaml tsdown.config.js tsconfig.json /app/
COPY --chown=node package.json pnpm-lock.yaml tsdown.config.js tsconfig.json /app/

RUN pnpm install --frozen-lockfile

# Bundle app source
COPY src src
COPY vendor vendor

RUN pnpm build:server


FROM node:18-alpine
WORKDIR /app
COPY --chown=node src /app/src
COPY --chown=node vendor /app/vendor

RUN adduser -D -u 8000 commercetools

COPY --from=builder /app/dist /app
# Build server bundle
RUN pnpm build:server

EXPOSE 8989
ENV HTTP_SERVER_PORT 8989
ENV HTTP_SERVER_PORT=8989

CMD ["node", "./server.js"]
CMD ["node", "./dist/server.mjs"]
13 changes: 13 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: "3.9"

services:
server:
build:
context: .
dockerfile: Dockerfile
ports:
- "8989:8989"
environment:
NODE_ENV: production
PORT: 8989
restart: unless-stopped
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
],
"scripts": {
"build": "tsdown",
"build:server": "esbuild src/server.ts --bundle --outfile=dist/server.js --platform=node",
"build:server": "tsdown src/server.ts --platform=node",
"check": "biome check && tsc",
"format": "biome check --fix",
"lint": "biome check",
Expand Down Expand Up @@ -65,10 +65,10 @@
"typescript": "5.9.3",
"vitest": "4.0.13"
},
"packageManager": "pnpm@10.8.0",
"packageManager": "pnpm@10.24.0",
"engines": {
"node": ">=18",
"pnpm": ">=9.0.2"
"pnpm": ">=10.8.0"
},
"publishConfig": {
"access": "public",
Expand Down
2 changes: 2 additions & 0 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ let port = 3000;
if (process.env.HTTP_SERVER_PORT)
port = Number.parseInt(process.env.HTTP_SERVER_PORT, 10);

// biome-ignore lint: lint/correctness/noConsoleLog
console.info("Starting commercetools-mock on http://localhost:" + port);
instance.runServer(port);