Skip to content

Commit 7344f39

Browse files
committed
feat: Add GitHub Actions for automated Docker builds
- Created GitHub Actions workflow for multi-platform builds - Enhanced build script with cloud build options via GitHub Actions - Added comprehensive build documentation for restricted environments - Created setup guide for GitHub secrets configuration - Support for both local and cloud-based builds - Multi-architecture support (amd64, arm64)
1 parent bc2cce0 commit 7344f39

File tree

4 files changed

+370
-20
lines changed

4 files changed

+370
-20
lines changed

.github/workflows/docker-build.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- 'Dockerfile'
8+
- 'entrypoint.sh'
9+
- '.github/workflows/docker-build.yml'
10+
pull_request:
11+
branches: [ main ]
12+
workflow_dispatch:
13+
inputs:
14+
tag:
15+
description: 'Docker image tag'
16+
required: false
17+
default: 'latest'
18+
19+
env:
20+
REGISTRY: docker.io
21+
IMAGE_NAME: fullstackagent/fullstack-web-runtime
22+
23+
jobs:
24+
build-and-push:
25+
runs-on: ubuntu-latest
26+
permissions:
27+
contents: read
28+
packages: write
29+
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v4
33+
34+
- name: Set up QEMU
35+
uses: docker/setup-qemu-action@v3
36+
37+
- name: Set up Docker Buildx
38+
uses: docker/setup-buildx-action@v3
39+
40+
- name: Log in to Docker Hub
41+
if: github.event_name != 'pull_request'
42+
uses: docker/login-action@v3
43+
with:
44+
registry: ${{ env.REGISTRY }}
45+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
46+
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
47+
48+
- name: Extract metadata
49+
id: meta
50+
uses: docker/metadata-action@v5
51+
with:
52+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
53+
tags: |
54+
type=ref,event=branch
55+
type=ref,event=pr
56+
type=semver,pattern={{version}}
57+
type=semver,pattern={{major}}.{{minor}}
58+
type=raw,value=latest,enable={{is_default_branch}}
59+
type=raw,value=${{ github.event.inputs.tag || 'latest' }}
60+
type=sha,prefix={{branch}}-
61+
62+
- name: Build and push Docker image
63+
uses: docker/build-push-action@v5
64+
with:
65+
context: .
66+
platforms: linux/amd64,linux/arm64
67+
push: ${{ github.event_name != 'pull_request' }}
68+
tags: ${{ steps.meta.outputs.tags }}
69+
labels: ${{ steps.meta.outputs.labels }}
70+
cache-from: type=gha
71+
cache-to: type=gha,mode=max
72+
build-args: |
73+
BUILDKIT_INLINE_CACHE=1
74+
75+
- name: Image digest
76+
if: github.event_name != 'pull_request'
77+
run: echo ${{ steps.docker_build.outputs.digest }}
78+
79+
- name: Update Docker Hub Description
80+
if: github.event_name != 'pull_request'
81+
uses: peter-evans/dockerhub-description@v3
82+
with:
83+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
84+
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
85+
repository: ${{ env.IMAGE_NAME }}
86+
readme-filepath: ./README.md

README.md

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,54 @@ docker run -it --rm \
3434

3535
### Building from Source
3636

37-
Due to security restrictions in some environments, you may need to build this image in an environment with proper Docker or Buildah permissions.
37+
The image can be built using multiple methods, including automated GitHub Actions builds for environments with restrictions.
3838

39-
#### Option 1: Using the Build Script
39+
#### Option 1: GitHub Actions (Recommended for Restricted Environments)
40+
41+
This method uses GitHub Actions to build the image in the cloud, perfect for environments without Docker access:
42+
43+
```bash
44+
# First, set up GitHub repository secrets:
45+
# Go to: https://github.com/FullstackAgent/fullstack-runtime-builder/settings/secrets
46+
# Add two secrets:
47+
# - DOCKER_HUB_USERNAME: your Docker Hub username
48+
# - DOCKER_HUB_PASSWORD: your Docker Hub password
49+
50+
# Method A: Trigger via Web UI
51+
# Go to: https://github.com/FullstackAgent/fullstack-runtime-builder/actions
52+
# Click "Build and Push Docker Image" → "Run workflow"
53+
54+
# Method B: Trigger via GitHub CLI
55+
gh workflow run docker-build.yml -f tag="latest"
56+
57+
# Method C: Automatic trigger on push
58+
# The workflow automatically runs when you push changes to Dockerfile
59+
```
60+
61+
#### Option 2: Using the Build Script
62+
63+
The build script supports both local and GitHub Actions builds:
4064

4165
```bash
42-
# Set your Docker Hub credentials
66+
# Show help
67+
./build.sh --help
68+
69+
# Trigger GitHub Actions build
70+
./build.sh --github
71+
72+
# Build locally (requires Docker/Buildah/Podman)
73+
./build.sh --local
74+
75+
# Build with specific tag
76+
./build.sh --github v1.0.0
77+
78+
# For local builds with push to Docker Hub:
4379
export DOCKER_HUB_NAME=your_username
4480
export DOCKER_HUB_PASSWD=your_password
45-
46-
# Run the build script
47-
./build.sh
81+
./build.sh --local
4882
```
4983

50-
#### Option 2: Manual Build with Docker
84+
#### Option 3: Manual Build with Docker
5185

5286
```bash
5387
# Build the image
@@ -58,7 +92,7 @@ docker login
5892
docker push fullstackagent/fullstack-web-runtime:latest
5993
```
6094

61-
#### Option 3: Manual Build with Buildah (for rootless environments)
95+
#### Option 4: Manual Build with Buildah (for rootless environments)
6296

6397
```bash
6498
# Build with Buildah

SETUP_GITHUB_SECRETS.md

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# Setting Up GitHub Secrets for Automated Docker Builds
2+
3+
This guide will help you set up GitHub repository secrets to enable automated Docker image builds and pushes.
4+
5+
## Prerequisites
6+
7+
1. A Docker Hub account (create one at https://hub.docker.com if needed)
8+
2. Write access to the GitHub repository
9+
10+
## Steps to Configure GitHub Secrets
11+
12+
### 1. Navigate to Repository Settings
13+
14+
Go to: https://github.com/FullstackAgent/fullstack-runtime-builder/settings/secrets/actions
15+
16+
Or manually:
17+
1. Open the repository: https://github.com/FullstackAgent/fullstack-runtime-builder
18+
2. Click on "Settings" tab
19+
3. In the left sidebar, click "Secrets and variables" → "Actions"
20+
21+
### 2. Add Docker Hub Username
22+
23+
1. Click "New repository secret"
24+
2. Name: `DOCKER_HUB_USERNAME`
25+
3. Secret: Enter your Docker Hub username (e.g., `fullstackagent`)
26+
4. Click "Add secret"
27+
28+
### 3. Add Docker Hub Password
29+
30+
1. Click "New repository secret"
31+
2. Name: `DOCKER_HUB_PASSWORD`
32+
3. Secret: Enter your Docker Hub password or access token
33+
4. Click "Add secret"
34+
35+
**Security Note**: It's recommended to use a Docker Hub access token instead of your password:
36+
- Go to: https://hub.docker.com/settings/security
37+
- Click "New Access Token"
38+
- Description: "GitHub Actions for fullstack-runtime-builder"
39+
- Access permissions: "Read & Write"
40+
- Click "Generate"
41+
- Copy the token and use it as the password
42+
43+
## Verifying the Setup
44+
45+
### Manual Trigger
46+
47+
1. Go to: https://github.com/FullstackAgent/fullstack-runtime-builder/actions
48+
2. Click on "Build and Push Docker Image" workflow
49+
3. Click "Run workflow" button
50+
4. Select branch: `main`
51+
5. Enter a tag (optional, defaults to `latest`)
52+
6. Click "Run workflow"
53+
54+
### Check Build Status
55+
56+
- Monitor the build at: https://github.com/FullstackAgent/fullstack-runtime-builder/actions
57+
- Green checkmark ✅ = Build successful
58+
- Red X ❌ = Build failed (check logs for details)
59+
60+
### Verify Image on Docker Hub
61+
62+
Once built successfully, the image will be available at:
63+
- https://hub.docker.com/r/fullstackagent/fullstack-web-runtime
64+
65+
## Triggering Builds
66+
67+
### Automatic Triggers
68+
69+
The workflow automatically runs when:
70+
- Changes are pushed to `Dockerfile`
71+
- Changes are pushed to `entrypoint.sh`
72+
- Changes are pushed to the workflow file itself
73+
74+
### Manual Triggers via GitHub CLI
75+
76+
```bash
77+
# Install GitHub CLI if not already installed
78+
# https://cli.github.com/
79+
80+
# Authenticate with GitHub
81+
gh auth login
82+
83+
# Trigger the workflow
84+
gh workflow run docker-build.yml -f tag="v1.0.0"
85+
86+
# Check workflow runs
87+
gh run list --workflow=docker-build.yml
88+
```
89+
90+
### Manual Triggers via Build Script
91+
92+
```bash
93+
# Use the provided build script
94+
./build.sh --github
95+
96+
# With custom tag
97+
./build.sh --github v1.0.0
98+
```
99+
100+
## Troubleshooting
101+
102+
### Authentication Failed
103+
104+
If the build fails with authentication errors:
105+
1. Verify your Docker Hub username is correct
106+
2. Regenerate your Docker Hub access token
107+
3. Update the `DOCKER_HUB_PASSWORD` secret
108+
109+
### Build Failed
110+
111+
Check the workflow logs:
112+
1. Go to the Actions tab
113+
2. Click on the failed workflow run
114+
3. Click on "build-and-push" job
115+
4. Review the error messages
116+
117+
### Image Not Appearing on Docker Hub
118+
119+
1. Ensure the build completed successfully
120+
2. Check that secrets are correctly configured
121+
3. Verify your Docker Hub account has push permissions
122+
123+
## Security Best Practices
124+
125+
1. **Use Access Tokens**: Always use Docker Hub access tokens instead of passwords
126+
2. **Limit Token Scope**: Create tokens with minimal required permissions
127+
3. **Rotate Tokens**: Regularly rotate your access tokens
128+
4. **Monitor Usage**: Check Docker Hub for unexpected image pushes
129+
5. **Review Logs**: Regularly review GitHub Actions logs for suspicious activity
130+
131+
## Support
132+
133+
For issues or questions:
134+
- Open an issue: https://github.com/FullstackAgent/fullstack-runtime-builder/issues
135+
- Check GitHub Actions documentation: https://docs.github.com/en/actions
136+
- Docker Hub documentation: https://docs.docker.com/docker-hub/

0 commit comments

Comments
 (0)