6.0 KiB
Automated Deployment Guide
This guide explains how to use the automated deployment system for the Project Mycelium.
Prerequisites
- SSH access to
root@info.ourworld.tf(passwordless SSH key setup recommended) - Git repository with
mainanddevelopmentbranches - Gitea credentials for deployment (username and personal access token)
.env.deployfile configured with your Gitea credentials
Quick Start
-
Copy the deployment environment template:
cp .env.deploy.example .env.deploy -
Edit
.env.deploywith your Gitea credentials:GITEA_USER=your_username GITEA_TOKEN=your_personal_access_token -
Setup development environment:
make setup-dev
Available Commands
First-Time Setup Commands
Setup Development Environment
make setup-dev
This will:
- Validate
.env.deployfile exists and has proper credentials - Copy development deployment script to server
- Copy development service configuration
- Copy deployment credentials to server
- Setup monitoring for the development service
- Start the
tf-marketplace-devservice
Setup Production Environment
make setup-prod
This will:
- Validate
.env.deployfile exists and has proper credentials - Copy production deployment script to server
- Copy production service configuration
- Copy deployment credentials to server
- Setup monitoring for the production service
- Start the
tf-marketplace-prodservice - Restart Caddy to load configurations
Setup Both Environments
make setup
Sets up both development and production environments in sequence.
Regular Update Commands
Update Development Environment
make update-dev
This will:
- SSH to the server
- Navigate to development repository path
- Checkout the
developmentbranch - Pull latest changes
- Restart the
tf-marketplace-devservice
Update Production Environment
make update-prod
This will:
- SSH to the server
- Navigate to production repository path
- Checkout the
mainbranch - Pull latest changes
- Restart the
tf-marketplace-prodservice
Monitoring Commands
Check Service Status
make status
Shows the status of both marketplace services.
View Service Logs
make logs
Shows logs from both development and production services.
Local Development Commands
Build and Run Locally
make build
Builds and runs the application locally (checks/generates .env file automatically).
Generate Secret Key
make key
Generates a new SECRET_KEY in the .env file.
Get Help
make help
Shows all available commands with descriptions.
Deployment Workflow
Initial Setup Workflow
- Copy
.env.deploy.exampleto.env.deploy - Edit
.env.deploywith your Gitea credentials - Run
make setup-devfor development environment - Run
make setup-prodfor production environment (ormake setupfor both)
Development Workflow
- Make changes in your local development branch
- Push changes to
developmentbranch in gitea - Run
make update-devto deploy to development environment
Production Workflow
- Create PR from
developmenttomainin gitea - Review and merge the PR
- Run
make update-prodto deploy to production environment
Server Configuration
The deployment assumes the following server setup:
- Development Repository Path:
/root/code/git.ourworld.tf/tfgrid_research/dev/projectmycelium - Production Repository Path:
/root/code/git.ourworld.tf/tfgrid_research/prod/projectmycelium - Development Service:
tf-marketplace-dev - Production Service:
tf-marketplace-prod - Zinit Configuration: Service configs stored in
/etc/zinit/ - Deployment Scripts: Stored in
/etc/zinit/cmds/
Troubleshooting
SSH Connection Issues
Ensure you have SSH key access to root@info.ourworld.tf:
ssh root@info.ourworld.tf 'echo "Connection successful"'
Service Not Starting
Check service logs:
make logs
Or check directly on the server:
ssh root@info.ourworld.tf 'zinit log tf-marketplace-prod'
ssh root@info.ourworld.tf 'zinit log tf-marketplace-dev'
Missing .env.deploy File
If you see errors about missing .env.deploy file:
- Copy the template:
cp .env.deploy.example .env.deploy - Edit the file with your Gitea credentials
- Ensure
GITEA_USERandGITEA_TOKENare properly set
Invalid Gitea Credentials
If setup fails due to invalid credentials:
- Verify your Gitea username and personal access token
- Ensure the token has appropriate repository access permissions
- Update
.env.deploywith correct credentials
Service Status Issues
Check service status:
make status
This will show if services are running, stopped, or have errors.
Manual Deployment
If you need to deploy manually, the commands are:
Development
ssh root@info.ourworld.tf 'cd /root/code/git.ourworld.tf/tfgrid_research/dev/projectmycelium && git checkout development && git pull && zinit restart tf-marketplace-dev'
Production
ssh root@info.ourworld.tf 'cd /root/code/git.ourworld.tf/tfgrid_research/prod/projectmycelium && git checkout main && git pull && zinit restart tf-marketplace-prod'
Environment Files
.env.deploy
Required for deployment setup. Contains Gitea credentials:
GITEA_USER=your_username
GITEA_TOKEN=your_personal_access_token
.env (Local Development)
Generated automatically by make build or make key. Contains:
SECRET_KEY- Auto-generated secure key- Other application configuration variables
Service Management
The deployment uses zinit for service management:
- Development Service:
tf-marketplace-dev - Production Service:
tf-marketplace-prod - Configuration Files:
/etc/zinit/tf-marketplace-dev.yaml/etc/zinit/tf-marketplace-prod.yaml
- Deployment Scripts:
/etc/zinit/cmds/tf-marketplace-dev.sh/etc/zinit/cmds/tf-marketplace-prod.sh