-
Notifications
You must be signed in to change notification settings - Fork 5
157 lines (132 loc) · 5.9 KB
/
build-flyio.yml
File metadata and controls
157 lines (132 loc) · 5.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: Build and Release Fly.io Server
# This workflow builds Docker image for Fly.io server and creates a release
# Responds only to tags starting with "server-v" (e.g., server-v1.0.0)
on:
workflow_dispatch: # Manual trigger
push:
tags:
- 'server-v*' # Triggers on tags starting with 'server-v' (e.g., server-v1.0.0)
jobs:
build-and-release:
name: Build Docker Image and Create Release
runs-on: ubuntu-latest
steps:
# 1. Checkout code
- name: Checkout code
uses: actions/checkout@v4
# 2. Prepare data directory for Docker build
- name: Prepare data directory
run: |
# If flyio_server/data doesn't exist, use data from project root
if [ ! -d "flyio_server/data" ]; then
echo "flyio_server/data not found, using data from project root"
if [ -d "data" ]; then
mkdir -p flyio_server
cp -r data flyio_server/data
echo "✓ Copied data from project root to flyio_server/data"
echo "⚠️ WARNING: This image will be built with placeholder/empty data"
echo "⚠️ WARNING: Server deployed from this image will NOT work properly (no game maps)"
echo "⚠️ WARNING: Users must add game data using deploy_prebuilt.sh with actual game data"
else
echo "WARNING: Neither flyio_server/data nor data directory found"
echo "Creating empty data directory (server will NOT work properly)"
mkdir -p flyio_server/data
fi
else
echo "✓ flyio_server/data exists, using it"
# Check if it contains actual game data (has maps directory)
if [ -d "flyio_server/data/maps" ] && [ "$(ls -A flyio_server/data/maps 2>/dev/null)" ]; then
echo "✓ flyio_server/data contains game maps - image will be fully functional"
else
echo "⚠️ WARNING: flyio_server/data exists but appears to be empty/placeholder"
echo "⚠️ WARNING: Server deployed from this image will NOT work properly"
fi
fi
# 3. Setup Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# 4. Login to GitHub Container Registry
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# 5. Extract version from tag or use commit SHA
- name: Extract version
id: version
run: |
if [[ "${{ github.ref }}" == refs/tags/server-v* ]]; then
# Remove "server-" prefix from tag (server-v1.0.0 -> v1.0.0)
VERSION=${GITHUB_REF#refs/tags/server-}
else
VERSION="dev-${GITHUB_SHA::8}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=ghcr.io/${{ github.repository_owner }}/fpc-atomic-server:$VERSION" >> $GITHUB_OUTPUT
echo "tag_latest=ghcr.io/${{ github.repository_owner }}/fpc-atomic-server:latest" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
# 6. Build Docker image
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./flyio_server/Dockerfile
push: true
tags: |
${{ steps.version.outputs.tag }}
${{ steps.version.outputs.tag_latest }}
cache-from: type=gha
cache-to: type=gha,mode=max
# 7. Create GitHub Release (only for server tags)
- name: Create Release
if: startsWith(github.ref, 'refs/tags/server-v')
uses: softprops/action-gh-release@v1
with:
name: Fly.io Server ${{ steps.version.outputs.version }}
body: |
☁️ Cloud Server Release
This release contains files for build and deploy game server to [fly.io](https://fly.io)
## FPC Atomic Server for Fly.io
### 🚀 How to deploy to Fly.io (without Pascal compiler!)
**Easiest way - use the pre-built Docker image:**
1. **Install Fly.io CLI:**
```bash
curl -L https://fly.io/install.sh | sh
```
2. **Login:**
```bash
flyctl auth login
```
3. **Create a new directory and download configuration:**
```bash
mkdir fpc-atomic-server && cd fpc-atomic-server
curl -L https://github.com/${{ github.repository }}/releases/latest/download/fly.toml.example -o fly.toml
```
4. **Edit `fly.toml` - change the image path to your GitHub username (if you have a fork):**
```toml
[build]
image = "ghcr.io/${{ github.repository_owner }}/fpc-atomic-server:latest"
```
5. **Deploy to Fly.io:**
```bash
flyctl launch
```
**Alternative - build from source code:**
If you want to build from source code, clone the repository and use `fly.toml` from the `flyio_server/` directory.
### 📦 Docker Image
Image is available on GitHub Container Registry:
- `ghcr.io/${{ github.repository_owner }}/fpc-atomic-server:${{ steps.version.outputs.version }}`
- `ghcr.io/${{ github.repository_owner }}/fpc-atomic-server:latest`
### 🔧 Configuration
- **Port:** 5521
- **Region:** Frankfurt (fra) - can be changed in `fly.toml`
- **Auto-shutdown:** 30 seconds of inactivity
### 📝 Documentation
For more information, see [README.md](flyio_server/README.md)
draft: false
prerelease: false
files: |
flyio_server/README.md
flyio_server/fly.toml.example
flyio_server/Dockerfile