Skip to content

Instantly share code, notes, and snippets.

@kandros
Created April 21, 2021 22:37
Show Gist options
  • Save kandros/736534120ddad4a34dc0be5019d60a43 to your computer and use it in GitHub Desktop.
Save kandros/736534120ddad4a34dc0be5019d60a43 to your computer and use it in GitHub Desktop.
Fastify TypeScript Dockerfile
FROM node:14-alpine as builder
WORKDIR /app
ENV NODE_ENV=production
COPY package.json package-lock.json tsconfig.json ./
COPY src ./src
RUN npm ci --also=dev
RUN npm run build:ts
RUN npm prune --production
FROM node:14-alpine
WORKDIR /app
ENV NODE_ENV=production
COPY --from=builder /app/package.json package.json
COPY --from=builder /app/node_modules node_modules
COPY --from=builder /app/dist dist/
USER node
CMD ["npm", "run", "prod"]
{
"name": "fastify-demo",
"version": "1.0.0",
"description": "",
"main": "app.ts",
"directories": {
"test": "test"
},
"scripts": {
"prod": "fastify start -l info dist/app.js",
"test": "npm run build:ts && tsc -p test/tsconfig.test.json && tap test/**/*.test.ts",
"start": "npm run build:ts && fastify start -l info dist/app.js",
"build:ts": "tsc",
"dev": "tsc && concurrently -k -p \"[{name}]\" -n \"TypeScript,App\" -c \"yellow.bold,cyan.bold\" \"tsc -w\" \"fastify start -w -l info -P dist/app.js\""
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"fastify": "^3.0.0",
"fastify-autoload": "^3.3.1",
"fastify-cli": "^2.9.1",
"fastify-plugin": "^3.0.0",
"fastify-sensible": "^3.1.0"
},
"devDependencies": {
"@types/node": "^14.14.14",
"@types/tap": "^14.10.1",
"concurrently": "^6.0.0",
"fastify-tsconfig": "^1.0.1",
"tap": "^14.11.0",
"typescript": "^4.1.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment