Skip to content

Commit 01353b6

Browse files
authored
feat(docs): add dynamic Docker installation (#199)
1 parent a6a93b7 commit 01353b6

File tree

2 files changed

+57
-21
lines changed

2 files changed

+57
-21
lines changed

docs/getting-started/installation/docker.mdx

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { DockerInstallSnippet } from '../../../src/components/pages/installation/docker/dynamic-docker-install'
2+
13
# Docker
24
Docker is our recommended installation method for beginners and professionals.
35
It is easy to use, ships with all dependencies inside a single container and is easy to use and maintain.
@@ -13,27 +15,8 @@ We recommend [NetworkChuck's Docker Containers 101](https://www.youtube.com/watc
1315

1416
### Installation
1517

16-
To install Homarr using Docker Compose, simply create a file called ``docker-compose.yml`` and paste the following code into it.
17-
18-
```yml title="docker-compose.yml"
19-
#---------------------------------------------------------------------#
20-
# Homarr - A simple, yet powerful dashboard for your server. #
21-
#---------------------------------------------------------------------#
22-
services:
23-
homarr:
24-
container_name: homarr
25-
image: ghcr.io/homarr-labs/homarr:latest
26-
restart: unless-stopped
27-
volumes:
28-
- /var/run/docker.sock:/var/run/docker.sock # Optional, only if you want docker integration
29-
- ./homarr/appdata:/appdata
30-
environment:
31-
- SECRET_ENCRYPTION_KEY=your_64_character_hex_string # <--- can be generated with `openssl rand -hex 32`
32-
ports:
33-
- '7575:7575'
34-
```
35-
36-
Then, run ``docker compose up -d`` in the same directory. This will start the Homarr container in the background.
18+
<DockerInstallSnippet data-visual-test="blackout"/>
19+
Finally, run ``docker compose up -d`` in the same directory. This will start the Homarr container in the background.
3720

3821
:::caution
3922

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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

Comments
 (0)