This guide covers deploying the Criptocracia Electoral Commission using Docker, both locally and on Digital Ocean App Platform.
- Docker and Docker Compose installed
- RSA key pair generated (see main README)
- Build and run locally:
# Build the Docker image
docker build -t criptocracia-ec .
# Run with environment variables
docker run -d \
-p 3000:3000 \
-e EC_PRIVATE_KEY="$(cat ec_private.pem)" \
-e EC_PUBLIC_KEY="$(cat ec_public.pem)" \
-v $(pwd)/data:/app/data \
criptocracia-ec- Using Docker Compose:
# Create data directory
mkdir -p data
# Set environment variables
export EC_PRIVATE_KEY="$(cat ec_private.pem)"
export EC_PUBLIC_KEY="$(cat ec_public.pem)"
# Start services
docker-compose up -dThe container expects:
- RSA keys via
EC_PRIVATE_KEYandEC_PUBLIC_KEYenvironment variables - Data directory mounted at
/app/data
- Digital Ocean account
- GitHub repository with your code
- RSA key pair generated
-
Prepare your repository:
- Ensure all Docker files are committed
- Push to GitHub
-
Create App on Digital Ocean:
- Go to Digital Ocean App Platform
- Create new app from GitHub repository
- Select your
criptocraciarepository - Choose
mainbranch
-
Configure Environment Variables: In the Digital Ocean dashboard, add these environment variables:
EC_PRIVATE_KEY: Your RSA private key PEM content (mark as encrypted)EC_PUBLIC_KEY: Your RSA public key PEM content (mark as encrypted)RUST_LOG: Set toinfo
You can also deploy using the included .do/app.yaml specification:
# Install doctl CLI
# Configure with your Digital Ocean API token
doctl apps create --spec .do/app.yaml| Variable | Description | Required |
|---|---|---|
EC_PRIVATE_KEY |
RSA private key in PEM format | Yes |
EC_PUBLIC_KEY |
RSA public key in PEM format | Yes |
RUST_LOG |
Log level (trace, debug, info, warn, error) | No (default: info) |
DATA_DIR |
Directory for application data | No (default: /app/data) |
- RSA keys are loaded from environment variables for security
- Container runs as non-root user
- Use Digital Ocean's secret management for production
- Regularly rotate RSA keys
- Monitor logs for suspicious activity
-
Container won't start:
- Check that environment variables are set correctly
- Verify RSA key format (must include headers/footers)
- Check logs:
docker logs <container_id>
-
Network issues:
- Verify port 3000 is accessible
- Check firewall settings
- Ensure Nostr relay connectivity
The container includes a health check that runs every 30 seconds. You can manually check:
docker exec <container_id> echo "Electoral Commission is running"For production deployment:
- Consider using Digital Ocean's database for persistence
- Set up monitoring and alerting
- Implement log aggregation
- Use load balancers for high availability
- Set up backup strategies for election data