Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

2.0 KB
Raw Blame
"use client";

import type React from "react";
import { IconRefresh } from "@tabler/icons-react";
import { DynamicCodeBlock } from "fumadocs-ui/components/dynamic-codeblock";
import { useEffect, useState } from "react";

import Admonition from "@/components/mdx/admonition";
import { Button } from "@/components/ui/button";

const generateRandomHex = (length = 64): string => {
  const array = new Uint8Array(length / 2);
  crypto.getRandomValues(array);
  return Array.from(array, (byte) => byte.toString(16).padStart(2, "0")).join("");
};

export const DockerInstallSnippet: React.FC = () => {
  const [randomHex, setRandomHex] = useState<string>("");
  const generateNewHex = () => {
    setRandomHex(generateRandomHex());
  };

  useEffect(() => {
    generateNewHex();
  }, []);

  return (
    <div>
      <p>
        First, create a <code>docker-compose.yml</code> file with the following content:
      </p>
      <DynamicCodeBlock
        lang="yaml"
        code={`#---------------------------------------------------------------------#
#     Homarr - A simple, yet powerful dashboard for your server.      #
#---------------------------------------------------------------------#
services:
  homarr:
    container_name: homarr
    image: ghcr.io/homarr-labs/homarr:latest
    restart: unless-stopped
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock # Optional, only if you want docker integration
      - ./homarr/appdata:/appdata
    environment:
      - SECRET_ENCRYPTION_KEY=${randomHex}
    ports:
      - '7575:7575'
			`}
      />
      <Admonition type="info" title="Encryption key">
        <p>
          The <code>SECRET_ENCRYPTION_KEY</code> above is randomly generated by your browser. You can also generate one
          with <code>openssl rand -hex 32</code>.
        </p>
        <Button type="button" variant="outline" size="sm" onClick={generateNewHex}>
          <IconRefresh aria-hidden="true" />
          Refresh key
        </Button>
      </Admonition>
    </div>
  );
};