-
Notifications
You must be signed in to change notification settings - Fork 0
Add GitHub Actions workflow for automated Docker builds #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d554872
d83018a
6d00437
120a6be
f27752e
c73a675
4952ff2
1b7ebad
a1f325c
1e92142
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||
|
|
@@ -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`) | ||||||
| - **Image name**: `cloud-server` | ||||||
|
||||||
| - **Image name**: `cloud-server` | |
| - **Image name**: `<username>/cloud-server` (where `<username>` is your Docker Hub username or the GitHub repository owner) |
Copilot
AI
Feb 6, 2026
There was a problem hiding this comment.
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".
| 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`. |
There was a problem hiding this comment.
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
mainbranch for build validation (without pushing to Docker Hub). Consider adding this information to the "Trigger" section: "- Pull requests tomain(build-only validation without pushing to Docker Hub)".