From f1421d707881df1a3bbc046dd3277592829b95a7 Mon Sep 17 00:00:00 2001 From: "courtmanr@gmail.com" Date: Sun, 20 Apr 2025 18:17:51 +0100 Subject: [PATCH] feat: Add Dockerfile and Docker Compose setup --- Dockerfile | 31 +++++++++++++++++++++++++ README.md | 58 +++++++++++++++++++++++++++++----------------- docker-compose.yml | 24 +++++++++++++++++++ 3 files changed, 92 insertions(+), 21 deletions(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..6c31a1ccf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +# Use an official Node runtime as a parent image +# Choose a version compatible with your application (e.g., LTS version like 18 or 20) +FROM node:18-alpine + +# Set the working directory in the container +WORKDIR /usr/src/app + +# Copy package.json and package-lock.json for root dependencies +COPY package*.json ./ + +# Install root dependencies +RUN npm install + +# Copy server package.json and package-lock.json +COPY server/package*.json ./server/ + +# Install server dependencies +RUN cd server && npm install + +# Copy the rest of the application code +# Copy server code first +COPY server/ ./server/ +# Copy public directory if it's used by the server (adjust if needed) +COPY public/ ./public/ + +# Application listens on port 7655 by default (as per .env.example) +EXPOSE 7655 + +# Define the command to run the app using the start script from root package.json +# This script should handle changing into the server directory +CMD [ "npm", "run", "start" ] \ No newline at end of file diff --git a/README.md b/README.md index d522cee54..9e1163e8f 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ A lightweight monitoring application for Proxmox VE that displays real-time stat - [Required Permissions](#required-permissions) - [Installation](#-installation) - [Running the Application](#-running-the-application) +- [Running the Application (Node.js)](#️-running-the-application-nodejs) +- [Running with Docker Compose](#-running-with-docker-compose) - [Features](#-features) - [System Requirements](#-system-requirements) - [Contributing](#-contributing) @@ -95,7 +97,9 @@ npm install cd .. ``` -## ▶️ Running the Application +## ▶️ Running the Application (Node.js) + +These instructions are for running the application directly using Node.js. ### Development Mode @@ -115,6 +119,35 @@ npm run start ``` This command starts the server using `node`. Access the application via the configured host and port. +## 🐳 Running with Docker Compose + +Using Docker Compose is the recommended way to run the application in a containerized environment. + +**Prerequisites:** +- Docker ([Install Docker](https://docs.docker.com/engine/install/)) +- Docker Compose ([Install Docker Compose](https://docs.docker.com/compose/install/)) + +**Steps:** + +1. **Configure Environment:** Ensure you have created and configured your `server/.env` file as described in the [Environment Variables](#environment-variables) section above. + +2. **Build and Run:** Navigate to the project root directory in your terminal and run: + ```bash + docker compose up --build -d + ``` + - `--build`: Builds the Docker image based on the `Dockerfile` if it doesn't exist or if the `Dockerfile` has changed. + - `-d`: Runs the container in detached mode (in the background). + +3. **Access:** The application should now be running. Access it via `http://:7655` (or the host port you mapped in `docker-compose.yml`). + +**Stopping the Application:** + +To stop the container(s) defined in the `docker-compose.yml` file, run: + +```bash +docker compose down +``` + ## ✨ Features - Lightweight monitoring for Proxmox VE nodes. @@ -123,30 +156,13 @@ This command starts the server using `node`. Access the application via the conf ## 💻 System Requirements -- **Node.js**: Version 16.x or higher recommended (check `package.json` engines for specifics). +- **Node.js** (for local development/running): Version 16.x or higher recommended. +- **Docker & Docker Compose** (for containerized deployment): Recent versions recommended. - **Network**: Connectivity between the Pulse server and your Proxmox server(s). -- **Proxmox**: A running Proxmox VE instance with API access enabled. ## 👥 Contributing Contributions are welcome! Please follow standard fork-and-pull-request workflow. Refer to the main repository's contributing guidelines if available. 1. **Fork the repository** -2. **Create a feature branch**: `git checkout -b feature/your-feature` -3. **Commit your changes**: `git commit -m 'Add your feature'` -4. **Push to the branch**: `git push origin feature/your-feature` -5. **Open a Pull Request** - -## 📄 License - -Specify the license under which this project is distributed (e.g., MIT License). *(Consider adding the actual license file if missing)* - -## Trademark Notice - -Proxmox® and Proxmox VE® are registered trademarks of Proxmox Server Solutions GmbH. Pulse for Proxmox VE is an independent project and is not affiliated with, endorsed by, or sponsored by Proxmox Server Solutions GmbH. - -## ❤️ Support - -If you find Pulse helpful, please consider supporting its development through Ko-fi. Your support helps keep this project maintained and free for everyone! - -[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/rcourtman) \ No newline at end of file +2. **Create a feature branch**: ` \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..72a80a604 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,24 @@ +version: '3.8' + +services: + pulse-server: + build: + context: . + dockerfile: Dockerfile + container_name: pulse_server_simplified + restart: unless-stopped + ports: + # Map container port 7655 to host port 7655 + # You can change the host port (left side) if 7655 is already in use on your host + - "7655:7655" + env_file: + # Load environment variables from the .env file located in the server directory + - ./server/.env + # Optional: Define networks if needed, otherwise uses default bridge network + # networks: + # - pulse_network + +# Optional: Define a network +# networks: +# pulse_network: +# driver: bridge \ No newline at end of file