|
| 1 | +import type React from 'react'; |
| 2 | +import CodeBlock from '@theme/CodeBlock'; |
| 3 | +import Admonition from '@theme/Admonition'; |
| 4 | +import { useEffect, useState } from 'react'; |
| 5 | + |
| 6 | +const generateRandomHex = (length = 64): string => { |
| 7 | + const array = new Uint8Array(length / 2); |
| 8 | + crypto.getRandomValues(array); |
| 9 | + return Array.from(array, (byte) => byte.toString(16).padStart(2, '0')).join(''); |
| 10 | +}; |
| 11 | + |
| 12 | +export const DockerInstallSnippet: React.FC = () => { |
| 13 | + const [randomHex, setRandomHex] = useState<string>(''); |
| 14 | + const generateNewHex = () => { |
| 15 | + setRandomHex(generateRandomHex()); |
| 16 | + }; |
| 17 | + |
| 18 | + useEffect(() => { |
| 19 | + generateNewHex(); |
| 20 | + }, []); |
| 21 | + |
| 22 | + return ( |
| 23 | + <div> |
| 24 | + <p> |
| 25 | + First, create a <code>docker-compose.yml</code> file with the following content: |
| 26 | + </p> |
| 27 | + <CodeBlock language="yml" title="docker-compose.yml"> |
| 28 | + {`#---------------------------------------------------------------------# |
| 29 | +# Homarr - A simple, yet powerful dashboard for your server. # |
| 30 | +#---------------------------------------------------------------------# |
| 31 | +services: |
| 32 | + homarr: |
| 33 | + container_name: homarr |
| 34 | + image: ghcr.io/homarr-labs/homarr:latest |
| 35 | + restart: unless-stopped |
| 36 | + volumes: |
| 37 | + - /var/run/docker.sock:/var/run/docker.sock # Optional, only if you want docker integration |
| 38 | + - ./homarr/appdata:/appdata |
| 39 | + environment: |
| 40 | + - SECRET_ENCRYPTION_KEY=${randomHex} |
| 41 | + ports: |
| 42 | + - '7575:7575' |
| 43 | + `} |
| 44 | + </CodeBlock> |
| 45 | + <Admonition type="info"> |
| 46 | + Key provided above for the <code>SECRET_ENCRYPTION_KEY</code> environment variable is |
| 47 | + randomly generated using your browser cryotography API. It will be different every time You |
| 48 | + can generate one yourself using <code>openssl rand -hex 32</code> |
| 49 | + <button className='px-1 mx-4' onClick={generateNewHex}>Refresh key</button> |
| 50 | + </Admonition> |
| 51 | + </div> |
| 52 | + ); |
| 53 | +}; |
0 commit comments