Skip to content
Merged
56 changes: 56 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Docker Build

on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
branches:
- main

jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# Login to Docker Hub (requires DOCKER_USERNAME and DOCKER_PASSWORD secrets)
- name: Log in to Docker Hub
if: github.event_name != 'pull_request' && vars.DOCKER_ENABLED == 'true'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
# Image will be named cloud-server under your Docker Hub username
# Falls back to GitHub repository owner for local builds
images: |
${{ secrets.DOCKER_USERNAME || github.repository_owner }}/cloud-server
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
# Only push if not a PR and DOCKER_ENABLED variable is set
push: ${{ github.event_name != 'pull_request' && vars.DOCKER_ENABLED == 'true' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ docker compose up -d

The server will be available at ws://localhost:9080/. Logs are persisted in the `./logs` directory on the host.

Alternatively, if Docker Hub publishing is configured for this repository, you can pull the pre-built image:

```bash
# To find the Docker Hub username:
# 1. Go to the repository's Actions tab on GitHub
# 2. Look for successful "Docker Build" workflow runs
# 3. Check the workflow logs for the image name being pushed
# OR ask the repository maintainer for the Docker Hub username

docker pull <username>/cloud-server:latest
docker run -d -p 9080:9080 <username>/cloud-server:latest
```

To stop the server:

```bash
Expand Down Expand Up @@ -108,3 +121,24 @@ server {
```

You may also want to make a systemd service file for the server, but this is left as an exercise to the reader.

## Development

### CI/CD

This repository includes a GitHub Actions workflow that automatically builds and publishes Docker images:

- **Trigger**: Automatically runs on push to `main` branch and on version tags (e.g., `v1.0.0`)

Copilot AI Feb 6, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation doesn't mention that the workflow also runs on pull requests targeting the main branch for build validation (without pushing to Docker Hub). Consider adding this information to the "Trigger" section: "- Pull requests to main (build-only validation without pushing to Docker Hub)".

Suggested change
- **Trigger**: Automatically runs on push to `main` branch and on version tags (e.g., `v1.0.0`)
- **Trigger**: Automatically runs on push to `main` branch, on pull requests targeting `main` (build-only validation without pushing to Docker Hub), and on version tags (e.g., `v1.0.0`)

Copilot uses AI. Check for mistakes.
- **Image name**: `cloud-server`

Copilot AI Feb 6, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The image name documentation is incomplete. The actual Docker image name is <username>/cloud-server (where username is from DOCKER_USERNAME secret or github.repository_owner), not just cloud-server. This should be updated to match the actual naming convention used in the workflow (line 41 of docker.yml).

Suggested change
- **Image name**: `cloud-server`
- **Image name**: `<username>/cloud-server` (where `<username>` is your Docker Hub username or the GitHub repository owner)

Copilot uses AI. Check for mistakes.
- **Tags**:
- `latest` tag for main branch pushes
- Semantic version tags (e.g., `1.0.0`, `1.0`) for version tag pushes

To enable Docker Hub publishing, configure the following repository secrets:
- `DOCKER_USERNAME`: Your Docker Hub username
- `DOCKER_PASSWORD`: Your Docker Hub password or access token

And set this repository variable:
- `DOCKER_ENABLED`: Set to `true` to enable Docker Hub publishing

The workflow will build the Docker image on every push and only push to Docker Hub if the `DOCKER_ENABLED` variable is set to `true`.

Copilot AI Feb 6, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The statement "The workflow will build the Docker image on every push" is misleading. According to the workflow configuration, it only runs on pushes to the main branch or version tags (e.g., v1.0.0), not on every push to every branch. Consider rephrasing to: "The workflow will build the Docker image on every push to the main branch and on version tag pushes".

Suggested change
The workflow will build the Docker image on every push and only push to Docker Hub if the `DOCKER_ENABLED` variable is set to `true`.
The workflow will build the Docker image on every push to the `main` branch and on version tag pushes, and will only push to Docker Hub if the `DOCKER_ENABLED` variable is set to `true`.

Copilot uses AI. Check for mistakes.