Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Node.js Web Development

You're reading from  Mastering Node.js Web Development

Product type Book
Published in Jun 2024
Publisher Packt
ISBN-13 9781804615072
Pages 778 pages
Edition 1st Edition
Languages
Author (1):
Adam Freeman Adam Freeman
Profile icon Adam Freeman
Toc

Table of Contents (26) Chapters close

1. Putting Node.js in Context
2. Getting Ready 3. Working with the Node.js Tools 4. JavaScript and TypeScript Primer 5. Understanding Node.js Concurrency 6. Handling HTTP Requests 7. Using Node.js Streams 8. Using Bundles and Content Security 9. Unit Testing and Debugging 10. Node.js in Detail
11. Creating the Example Project 12. Using HTML Templates 13. Handling Form Data 14. Using Databases 15. Using Sessions 16. Creating RESTful Web Services 17. Authenticating and Authorizing Requests 18. SportsStore
19. SportsStore: A Real Application 20. SportsStore: Navigation and Cart 21. SportsStore: Orders and Validation 22. SportsStore: Authentication 23. SportsStore: Administration 24. SportsStore: Deployment 25. Other Books You May Enjoy
26. Index

Creating the SportsStore Docker image

The next step is to prepare an image that contains Node.js, the SportsStore application, all of the packages that it relies on, the templates, and the configuration files. The first step is to create a file that tells Docker to ignore the node_modules folder, which causes a slowdown in the creation of an image because all of the folders are scanned. Create a file named .dockerignore in the sportsstore folder, with the contents shown in Listing 21.15.

Listing 21.15: The contents of the .dockerignore file in the sportsstore folder

node_modules

The next step is to create the file that tells Docker how to create the image. Add a file named Dockerfile (with no file extension) to the sportsstore folder with the content shown in Listing 21.16.

Listing 21.16: The contents of the Dockerfile file in the sportsstore folder

FROM node:20.10.0
RUN mkdir -p /usr/src/sportsstore
COPY dist /usr/src/sportsstore/dist
COPY templates /usr/src...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime