Dockerfile
1,086 bytes
| 1 | # syntax=docker/dockerfile:1 |
|---|---|
| 2 | |
| 3 | # Node 24 because the app stores everything through `node:sqlite`, which is |
| 4 | # built in from 22 and stable from 24. That is also why there is no build stage |
| 5 | # and no compiler in this image: every dependency is plain JavaScript, so there |
| 6 | # is no native module to compile and nothing to bundle. |
| 7 | FROM node:24-bookworm-slim |
| 8 | WORKDIR /app |
| 9 | |
| 10 | ENV NODE_ENV=production |
| 11 | ENV PORT=3000 |
| 12 | |
| 13 | COPY package*.json ./ |
| 14 | RUN npm ci --omit=dev |
| 15 | |
| 16 | COPY src ./src |
| 17 | |
| 18 | # The SQLite file lives in a named volume mounted here. It has to belong to the |
| 19 | # `node` user, because the container does not run as root. |
| 20 | RUN mkdir -p /app/data && chown -R node:node /app/data |
| 21 | |
| 22 | USER node |
| 23 | |
| 24 | EXPOSE 3000 |
| 25 | |
| 26 | # Node 24 has global fetch, so the slim image needs no curl for this. The root |
| 27 | # path renders the sign-in page and touches the database, so a 200 here means |
| 28 | # both the server and its storage are alive. |
| 29 | HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \ |
| 30 | CMD node -e "fetch('http://127.0.0.1:3000/').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))" |
| 31 | |
| 32 | CMD ["npm", "start"] |
| 33 | |