How superfly/rchab works
Main Components
• Docker Proxy Service: The heart of the system is in the dockerproxy directory (with files like main.go, auth.go, dockerd.go, etc.). This Go-based service intercepts and manages Docker build requests.
• Docker Entrypoint Script(s): Managed via the docker-entrypoint.d directory and the separate “entrypoint” file. These scripts initialize the environment and adjust system configurations before the service runs.
• Configuration Files: These include deployment and environment config files such as Dockerfile, Procfile, Vagrantfile (for local development), fly.toml, and the daemon.json file inside etc/docker. These files indicate how the service is built, deployed, and behaves in production versus development.
• CI/CD Pipeline: The .github directory (with workflows such as ci.yaml) represents an automated build/test/deployment pipeline, ensuring code changes are integrated and deployed correctly (by GitHub Actions deploying changes to the main branch).
• Utility Scripts and Tools: Files like Makefile, build.sh, and rsyncd.conf support building, testing, and syncing the development environment.
Relationships and Workflows
• Client Interaction: External tools (like flyctl, as described in the README) connect to the proxy service. For local development, Vagrant is used to run an isolated VM that has the service and its own Docker daemon.
• Remote Build Triggering: When a user triggers a build (e.g., using the fly deploy command), flyctl communicates with this proxy service, which then directs the Docker commands to its locally managed Docker daemon.
• CI/CD Integration: GitHub Actions automatically build and deploy updates when changes are merged into the main branch. This updates the running service on Fly.
• Service Initialization: The dockerentrypoint scripts and the separate “entrypoint” are responsible for setting up and configuring the Docker environment, including possibly sysctl and other system-level configuration.
Important Architectural Patterns & Design Principles
• Separation of Concerns: The design clearly separates the proxy service’s logic (dockerproxy implementation) from the environment setup (entrypoint scripts, configuration in etc/ and Dockerfile).
• Remote Build Abstraction: The architecture is designed to abstract away local Docker interactions, using a remote builder that can be overridden (via FLY_RCHAB_OVERRIDE_HOST) for testing.
• CI/CD and Infrastructure as Code: The project leverages GitHub Actions and configuration files (fly.toml, Vagrantfile) to manage deployment and environmental consistency.
Specify Relevant Technologies
• Go: The primary language for the dockerproxy service.
• Docker: Both as the container platform (with its Dockerfile and daemon configuration) and the service’s target environment for build operations.
• Fly.io: The deployment and remote build environment driven by flyctl commands.
• Vagrant: For local development to simulate an isolated environment running Docker without interfering with the host setup.
• GitHub Actions: Used for continuous integration and deployment (ci.yaml in .github/workflows).