Henry S. Coelho

Two-stage build PureScript Dockerfile

Example of a Dockerfile with a two-stage build for PureScript projects.

The first stage install the NPM packages and uses Spago to bundle the PureScript source code into a single index.js file.

The second stage pulls the node_modules dependencies and index.js file from the builder stage, and executes the index.js file with Node.


  "dependencies": { },
  "devDependencies": {
    "purescript": "0.14.4",
    "spago": "0.20.3"


FROM node:16.10 AS builder


COPY . .
RUN npm install
RUN npx spago bundle-app


FROM node:16.10-alpine3.14


COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/index.js .

CMD ["node", "index.js"]