Skip to content

Commit 578ac25

Browse files
committed
sketch dockerfile
1 parent 3835fc5 commit 578ac25

3 files changed

Lines changed: 40 additions & 2 deletions

File tree

cli/Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Generates a container to run the compiled node.js scripts in
2+
# -> Runs as the "node" user so any extra folders will need to be chown-ed
3+
# -> Uses a multi-stage to compile JavaScript and produce a slim image
4+
5+
# [0] A common base for both stages
6+
FROM node:22-alpine AS base
7+
WORKDIR /app
8+
RUN chown -R node:node /app
9+
USER node
10+
COPY --chown=node ["package*.json", "tsconfig.json", "/app/"]
11+
COPY --chown=node ["cli/package.json", "/app/cli/"]
12+
13+
# [1] A builder to install modules and run a build
14+
FROM base AS builder
15+
ENV NODE_ENV=development
16+
RUN npm ci
17+
COPY --chown=node ["cli", "/app/cli"]
18+
RUN npm run --workspace=cli build
19+
RUN wget -O- https://github.com/protomaps/go-pmtiles/releases/download/v1.28.0/go-pmtiles_1.28.0_Linux_x86_64.tar.gz | tar -xzC /tmp
20+
# && npm run --workspace=cli test \
21+
22+
# [2] From the base again, install production dependencies and copy compiled code
23+
FROM base AS dist
24+
ENV NODE_ENV=production
25+
RUN npm ci -w cli && npm cache clean --force
26+
COPY --from=builder --chown=node ["/app/cli/dist/", "/app/cli/"]
27+
COPY --from=builder --chown=node ["/tmp/pmtiles", "/usr/local/bin/pmtiles"]
28+
WORKDIR /app
29+
ENTRYPOINT ["node", "cli/main.js"]
30+
CMD ["serve"]

cli/tsconfig.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"include": ["."],
4+
"exclude": ["node_modules", "dist"],
5+
"compilerOptions": {
6+
"outDir": "dist"
7+
}
8+
}

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
"noFallthroughCasesInSwitch": true,
2222
"noUncheckedSideEffectImports": true,
2323
"forceConsistentCasingInFileNames": true,
24-
"erasableSyntaxOnly": true,
25-
"verbatimModuleSyntax": true
24+
"erasableSyntaxOnly": true
25+
// "verbatimModuleSyntax": true
2626
},
2727
"include": ["cli"],
2828
"exclude": ["node_modules"]

0 commit comments

Comments
 (0)