Skip to content

Commit df6a89b

Browse files
committed
Nicer Docker instructions
1 parent 148c9b4 commit df6a89b

3 files changed

Lines changed: 92 additions & 20 deletions

File tree

Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,23 @@ COPY --from=builder /usr/src/hadrian/migrations_sqlx /app/migrations_sqlx
136136
# Create data directory for SQLite (will be overwritten by volume mount)
137137
RUN mkdir -p /app/data
138138

139+
# Create default config (can be overridden by mounting a volume at /app/config/hadrian.toml)
140+
RUN mkdir -p /app/config && cat > /app/config/hadrian.toml <<'EOF'
141+
[server]
142+
host = "0.0.0.0"
143+
port = 8080
144+
145+
[database]
146+
type = "sqlite"
147+
path = "/app/data/hadrian.db"
148+
149+
[cache]
150+
type = "memory"
151+
152+
[ui]
153+
enabled = true
154+
EOF
155+
139156
# Expose port
140157
EXPOSE 8080
141158

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ Download the latest binary from [GitHub Releases](https://github.com/ScriptSmith
4141

4242
Or use Docker:
4343

44+
```bash
45+
docker run -p 8080:8080 \
46+
-v hadrian-data:/app/data \
47+
ghcr.io/scriptsmith/hadrian
48+
```
49+
50+
To customize the configuration, create a `hadrian.toml` and mount it:
51+
4452
```bash
4553
cat <<'EOF' > hadrian.toml
4654
[server]

docs/components/quick-start-selector.tsx

Lines changed: 67 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,65 @@ function getDownloadUrl(os: OS, profile: Profile, libc: Libc): string {
133133
return `https://github.com/ScriptSmith/hadrian/releases/latest/download/hadrian-${target}-${profile}.${ext}`;
134134
}
135135

136+
const dockerSimpleCommand = [
137+
"docker run -p 8080:8080 \\",
138+
" -v hadrian-data:/app/data \\",
139+
" ghcr.io/scriptsmith/hadrian",
140+
].join("\n");
141+
142+
const dockerConfigCommand = [
143+
"cat <<'EOF' > hadrian.toml",
144+
"[server]",
145+
'host = "0.0.0.0"',
146+
"port = 8080",
147+
"",
148+
"[database]",
149+
'type = "sqlite"',
150+
'path = "/app/data/hadrian.db"',
151+
"",
152+
"[cache]",
153+
'type = "memory"',
154+
"",
155+
"[ui]",
156+
"enabled = true",
157+
"EOF",
158+
"",
159+
"docker run -p 8080:8080 \\",
160+
" -v ./hadrian.toml:/app/config/hadrian.toml:ro \\",
161+
" -v hadrian-data:/app/data \\",
162+
" ghcr.io/scriptsmith/hadrian",
163+
].join("\n");
164+
165+
function CommandBlock({ command, label }: { command: string; label?: string }) {
166+
const [copied, setCopied] = useState(false);
167+
const handleCopy = async () => {
168+
await navigator.clipboard.writeText(command);
169+
setCopied(true);
170+
setTimeout(() => setCopied(false), 2000);
171+
};
172+
return (
173+
<div>
174+
{label && (
175+
<div className="border-b border-fd-border px-4 py-2">
176+
<span className="text-xs font-medium text-fd-muted-foreground">{label}</span>
177+
</div>
178+
)}
179+
<div className="relative">
180+
<pre className="overflow-x-auto whitespace-pre-wrap break-all p-4 pr-12 text-sm">
181+
<code className="text-fd-foreground">{command}</code>
182+
</pre>
183+
<button
184+
onClick={handleCopy}
185+
className="absolute right-3 top-3 rounded-md p-1.5 text-fd-muted-foreground transition-colors hover:bg-fd-muted hover:text-fd-foreground"
186+
aria-label="Copy command"
187+
>
188+
{copied ? <Check className="h-4 w-4 text-green-500" /> : <Copy className="h-4 w-4" />}
189+
</button>
190+
</div>
191+
</div>
192+
);
193+
}
194+
136195
function ToggleGroup<T extends string>({
137196
options,
138197
value,
@@ -184,8 +243,6 @@ export function QuickStartSelector() {
184243
const [os, setOs] = useState<OS>("linux-x86_64");
185244
const [profile, setProfile] = useState<Profile>("standard");
186245
const [libc, setLibc] = useState<Libc>("musl");
187-
const [copied, setCopied] = useState(false);
188-
189246
const isLinux = os === "linux-x86_64" || os === "linux-arm64";
190247
const disabledProfiles = getDisabledProfiles(os, libc);
191248
const disabledLibcs = os === "linux-arm64" ? new Set<Libc>(["musl"]) : undefined;
@@ -213,12 +270,6 @@ export function QuickStartSelector() {
213270
const command = getInstallCommand(method, os, profile, libc);
214271
const downloadUrl = method === "binary" ? getDownloadUrl(os, profile, libc) : null;
215272

216-
const handleCopy = async () => {
217-
await navigator.clipboard.writeText(command);
218-
setCopied(true);
219-
setTimeout(() => setCopied(false), 2000);
220-
};
221-
222273
return (
223274
<div className="not-prose overflow-hidden rounded-lg border border-fd-border bg-fd-card">
224275
<div className="space-y-3 border-b border-fd-border bg-fd-muted/50 p-4">
@@ -334,20 +385,16 @@ export function QuickStartSelector() {
334385
allow="clipboard-read; clipboard-write"
335386
/>
336387
</div>
337-
) : (
388+
) : method === "docker" ? (
338389
<>
339-
<div className="relative">
340-
<pre className="overflow-x-auto whitespace-pre-wrap break-all p-4 pr-12 text-sm">
341-
<code className="text-fd-foreground">{command}</code>
342-
</pre>
343-
<button
344-
onClick={handleCopy}
345-
className="absolute right-3 top-3 rounded-md p-1.5 text-fd-muted-foreground transition-colors hover:bg-fd-muted hover:text-fd-foreground"
346-
aria-label="Copy command"
347-
>
348-
{copied ? <Check className="h-4 w-4 text-green-500" /> : <Copy className="h-4 w-4" />}
349-
</button>
390+
<CommandBlock command={dockerSimpleCommand} label="Run" />
391+
<div className="border-t border-fd-border">
392+
<CommandBlock command={dockerConfigCommand} label="With configuration" />
350393
</div>
394+
</>
395+
) : (
396+
<>
397+
<CommandBlock command={command} />
351398

352399
{downloadUrl && (
353400
<div className="border-t border-fd-border bg-fd-muted/30 px-4 py-3">

0 commit comments

Comments
 (0)