3.0 KiB
Deploying RedditBot to Dokploy
This guide explains how to deploy the RedditBot to Dokploy without needing to manually transfer your local browser session.
Automated Login Feature
The bot has been updated to support automated login using environment variables. This means when you deploy to a fresh server (like Dokploy), the bot will detect it's not logged in and automatically authenticate using the credentials you provide.
Deployment Steps
-
Create a New Application in Dokploy:
- Select "Docker Compose" as the deployment method (recommended) or "Dockerfile".
-
Environment Variables:
- Go to the "Environment" tab of your application.
- Add the following variables:
OPENROUTER_API_KEY: Your OpenRouter API key.REDDIT_USERNAME: Your Reddit username.REDDIT_PASSWORD: Your Reddit password.BROWSER_HEADLESS:false(required for interactive noVNC login).VNC_PASSWORD: A strong password for the interactive VNC session.NOVNC_PUBLIC_URL:http://<dokploy-host>:16080.
-
Volumes (Persistence):
- The
docker-compose.ymlis already configured to mount a./datavolume. - Dokploy usually handles volumes automatically for Docker Compose projects, or you may need to define a persistent volume path if you want data to survive container recreations (which you do, to avoid logging in every time).
- Make sure the
/app/datadirectory is persisted.
- The
-
Deploy:
- Push your code to your Git repository connected to Dokploy.
- Click "Deploy".
noVNC networking
The Compose configuration publishes noVNC directly on host port 16080.
Do not route it through a Dokploy/Traefik domain: the upstream proxy strips
the WebSocket Upgrade request that noVNC requires, producing rfb.js:688 with
WebSocket code 1011 and “Failed to connect to downstream server”.
Set NOVNC_PUBLIC_URL to http://<dokploy-host>:16080, then open that URL in
a separate tab from the dashboard. If the dashboard itself is HTTPS, browsers
will not embed this HTTP endpoint in its iframe; the separate-tab link is the
intended route. Restrict inbound TCP 16080 at the Dokploy host firewall to
your own IP or VPN subnet.
How it works
- On the first run, the bot will see the
data/browser-sessionfolder is empty/invalid. - It will read
REDDIT_USERNAMEandREDDIT_PASSWORD. - It will launch a headless browser, navigate to Reddit, and log in.
- The session cookies and storage will be saved to
data/browser-session. - On subsequent restarts, it will use the saved session (as long as the
/app/datavolume is persisted).
Troubleshooting
- Login Failed: Check the application logs. If Reddit presents a captcha or 2FA, the automated login will fail. You may need to temporarily run locally to solve the captcha, then copy the session (though this feature avoids that for standard accounts).
- Verification: The logs will show "Credentials found in config/env. Attempting automated login..." followed by "Login successful!".