Skip to content

Commit bc3ca98

Browse files
authored
Merge pull request #610 from maximhq/10-13-deployment_instructions_for_fly
deployment instructions for fly
2 parents 48c06ab + 8e4cb11 commit bc3ca98

File tree

6 files changed

+230
-4
lines changed

6 files changed

+230
-4
lines changed

Makefile

Lines changed: 99 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ BLUE=\033[0;34m
1616
CYAN=\033[0;36m
1717
NC=\033[0m # No Color
1818

19-
.PHONY: all help dev build-ui build run install-air clean test install-ui setup-workspace work-init work-clean docs docker-build cleanup-enterprise
19+
.PHONY: all help dev build-ui build run install-air clean test install-ui setup-workspace work-init work-clean docs build-docker-image cleanup-enterprise deploy-to-fly-io
2020

2121
all: help
2222

@@ -81,10 +81,11 @@ build: build-ui ## Build bifrost-http binary
8181
@cd transports/bifrost-http && GOWORK=off go build -o ../../tmp/bifrost-http .
8282
@echo "$(GREEN)Built: tmp/bifrost-http$(NC)"
8383

84-
docker-build: build-ui ## Build Docker image
84+
build-docker-image: build-ui ## Build Docker image
8585
@echo "$(GREEN)Building Docker image...$(NC)"
86-
@docker build -f transports/Dockerfile -t bifrost .
87-
@echo "$(GREEN)Docker image built: bifrost$(NC)"
86+
$(eval GIT_SHA=$(shell git rev-parse --short HEAD))
87+
@docker build -f transports/Dockerfile -t bifrost -t bifrost:$(GIT_SHA) -t bifrost:latest .
88+
@echo "$(GREEN)Docker image built: bifrost, bifrost:$(GIT_SHA), bifrost:latest$(NC)"
8889

8990
docker-run: ## Run Docker container
9091
@echo "$(GREEN)Running Docker container...$(NC)"
@@ -177,3 +178,97 @@ work-init: ## Create local go.work to use local modules for development (legacy)
177178
work-clean: ## Remove local go.work
178179
@rm -f go.work go.work.sum || true
179180
@echo "$(GREEN)Removed local go.work files$(NC)"
181+
182+
183+
# Deployment scripts for different platforms
184+
185+
deploy-to-fly-io: ## Deploy to Fly.io (Usage: make deploy-to-fly-io APP_NAME=your-app-name)
186+
@echo "$(BLUE)Starting Fly.io deployment...$(NC)"
187+
@echo ""
188+
@# Check if APP_NAME is provided
189+
@if [ -z "$(APP_NAME)" ]; then \
190+
echo "$(RED)Error: APP_NAME is required$(NC)"; \
191+
echo "$(YELLOW)Usage: make deploy-to-fly-io APP_NAME=your-app-name$(NC)"; \
192+
exit 1; \
193+
fi
194+
@echo "$(YELLOW)Checking prerequisites...$(NC)"
195+
@# Check if docker is installed
196+
@which docker > /dev/null || (echo "$(RED)Error: Docker is not installed. Please install Docker first.$(NC)" && exit 1)
197+
@echo "$(GREEN)✓ Docker is installed$(NC)"
198+
@# Check if flyctl is installed
199+
@which flyctl > /dev/null || (echo "$(RED)Error: flyctl is not installed. Please install flyctl first.$(NC)" && exit 1)
200+
@echo "$(GREEN)✓ flyctl is installed$(NC)"
201+
@# Check if app exists on Fly.io
202+
@flyctl status -a $(APP_NAME) > /dev/null 2>&1 || (echo "$(RED)Error: App '$(APP_NAME)' not found on Fly.io$(NC)" && echo "$(YELLOW)Create the app first with: flyctl launch --name $(APP_NAME)$(NC)" && exit 1)
203+
@echo "$(GREEN)✓ App '$(APP_NAME)' exists on Fly.io$(NC)"
204+
@echo ""
205+
@# Check if fly.toml exists, create temp if needed
206+
@if [ -f "fly.toml" ]; then \
207+
echo "$(GREEN)✓ Using existing fly.toml$(NC)"; \
208+
else \
209+
echo "$(YELLOW)fly.toml not found in current directory$(NC)"; \
210+
echo "$(CYAN)Would you like to create a temporary fly.toml with 2 vCPU configuration?$(NC)"; \
211+
echo "$(CYAN)(It will be removed after deployment)$(NC)"; \
212+
printf "Create temporary fly.toml? [y/N]: "; read response; \
213+
case "$$response" in \
214+
[yY][eE][sS]|[yY]) \
215+
echo "$(YELLOW)Creating temporary fly.toml with 2 vCPU configuration...$(NC)"; \
216+
echo "app = '$(APP_NAME)'" > fly.toml; \
217+
echo "primary_region = 'iad'" >> fly.toml; \
218+
echo "" >> fly.toml; \
219+
echo "[build]" >> fly.toml; \
220+
echo " image = 'registry.fly.io/$(APP_NAME):latest'" >> fly.toml; \
221+
echo "" >> fly.toml; \
222+
echo "[http_service]" >> fly.toml; \
223+
echo " internal_port = 8080" >> fly.toml; \
224+
echo " force_https = true" >> fly.toml; \
225+
echo " auto_stop_machines = true" >> fly.toml; \
226+
echo " auto_start_machines = true" >> fly.toml; \
227+
echo " min_machines_running = 0" >> fly.toml; \
228+
echo "" >> fly.toml; \
229+
echo "[[vm]]" >> fly.toml; \
230+
echo " memory = '2gb'" >> fly.toml; \
231+
echo " cpu_kind = 'shared'" >> fly.toml; \
232+
echo " cpus = 2" >> fly.toml; \
233+
echo "$(GREEN)✓ Created temporary fly.toml with 2 vCPU configuration$(NC)"; \
234+
touch .fly.toml.tmp.marker; \
235+
;; \
236+
*) \
237+
echo "$(RED)Deployment cancelled. Please create a fly.toml file or run 'flyctl launch' first.$(NC)"; \
238+
exit 1; \
239+
;; \
240+
esac; \
241+
fi
242+
@echo ""
243+
@echo "$(YELLOW)Building Docker image...$(NC)"
244+
@$(MAKE) build-docker-image
245+
@echo ""
246+
@echo "$(YELLOW)Tagging image for Fly.io registry...$(NC)"
247+
@docker tag bifrost:latest registry.fly.io/$(APP_NAME):latest
248+
$(eval GIT_SHA=$(shell git rev-parse --short HEAD))
249+
@docker tag bifrost:$(GIT_SHA) registry.fly.io/$(APP_NAME):$(GIT_SHA)
250+
@echo "$(GREEN)✓ Tagged: registry.fly.io/$(APP_NAME):latest$(NC)"
251+
@echo "$(GREEN)✓ Tagged: registry.fly.io/$(APP_NAME):$(GIT_SHA)$(NC)"
252+
@echo ""
253+
@echo "$(YELLOW)Pushing to Fly.io registry...$(NC)"
254+
@echo "$(YELLOW)Authenticating with Fly.io...$(NC)"
255+
@flyctl auth docker
256+
@echo "$(GREEN)✓ Authenticated with Fly.io$(NC)"
257+
@echo ""
258+
@echo "$(YELLOW)Pushing image to Fly.io registry...$(NC)"
259+
@docker push registry.fly.io/$(APP_NAME):latest
260+
@docker push registry.fly.io/$(APP_NAME):$(GIT_SHA)
261+
@echo "$(GREEN)✓ Image pushed to registry$(NC)"
262+
@echo ""
263+
@echo "$(YELLOW)Deploying to Fly.io...$(NC)"
264+
@flyctl deploy -a $(APP_NAME)
265+
@echo ""
266+
@echo "$(GREEN)✓ Deployment complete!$(NC)"
267+
@echo "$(CYAN)App URL: https://$(APP_NAME).fly.dev$(NC)"
268+
@echo ""
269+
@# Clean up temporary fly.toml if we created it
270+
@if [ -f ".fly.toml.tmp.marker" ]; then \
271+
echo "$(YELLOW)Cleaning up temporary fly.toml...$(NC)"; \
272+
rm -f fly.toml .fly.toml.tmp.marker; \
273+
echo "$(GREEN)✓ Temporary fly.toml removed$(NC)"; \
274+
fi

docs/deployment-guides/fly.mdx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: fly.io
3+
description: "This guide explains how to deploy Bifrost on fly.io"
4+
icon: "fly"
5+
---
6+
7+
As `Bifrost` uses multiple sub-modules (`core`, `framework`, etc.) and also embeds the front-end into a single binary (embed.FS), we use a custom Docker build step before we hand over the deployment to flyctl.
8+
9+
There are two ways to deploy Bifrost on Fly.io:
10+
11+
1. By cloning the repo
12+
2. Using flyctl + Docker Hub image
13+
14+
## By cloning the repo
15+
16+
1. Clone https://github.com/maximhq/bifrost
17+
2. Ensure [Make](/deployment-guides/how-to/install-make) is installed.
18+
3. Run `make deploy-to-fly-io APP_NAME=<your-fly-app-name>`
19+
20+
21+
## Using flyctl + Docker Hub image
22+
23+
1. Update your `fly.toml` to specify the Bifrost Docker Hub image.
24+
25+
```toml
26+
[build]
27+
image = "maximhq/bifrost:latest"
28+
```
29+
30+
2. Or you can specify the Docker Hub image path in the command:
31+
32+
```
33+
fly deploy --app <your-app-name> --image docker.io/maximhq/bifrost:latest
34+
```
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
title: "Install make command"
3+
description: "This guide explains how to install make command."
4+
icon: "compact-disc"
5+
---
6+
7+
8+
## Windows
9+
10+
### Option A: Chocolatey (easy)
11+
12+
```
13+
# Run in an elevated PowerShell (Run as Administrator)
14+
choco install make
15+
# verify
16+
make --version
17+
```
18+
19+
### Option B: Scoop (no admin needed)
20+
```
21+
# In a normal PowerShell
22+
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
23+
iwr get.scoop.sh -useb | iex
24+
scoop install make
25+
make --version
26+
```
27+
28+
### Option C: MSYS2 (full Unix-like env)
29+
30+
```
31+
# 1) Install MSYS2 from https://www.msys2.org/
32+
# 2) In "MSYS2 MSYS" terminal:
33+
pacman -Syu # then reopen terminal if asked
34+
pacman -S make
35+
make --version
36+
```
37+
38+
<Note> Visual Studio’s nmake is a different tool (not GNU make). </Note>
39+
40+
## Ubuntu / Debian
41+
42+
```
43+
sudo apt update
44+
# Pulls in compilers and common build tools, including make
45+
sudo apt install build-essential
46+
# (or just) sudo apt install make
47+
make --version
48+
```
49+
50+
## macOS
51+
52+
### Option A: Xcode Command Line Tools (most common)
53+
54+
```
55+
xcode-select --install # follow the prompt
56+
make --version
57+
```
58+
59+
This provides Apple’s/BSD-flavored make, which is fine for most projects.
60+
61+
### Option B: Homebrew (get GNU make ≥ 4.x as gmake)
62+
63+
```
64+
# Install Homebrew if needed: https://brew.sh
65+
brew install make
66+
gmake --version
67+
```
68+
69+
If a project specifically requires GNU make as make, you can use:
70+
71+
echo 'alias make="gmake"' >> ~/.zshrc && source ~/.zshrc
72+
73+
## Troubleshooting tips
74+
75+
- If make isn’t found, restart your terminal (or on Windows, open a new PowerShell) so your PATH updates.
76+
- Run which make (where make on Windows) to confirm which binary you’re using.
77+
- For Windows builds that depend on Unix tools (sed, grep, etc.), prefer MSYS2 or WSL for a smoother experience.

docs/deployment/docker-setup.mdx

Whitespace-only changes.

docs/docs.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,26 @@
122122
}
123123
]
124124
},
125+
{
126+
"tab": "Deployment Guides",
127+
"icon": "server",
128+
"pages": [
129+
{
130+
"group":"Common setup instructions",
131+
"icon": "book",
132+
"pages": [
133+
"deployment-guides/how-to/install-make"
134+
]
135+
},
136+
{
137+
"group":"Platform specific guides",
138+
"icon": "swatchbook",
139+
"pages": [
140+
"deployment-guides/fly"
141+
]
142+
}
143+
]
144+
},
125145
{
126146
"tab": "API Reference",
127147
"icon": "code",

docs/favicon.ico

4.19 KB
Binary file not shown.

0 commit comments

Comments
 (0)