-
Notifications
You must be signed in to change notification settings - Fork 61
feat(docs): add dynamic Docker installation #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/components/pages/installation/docker/dynamic-docker-install.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import type React from 'react'; | ||
| import CodeBlock from '@theme/CodeBlock'; | ||
| import Admonition from '@theme/Admonition'; | ||
| import { useEffect, useState } from 'react'; | ||
|
|
||
| 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> | ||
| <CodeBlock language="yml" title="docker-compose.yml"> | ||
| {`#---------------------------------------------------------------------# | ||
| # 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' | ||
| `} | ||
| </CodeBlock> | ||
| <Admonition type="info"> | ||
| Key provided above for the <code>SECRET_ENCRYPTION_KEY</code> environment variable is | ||
| randomly generated using your browser cryotography API. It will be different every time You | ||
| can generate one yourself using <code>openssl rand -hex 32</code> | ||
| <button className='px-1 mx-4' onClick={generateNewHex}>Refresh key</button> | ||
| </Admonition> | ||
| </div> | ||
| ); | ||
| }; | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.