Skip to content

Commit

Permalink
Try docker
Browse files Browse the repository at this point in the history
Refs #51
  • Loading branch information
sverhoeven committed Oct 14, 2024
1 parent fd07c6a commit 3cf223c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.git
.gitignore
*.md
dist
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"@biomejs/biome": "1.8.3",
"turbo": "^2.0.6"
},
"packageManager": "pnpm@8.15.6",
"packageManager": "pnpm@9.12.1",
"name": "class-web"
}
19 changes: 19 additions & 0 deletions packages/class/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# From https://pnpm.io/docker#example-1-build-a-bundle-in-a-docker-container
# Build with
# docker build -t class -f packages/class/Dockerfile .
# Run with
# docker run --rm -v $PWD:$PWD class $PWD/config.json
FROM node:22-slim
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
COPY . /app
WORKDIR /app

RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile

# Create a non-root user and switch to it
RUN useradd --create-home --shell /bin/bash appuser
USER appuser
WORKDIR /app/packages/class/src
ENTRYPOINT ["node", "--experimental-strip-types", "--experimental-default-type=module", "cli.ts"]
3 changes: 2 additions & 1 deletion packages/class/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"scripts": {
"test": "tsx --test src/*.test.ts",
"typecheck": "tsc --noEmit",
"json2ts": "json2ts src/config.json src/config.ts"
"json2ts": "json2ts src/config.json src/config.ts",
"build": "tsc --outDir dist --module nodenext --target esnext --moduleResolution nodenext --declarationMap false --declaration false"
},
"devDependencies": {
"@types/node": "^20.13.1",
Expand Down
4 changes: 3 additions & 1 deletion packages/class/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ function main() {
}
}

main();
if (require.main === module) {
main();
}

0 comments on commit 3cf223c

Please sign in to comment.