In this article, I would like to share basic Dockerfile for Node.js and TypeScript.
🤔 Dockerfile
Basic Express.js App
This Dockerfile
is for basic TypeScript Application with Node.js process(e.g. Express.js):
FROM node |
create-react-app Project
This Dockerfile
is for basic React.js Application with create-react-app:
## Build environment ## |
Nuxt.js with SSR
It is Dockerfile
for running Nuxt.js with SSR. It supports to minimize Docker image by “Docker Multi-stage build” and “node-prune”
FROM node:10.11.0-alpine as builder |
🚕 docker-compose
Basic docker-compose.yml
are as follows:
version: '3.5' |
Build the image and fire up the container:
docker-compose up -d --build |
🐯 .gitignore
To generate .gitignore
, please run the command:
gibo Ruby MacOS JetBrains Node >> .gitignore |
😸 .dockerignore
.dockerignore
contains:
node_modules |
🐮 [Appendix] Install node & yarn
If you want to install Node.js or yarn in Dockerfile, please write as follows:
# Install Node.js 8 |
🐹 Special Thanks
- https://medium.com/google-cloud/next-js-tutorial-deploy-to-docker-on-google-cloud-container-engine-6b0c19dd8ecb
- http://mherman.org/blog/2017/12/07/dockerizing-a-react-app/
- https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
- https://yarnpkg.com/lang/en/docs/install/#debian-stable
- https://github.com/apollographql/apollo-link/issues/513
- https://qiita.com/po3rin/items/0cef246755aa655ce53d
🖥 Recommended VPS Service
VULTR provides high performance cloud compute environment for you.
Vultr has 15 data-centers strategically placed around the globe, you can use a VPS with 512 MB memory for just $ 2.5 / month ($ 0.004 / hour).
In addition, Vultr is up to 4 times faster than the competition, so please check it => Check Benchmark Results!!