typescript-docker-multi-stage-build
typescript-docker-multi-stage-build copied to clipboard
🐳 This repository shows how to build a Docker image for a Node.js + TypeScript app with the Docker multi-stage feature
typescript-docker-multi-stage-build
The purpose of this repository is to show how you can build a Docker image for a Node.js + TypeScript app with the Docker multi-stage feature, available since version 17.05.
Run the app
- Install dependencies:
npm install - Start the app:
npm start - Call the greeting endpoint:
curl http://localhost:3000/greeting\?name\=John
{"id":"76ac792c-c1a9-4fc5-ba75-39652a06b381","message":"Hello, John!"}
Build the Docker image
To build the Docker image, use the docker build command:
docker build . -t greeting-service:latest
To stop the build on a specific stage, use the target option:
docker build --target builder -t greeting-service:latest .
Run the Docker image
To run the Docker image, use the docker run command:
docker run -p 3000:3000 --rm greeting-service:latest
Then, you can invoke the greeting service running in a Docker container with:
curl http://localhost:3000/greeting\?name\=Docker
{"id":"7af0385b-99dc-4d47-a423-f6ab18ea7f1c","message":"Hello, Docker!"}
Contributing
Contributions are welcome!
Submit an issue or a pull request if you want to contribute some code.
License
MIT