Skip to content

🐳 This repository shows how to build a Docker image for a Node.js + TypeScript app with the Docker multi-stage feature

License

Notifications You must be signed in to change notification settings

kevinpollet/typescript-docker-multi-stage-build

Repository files navigation

typescript-docker-multi-stage-build

Build Status License

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

  1. Install dependencies: npm install
  2. Start the app: npm start
  3. 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

About

🐳 This repository shows how to build a Docker image for a Node.js + TypeScript app with the Docker multi-stage feature

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published