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
main
anddevelopment
branches - Gitea credentials for deployment (username and personal access token)
.env.deploy
file configured with your Gitea credentials
Quick Start
-
Copy the deployment environment template:
cp .env.deploy.example .env.deploy
-
Edit
.env.deploy
with 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.deploy
file 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-dev
service
Setup Production Environment
make setup-prod
This will:
- Validate
.env.deploy
file 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-prod
service - 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
development
branch - Pull latest changes
- Restart the
tf-marketplace-dev
service
Update Production Environment
make update-prod
This will:
- SSH to the server
- Navigate to production repository path
- Checkout the
main
branch - Pull latest changes
- Restart the
tf-marketplace-prod
service
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.example
to.env.deploy
- Edit
.env.deploy
with your Gitea credentials - Run
make setup-dev
for development environment - Run
make setup-prod
for production environment (ormake setup
for both)
Development Workflow
- Make changes in your local development branch
- Push changes to
development
branch in gitea - Run
make update-dev
to deploy to development environment
Production Workflow
- Create PR from
development
tomain
in gitea - Review and merge the PR
- Run
make update-prod
to 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_USER
andGITEA_TOKEN
are 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.deploy
with 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