![]() ![]() ![]() The resulting container image is approximately 831 MB in size. With these files in place, build a container image using the Podman (or Docker) CLI: # Change this as necessary for your own project(s) It’s used to avoid copying the specified files into a container image: gitignore, but is respected by tools like Podman and Docker. dockerignore file in the root of the repository. # These parameters can be overridden if you’d likeĬMD # Launch the container by passing these parameters to the entrypoint # Set the fastify-cli binary as the entrypointĮNTRYPOINT # Configure fastify behaviour, and NODE_ENV # Install dependencies and devDependencies # Copy in package.json and package-lock.json # Change into the project directory and generate a package-lock.jsonĬreate a Containerfile in the new nodejs-ts-basic project directory with the following contents:įROM /ubi8/nodejs-18 To get started, generate a new Fastify project that uses TypeScript using the Fastify CLI: ![]() This application will use the Fastify framework and TypeScript, but it’s worth noting that this guide is applicable to any Node.js web framework. Let’s use that as a template to create a container image for a Node.js application. The Node.js documentation provides a great overview of how to configure a Containerfile (also known as a Dockerfile) for a basic Node.js application. Building a Node.js application container image Substitute docker in place of podman in commands if you’re using Docker instead of Podman. Podman is the container engine used for the examples in this post. You’ll need Node.js 18 and either Docker or Podman installed to follow along. Note: All of the examples and code used in this post can be found in this repository on GitHub. Figure 1: Image sizes resulting from a various build approaches using Red Hat's Universal Base Images for Node.js. ![]()
0 Comments
Leave a Reply. |