/hackathon-starter

A boilerplate for Node.js web applications

Primary LanguageJavaScriptMIT LicenseMIT

Documentation

Techniques inside the projects

  • Node.js: A JavaScript runtime built on Chrome's V8 JavaScript engine.
  • Express.js: A minimal and flexible Node.js web application framework.
  • K3s: A lightweight Kubernetes distribution designed for edge computing.
  • Containerd: An industry-standard core container runtime.
  • nerdctl: A Docker-compatible CLI for containerd.
  • GitHub Actions: A CI/CD tool that automates software workflows.
  • Helm: A package manager for Kubernetes.

Setup Instructions

Development Environment

  1. Clone the Repository:
git clone <repository-url>
cd <repository-directory>
  1. Install Dependencies:
npm install
  1. Start the Development Server:
npm run dev

Production Environment

  1. Clone the Repository:
git clone <repository-url>
cd <repository-directory>
  1. Checkout the Production Branch:
git checkout production/tags
  1. Change config.yaml & .env files
  • Update the config.yaml file with the required configuration.
  • Create a .env file and set the required environment variables.
  1. Run deploy.sh Script:
./deploy.sh

Configuration Options

  • environment: Specifies the environment in which the application is running. Common values are dev for development, staging for pre-production, and prod for production. In this case, it's set to dev.

  • app_name: The name of the application. This is often used for logging, monitoring, and display purposes. Here, it's set to hackathon-starter.

  • app_url: The URL where the application is hosted. This is useful for generating links or for use in API calls. The provided URL is https://1devops.io.

  • images_registry: The container image registry where your Docker images are stored. In this case, it's set to ghcr.io, which stands for GitHub Container Registry.

  • images_namespace: The namespace within the image registry. This helps in organizing and managing images. Here, it's set to googlesky.

  • images_tag: The tag used for the Docker images. Tags are used to version images. In this case, it's set to commit_sha, which likely means the tag will be the commit SHA of the codebase.

  • app_config: The path to the application's configuration file. This file typically contains environment variables and other settings. Here, it's set to .env.

  • kubernetes_namespace: The Kubernetes namespace where the application will be deployed. Namespaces in Kubernetes are used to divide cluster resources between multiple users. In this case, it's set to hackathon-starter.

Troubleshooting Guide

  • Server Not Starting:

    • Ensure all dependencies are installed: npm install.
    • Check if the correct environment variables are set.
    • Verify the port is not in use by another application.
  • Database Connection Issues:

    • Confirm the DATABASE_URL is correctly set.
    • Ensure the database server is running and accessible.
  • Build Failures:

    • Check for syntax errors or missing dependencies.
    • Ensure all required environment variables are set before building.

Security Considerations

  • Environment Variables:

    • Never hardcode sensitive information in the codebase. Use environment variables for configuration.
  • Dependencies:

    • Regularly update dependencies to mitigate known vulnerabilities.
    • Use tools like npm audit to check for security issues in dependencies.
  • Access Control:

    • Implement proper authentication and authorization mechanisms.
    • Ensure sensitive routes and data are protected.
  • Data Encryption:

    • Use HTTPS to encrypt data in transit.
    • Encrypt sensitive data at rest using appropriate encryption techniques.