Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# GitHub Actions Workflows for Alpha

This directory contains GitHub Actions workflows for automating tasks in the Alpha project.

## Docker Image Publishing

The `docker-publish.yml` workflow automatically builds and publishes Docker images to GitHub Container Registry (ghcr.io) when:

1. A new GitHub Release is published
2. The workflow is manually triggered

### How It Works

When a new release is created:

1. GitHub Actions checks out the code
2. Sets up Docker Buildx for multi-platform builds
3. Logs in to GitHub Container Registry using the built-in GITHUB_TOKEN
4. Builds the Docker image using the Dockerfile in the docker/ directory
5. Tags the image with both the release version and 'latest'
6. Pushes the image to ghcr.io/{owner}/alpha
7. Updates the container description with the contents of docker/README.md

### Manual Triggering

You can manually trigger a build by:

1. Going to the "Actions" tab in GitHub
2. Selecting "Build and Publish Docker Image" workflow
3. Clicking "Run workflow"
4. Optionally specifying a tag (leave empty for 'latest')

### Image Access

The published images will be available at:

```
ghcr.io/{owner}/alpha:latest
ghcr.io/{owner}/alpha:{tag}
```

Where `{owner}` is your GitHub username or organization name, and `{tag}` is the release version.

### Local Building and Publishing

You can also build and push the Docker image locally using the provided script:

```bash
./docker/publish-image.sh [tag]
```

This script will:

1. Build the Docker image locally
2. Tag it with both the specified tag and 'latest'
3. Push it to GitHub Container Registry (if you're logged in)

### Required Permissions

For the workflow to function properly:

1. The repository must have "Read and write permissions" for "Workflow permissions" in Settings → Actions → General
2. If using organization packages, the repository must have package write access configured in the organization settings
71 changes: 71 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build and Publish Docker Image

on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: 'Tag to build (leave empty for latest)'
required: false
default: ''

jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0

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

- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set tag variables
id: vars
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
VERSION=${{ github.event.release.tag_name }}
elif [[ -n "${{ github.event.inputs.tag }}" ]]; then
VERSION=${{ github.event.inputs.tag }}
else
VERSION=latest
fi
echo "VERSION=${VERSION}" >> $GITHUB_ENV
REPO_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
echo "IMAGE_NAME=ghcr.io/${REPO_LOWER}/alpha" >> $GITHUB_ENV

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./docker/Dockerfile
push: true
tags: |
${{ env.IMAGE_NAME }}:${{ env.VERSION }}
${{ env.IMAGE_NAME }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Update Docker Hub description
uses: peter-evans/dockerhub-description@v3
if: github.event_name == 'release'
with:
registry: ghcr.io
repository: ${{ github.repository_owner }}/alpha
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
short-description: "Alpha cryptocurrency node"
readme-filepath: ./docker/README.md
31 changes: 31 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Alpha Project Guidelines

## Build Commands
- Basic build: `./autogen.sh && ./configure && make`
- With GUI: `./autogen.sh && make -C depends && ./configure --prefix=$PWD/depends/x86_64-pc-linux-gnu --program-transform-name='s/bitcoin/alpha/g' && make && make install`
- Without GUI: `./autogen.sh && make -C depends NO_QT=1 && ./configure --without-gui --prefix=$PWD/depends/x86_64-pc-linux-gnu --program-transform-name='s/bitcoin/alpha/g' && make && make install`
- Debug build: `./configure --enable-debug && make`

## Test Commands
- All unit tests: `make check`
- Single unit test: `src/test/test_bitcoin --run_test=getarg_tests/doubledash`
- All functional tests: `test/functional/test_runner.py`
- Single functional test: `test/functional/feature_rbf.py`
- Test coverage: `./configure --enable-lcov && make && make cov`

## Lint Commands
- Run all lint checks: `ci/lint_run_all.sh`
- Run clang-tidy: `bear --config src/.bear-tidy-config -- make -j $(nproc) && cd ./src/ && run-clang-tidy -j $(nproc)`

## Code Style
- C++: 4-space indentation, braces on new lines for functions/classes
- Variables: `snake_case`, class members with `m_` prefix, constants in `ALL_CAPS`, globals with `g_` prefix
- Class/methods: `UpperCamelCase` for classes, no `C` prefix
- Commit messages: 50 chars title + blank line + description
- PR titles: Prefix with component (consensus, doc, qt, wallet, etc.)
- Python: Follow PEP-8, use f-strings, include docstrings
- Include guards: `BITCOIN_FOO_BAR_H` format
- Imports: No `using namespace` in global scope
- Error handling: Use `assert`/`Assert` for assumptions, `CHECK_NONFATAL` for recoverable errors
- Use init lists for member initialization: `int x{0};` instead of `int x = 0;`
- Always use full namespace specifiers for function calls
65 changes: 65 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
FROM ubuntu:22.04 AS builder

# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive

# Install build dependencies
RUN apt-get update && apt-get install -y \
build-essential libtool autotools-dev automake pkg-config bsdmainutils python3 \
libssl-dev libevent-dev libboost-system-dev libboost-filesystem-dev \
libboost-chrono-dev libboost-test-dev libboost-thread-dev \
libminiupnpc-dev libzmq3-dev libdb-dev libdb++-dev git \
cmake bison \
&& rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /alpha

# Copy the source code
COPY . .

# Build Dependencies and Alpha
RUN ./autogen.sh
RUN make -C depends NO_QT=1 -j$(nproc)
RUN ./configure --without-gui --prefix=$PWD/depends/x86_64-pc-linux-gnu --program-transform-name='s/bitcoin/alpha/g'
RUN make -j$(nproc)
RUN make install

# Second stage: create minimal runtime image
FROM ubuntu:22.04

# Install runtime dependencies
RUN apt-get update && apt-get install -y \
libboost-system1.74.0 libboost-filesystem1.74.0 libboost-thread1.74.0 \
libboost-chrono1.74.0 libevent-2.1-7 libzmq5 libminiupnpc17 \
&& rm -rf /var/lib/apt/lists/*

# Update library path
RUN ldconfig /usr/local/lib

# Copy binaries from builder stage
COPY --from=builder /alpha/depends/x86_64-pc-linux-gnu/bin/alphad /usr/local/bin/
COPY --from=builder /alpha/depends/x86_64-pc-linux-gnu/bin/alpha-cli /usr/local/bin/

# Copy required libraries
COPY --from=builder /alpha/depends/x86_64-pc-linux-gnu/lib/librandomx.* /usr/local/lib/

# Configure library paths
RUN echo "/usr/local/lib" > /etc/ld.so.conf.d/local.conf && ldconfig

# Create directory for alpha config and data
RUN mkdir -p /etc/alpha /root/.alpha

# Copy the default configuration file from the docker directory
COPY docker/alpha.conf.default /etc/alpha/alpha.conf.default
COPY docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

# Expose ports - P2P and RPC
EXPOSE 7933 8589

# This directory was already created above

# Set entrypoint
ENTRYPOINT ["/entrypoint.sh"]
CMD ["alphad"]
Loading