A simple, interactive Node.js web application demonstrating how to use Podman to containerize and deploy apps in a secure, scalable way.
This project is an open-source example of how to containerize and deploy a basic web application using Podman, a daemonless container engine. The app provides users with an interactive experience, including the ability to toggle dark and light modes and submit their names to get personalized greetings. This is a simple example of using modern web technologies inside containers to create engaging applications.
The app has been built using Node.js and Express.js and includes:
- Dynamic feedback on user interactions.
- A theme toggle feature to switch between dark and light modes.
- A secure, production-ready Dockerfile for containerization.
- Deployment with Podman for enhanced security and ease of use.
- Exclusion of unnecessary files from the image build using
.dockerignore
.
- Features
- Prerequisites
- Installation
- Podman Setup
- Running the App
- Building the Docker Image
- Running the Docker Image
- Contributing
- License
- Interactive Web App: The app allows users to input their names and receive personalized greetings.
- Theme Switching: Users can toggle between dark and light modes for the interface.
- Loading Animation: Provides a dynamic loading animation when the form is submitted.
- Secure Containerization: The project includes a secure Dockerfile that adheres to container security best practices using Podman.
- Open Source: Contributions are welcome to extend the project further.
Before you begin, ensure you have the following:
- Node.js (v14 or higher) installed on your system. You can download it here.
- Podman installed. Instructions can be found here.
- Basic knowledge of Docker or Podman.
- A GitHub or GitLab account to contribute to the project.
To get started with this project, you need to clone the repository and install the required dependencies.
- Clone the repository:
git clone https://github.com/your-username/podman-tutorial-app.git
cd podman-tutorial-app
- Install dependencies:
npm install
To run the application within a Podman container, you need to ensure that Podman is installed and set up correctly on your machine.
-
Install Podman:
- You can install Podman using a package manager like winget or brew.
- Alternatively, follow the instructions for your operating system here.
-
Initialize and start Podman Machine (if on MacOS or Windows):
podman machine init
podman machine start
- Verify Podman installation:
podman --version
Once you have installed the dependencies, you can run the app locally to verify everything works before containerizing it.
- Start the app:
node app.js
- Access the app:
Open a browser and navigate to
http://localhost:3000
. You should see the welcome page with the interactive features.
We will use Podman to build the Docker image for this application. Podman is Docker-compatible and provides additional security by not requiring a root daemon.
- Build the image:
podman build -t podman-tutorial-app .
This command builds the image and tags it as podman-tutorial-app
.
After building the image, you can run it in a Podman container.
- Run the container:
podman run -d -p 3000:3000 --name podman-tutorial-app podman-tutorial-app
This command runs the container in detached mode (-d
) and maps port 3000
on the host to port 3000
in the container.
- Access the app:
- Open a browser and navigate to
http://localhost:3000
to view the running app inside the Podman container.
- Open a browser and navigate to
If you're making changes to the project and testing them, the following workflow will help you work efficiently with Podman.
- Stop and remove the running container:
podman stop podman-tutorial-app
podman rm podman-tutorial-app
- Rebuild the image (after making code changes):
podman build -t podman-tutorial-app .
- Re-run the container:
podman run -d -p 3000:3000 --name podman-tutorial-app podman-tutorial-app
We welcome contributions to improve this project. Here are a few ways you can help:
- Reporting Bugs: If you find any bugs, please create an issue in this repository.
- Adding Features: Want to add a feature? Fork the repo, make the changes, and create a pull request (PR).
- Documentation Improvements: Help us improve the README or other documentation by submitting PRs.
- Fork this repository.
- Create a branch with a descriptive name.
- Make your changes in your branch.
- Push the changes to your forked repo.
- Open a pull request on the main repo.
This project is licensed under the MIT License. You’re free to use, modify, and distribute this software. See the LICENSE
file for more details.
If you have any questions or need further assistance, feel free to open an issue on the GitHub repository or contact us via the project's discussion board.