Skip to content

Commit 2a29a8f

Browse files
committed
docs(docker): fix GPG keyring compatibility and improve documentation
- Use ~/.cryptic-gpg instead of ~/.gnupg to avoid keyboxd daemon conflicts on modern macOS/Linux (GPG 2.4+) - Add two methods for running client: env vars vs command-line flags - Document build context requirement (parent directory with cryptic-tui) - Add troubleshooting for common COPY failed build errors - Simplify server setup with dedicated ~/.cryptic_server directory - Remove redundant admin bootstrap section (covered in quick start) Also fix entrypoint script to execute custom commands directly without banner output, improving onboarding and console mode usability.
1 parent 78aadc0 commit 2a29a8f

File tree

2 files changed

+75
-90
lines changed

2 files changed

+75
-90
lines changed

docs/DOCKER.md

Lines changed: 48 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,51 @@ This guide explains how to deploy the Cryptic client and or the
88

99
**Run the latest client image:**
1010

11-
[Demo](https://youtu.be/acNHqzHia3o?si=_4mQuE4KQooxb1UM)
11+
[Video Demo](https://youtu.be/acNHqzHia3o?si=_4mQuE4KQooxb1UM)
1212

1313
```bash
1414
# Get the latest Client docker image
1515
docker pull ghcr.io/etnt/cryptic-tui:latest
1616

17+
# Create a separate GPG directory for Docker (avoids conflicts with host's keyboxd)
18+
mkdir -p ~/.cryptic-gpg
19+
1720
# Run the Cryptic Onboarding script
18-
# 1. Generate a GPG key pair (or use existing one from ~/.gnupg)
21+
# 1. Generate a GPG key pair (stored in ~/.cryptic-gpg on host)
1922
# 2. Export the generated key
2023
# 3. Send the key and fingerprint to the admin
21-
# 4. WAIT! - Do not exit the onboard script (the container will be gone)
24+
# 4. WAIT! - Do not exit the onboard script until certificate is received
2225
# 5. When admin has registered your key: Request a TLS certificate from server
2326
# If your server is running on localhost on your Host machine, specify:
2427
# cryptic-server as your server address (see the: `--add-host` below)
2528
# 6. Exit the onboard script
2629
# You should now see your certificates at ~/.cryptic/<user>/cryptic-server_<port>
2730
#
28-
# NOTE: ~/.gnupg is mounted so your GPG keyring is shared with the container.
29-
# This is required for automatic certificate renewal.
31+
# NOTE: We use ~/.cryptic-gpg instead of ~/.gnupg because modern macOS/Linux
32+
# GPG uses keyboxd daemon which doesn't work across container boundaries.
33+
# The container manages its own GPG keyring that persists on the host.
3034
docker run -it --rm --name cryptic-client \
3135
-v ~/.cryptic:/home/cryptic/.cryptic \
32-
-v ~/.gnupg:/home/cryptic/.gnupg \
36+
-v ~/.cryptic-gpg:/home/cryptic/.gnupg \
3337
--add-host=cryptic-server:host-gateway \
3438
ghcr.io/etnt/cryptic-tui:latest sh -c 'cryptic --onboard'
3539

3640
# Start the Cryptic client with your username (e.g `franz`)
3741
# You'll be prompted for a Passphrase which is used to encrypt your local DB
42+
43+
# Method 1: Using environment variables
44+
docker run -it --rm --name cryptic-client \
45+
-v ~/.cryptic:/home/cryptic/.cryptic \
46+
-v ~/.cryptic-gpg:/home/cryptic/.gnupg \
47+
--add-host=cryptic-server:host-gateway \
48+
-e CRYPTIC_USERNAME=franz \
49+
-e CRYPTIC_ENABLE_DB=true \
50+
ghcr.io/etnt/cryptic-tui:latest
51+
52+
# Method 2: Using command-line flags
3853
docker run -it --rm --name cryptic-client \
3954
-v ~/.cryptic:/home/cryptic/.cryptic \
40-
-v ~/.gnupg:/home/cryptic/.gnupg \
55+
-v ~/.cryptic-gpg:/home/cryptic/.gnupg \
4156
--add-host=cryptic-server:host-gateway \
4257
ghcr.io/etnt/cryptic-tui:latest sh -c 'cryptic -u franz --enable-db --tui'
4358
```
@@ -48,6 +63,10 @@ docker run -it --rm --name cryptic-client \
4863
# Get the latest Server docker image
4964
docker pull ghcr.io/etnt/cryptic:latest
5065

66+
# Create a directory for storing the Cryptic server data
67+
mkdir ~/.cryptic_server
68+
cd ~/.cryptic_server
69+
5170
# Setup the server certificates (one-time step)
5271
# Creates ca.crt, ca.key, server.crt, server.key in ./priv/ssl/
5372
mkdir -p priv/ssl priv/ca/bootstrap
@@ -65,6 +84,7 @@ gpg --armor --export alice@cryptic.local > priv/ca/bootstrap/alice.gpg
6584

6685
# Run the server (requires certificates in ./priv/ssl/)
6786
# Here we show how to expose port 9898 instead of the default (8443)
87+
# For debug log output, add: -e CRYPTIC_DEBUG=true
6888
mkdir -p logs data/ca/bootstrap
6989
docker run -d \
7090
--name cryptic-server \
@@ -84,61 +104,10 @@ docker run -d \
84104
# Check server logs
85105
docker logs -f cryptic-server
86106

87-
# Stop the server
107+
# Stop the server and remove the container
88108
docker stop cryptic-server && docker rm cryptic-server
89109
```
90110

91-
### First Admin Bootstrap
92-
93-
The admin bootstrap happens **before** starting the server:
94-
95-
1. **Generate a GPG key** on your host machine (if you don't have one):
96-
```bash
97-
gpg --quick-generate-key 'alice <alice@cryptic.local>' rsa4096
98-
```
99-
100-
2. **Export the public key** to the bootstrap directory:
101-
```bash
102-
gpg --armor --export alice@cryptic.local > priv/ca/bootstrap/alice.gpg
103-
```
104-
105-
3. **Start the server** - it will read the bootstrap directory and register the admin.
106-
107-
**Now the admin can onboard** from their client machine:
108-
109-
```bash
110-
docker run -it --rm --name cryptic-client \
111-
-v ~/.cryptic:/home/cryptic/.cryptic \
112-
-v ~/.gnupg:/home/cryptic/.gnupg \
113-
--add-host=cryptic-server:host-gateway \
114-
ghcr.io/etnt/cryptic-tui:latest sh -c 'cryptic --onboard'
115-
```
116-
117-
During onboarding:
118-
1. Use your existing GPG key (the one you just created)
119-
2. The fingerprint is already registered (from the bootstrap step)
120-
3. Request your TLS certificate
121-
4. Start using Cryptic!
122-
123-
Once the first admin has a certificate, they can register other users' GPG keys
124-
through the admin interface, allowing those users to complete onboarding.
125-
126-
**Note**: If you need to bootstrap multiple admin users before starting the server,
127-
each admin generates their GPG key and exports it:
128-
129-
```bash
130-
# Each admin generates their key on their machine (no passphrase needed)
131-
gpg --quick-generate-key 'alice <alice@cryptic.local>' rsa4096
132-
gpg --quick-generate-key 'bob <bob@cryptic.local>' rsa4096
133-
134-
# Export each public key to the bootstrap directory
135-
gpg --armor --export alice@cryptic.local > priv/ca/bootstrap/alice.gpg
136-
gpg --armor --export bob@cryptic.local > priv/ca/bootstrap/bob.gpg
137-
138-
# Then start the server (it will read all GPG keys from priv/ca/bootstrap/)
139-
docker run -d --name cryptic-server ...
140-
```
141-
142111
## The Client
143112

144113
The Cryptic TUI (Terminal User Interface) client can run in Docker to
@@ -336,8 +305,18 @@ The entrypoint script (`docker-tui-entrypoint.sh`) handles:
336305

337306
#### Building the Image
338307

308+
**Important**: The Dockerfile expects to be run from the **parent directory** containing both `cryptic/` and `cryptic-tui/` as subdirectories.
309+
339310
Build the Docker image:
340311
```bash
312+
# From the parent directory (containing both cryptic/ and cryptic-tui/)
313+
cd /path/to/parent-directory
314+
docker build -t cryptic-tui:latest -f cryptic/Dockerfile.tui .
315+
```
316+
317+
Or using Docker Compose (handles build context automatically):
318+
```bash
319+
# From the cryptic directory
341320
docker compose build cryptic-tui
342321
```
343322

@@ -346,6 +325,16 @@ Build without cache (fresh build):
346325
docker compose build --no-cache cryptic-tui
347326
```
348327

328+
**Common Error**: If you get `COPY failed: file not found` errors, ensure you're building from the parent directory, not from within `cryptic/`:
329+
```bash
330+
# Wrong (from inside cryptic/)
331+
docker build -t cryptic-tui:latest -f Dockerfile.tui . # ❌ Will fail
332+
333+
# Correct (from parent directory)
334+
cd ..
335+
docker build -t cryptic-tui:latest -f cryptic/Dockerfile.tui . # ✅ Works
336+
```
337+
349338
#### Running the Client
350339

351340
Run interactively (recommended):

scripts/docker-tui-entrypoint.sh

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fix_permissions() {
3636
# Get the actual owner UID
3737
local owner_uid=$(stat -c %u "$dir" 2>/dev/null || stat -f %u "$dir" 2>/dev/null || echo "0")
3838
local cryptic_uid=$(id -u cryptic)
39-
39+
4040
if [ "$owner_uid" != "$cryptic_uid" ]; then
4141
info "Fixing permissions for $dir..."
4242
chown -R cryptic:cryptic "$dir" 2>/dev/null || warn "Could not change ownership of $dir"
@@ -47,7 +47,7 @@ fix_permissions() {
4747
# Set up Erlang cookie
4848
setup_erlang_cookie() {
4949
local cookie_file="/home/cryptic/.erlang.cookie"
50-
50+
5151
if [ -n "$ERLANG_COOKIE" ]; then
5252
info "Setting up Erlang cookie from environment..."
5353
echo -n "$ERLANG_COOKIE" > "$cookie_file"
@@ -74,14 +74,14 @@ setup_erlang_cookie() {
7474
# Verify certificate files exist
7575
check_certificates() {
7676
local cert_dir="/home/cryptic/.cryptic/${CRYPTIC_USERNAME}/${CRYPTIC_SERVER_HOST}_${CRYPTIC_SERVER_PORT}/certificates"
77-
77+
7878
if [ ! -d "$cert_dir" ]; then
7979
warn "Certificate directory not found: $cert_dir"
8080
warn "You may need to run onboarding first:"
8181
warn " docker compose run --rm cryptic-tui sh -c \"cryptic --onboard\""
8282
return 1
8383
fi
84-
84+
8585
if [ ! -f "$cert_dir/${CRYPTIC_USERNAME}.crt" ] || \
8686
[ ! -f "$cert_dir/${CRYPTIC_USERNAME}.key" ] || \
8787
[ ! -f "$cert_dir/ca.crt" ]; then
@@ -93,21 +93,21 @@ check_certificates() {
9393
warn "Run onboarding: docker compose run --rm cryptic-tui sh -c \"cryptic --onboard\""
9494
return 1
9595
fi
96-
96+
9797
success "Certificates found in $cert_dir"
9898
return 0
9999
}
100100

101101
# Check GPG keyring is available (mounted from host)
102102
check_gpg_keyring() {
103103
local gpg_home="/home/cryptic/.gnupg"
104-
104+
105105
if [ ! -d "$gpg_home" ]; then
106106
warn "GPG keyring not mounted: $gpg_home"
107107
warn "Certificate auto-renewal requires ~/.gnupg to be mounted."
108108
return 1
109109
fi
110-
110+
111111
# Check if there are any secret keys
112112
if su-exec cryptic gpg --list-secret-keys 2>/dev/null | grep -q "^sec"; then
113113
success "GPG keyring available with secret keys"
@@ -143,39 +143,35 @@ EOF
143143

144144
# Main execution
145145
main() {
146-
info "Cryptic TUI Container Starting..."
147-
148146
# Fix permissions on mounted volumes
149147
fix_permissions "/home/cryptic/.cryptic"
150-
148+
151149
# Set up Erlang cookie
152150
setup_erlang_cookie
153-
154-
# Check certificates (warn but don't fail - user might be onboarding)
151+
152+
# If arguments are given, just execute the command directly as cryptic user
153+
if [ $# -gt 0 ]; then
154+
exec su-exec cryptic "$@"
155+
fi
156+
157+
# Check certificates (warn but don't fail - user might need to onboard)
155158
check_certificates || warn "Continuing without certificates (use --onboard to set up)..."
156-
159+
157160
# Check GPG keyring is available (warn but don't fail)
158161
check_gpg_keyring || warn "Continuing without GPG keyring..."
159-
162+
160163
# Show connection info
161164
show_connection_info
162-
163-
# If command is cryptic-tui (default), run bin/cryptic --tui
164-
if [ "$1" = "cryptic-tui" ]; then
165-
info "Starting Cryptic TUI via bin/cryptic --tui..."
166-
167-
# Execute as cryptic user with bin/cryptic script
168-
exec su-exec cryptic /opt/cryptic/bin/cryptic --tui \
169-
-u "${CRYPTIC_USERNAME}" \
170-
-s "${CRYPTIC_SERVER_HOST}" \
171-
-p "${CRYPTIC_SERVER_PORT}" \
172-
--name "${CRYPTIC_NODE_NAME}" \
173-
$([ "${CRYPTIC_ENABLE_DB}" = "true" ] && echo "--enable-db")
174-
else
175-
# Run custom command as cryptic user
176-
info "Running custom command: $@"
177-
exec su-exec cryptic "$@"
178-
fi
165+
166+
info "Starting Cryptic TUI via bin/cryptic --tui..."
167+
168+
# Execute as cryptic user with bin/cryptic script
169+
exec su-exec cryptic /opt/cryptic/bin/cryptic --tui \
170+
-u "${CRYPTIC_USERNAME}" \
171+
-s "${CRYPTIC_SERVER_HOST}" \
172+
-p "${CRYPTIC_SERVER_PORT}" \
173+
--name "${CRYPTIC_NODE_NAME}" \
174+
$([ "${CRYPTIC_ENABLE_DB}" = "true" ] && echo "--enable-db")
179175
}
180176

181177
main "$@"

0 commit comments

Comments
 (0)