Skip to content

Commit 119ee12

Browse files
authored
Merge pull request #4 from unicitynetwork/docker
Docker
2 parents 439cbaf + 47abd3a commit 119ee12

File tree

15 files changed

+1148
-0
lines changed

15 files changed

+1148
-0
lines changed

.github/workflows/README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# GitHub Actions Workflows for Alpha
2+
3+
This directory contains GitHub Actions workflows for automating tasks in the Alpha project.
4+
5+
## Docker Image Publishing
6+
7+
The `docker-publish.yml` workflow automatically builds and publishes Docker images to GitHub Container Registry (ghcr.io) when:
8+
9+
1. A new GitHub Release is published
10+
2. The workflow is manually triggered
11+
12+
### How It Works
13+
14+
When a new release is created:
15+
16+
1. GitHub Actions checks out the code
17+
2. Sets up Docker Buildx for multi-platform builds
18+
3. Logs in to GitHub Container Registry using the built-in GITHUB_TOKEN
19+
4. Builds the Docker image using the Dockerfile in the docker/ directory
20+
5. Tags the image with both the release version and 'latest'
21+
6. Pushes the image to ghcr.io/{owner}/alpha
22+
7. Updates the container description with the contents of docker/README.md
23+
24+
### Manual Triggering
25+
26+
You can manually trigger a build by:
27+
28+
1. Going to the "Actions" tab in GitHub
29+
2. Selecting "Build and Publish Docker Image" workflow
30+
3. Clicking "Run workflow"
31+
4. Optionally specifying a tag (leave empty for 'latest')
32+
33+
### Image Access
34+
35+
The published images will be available at:
36+
37+
```
38+
ghcr.io/{owner}/alpha:latest
39+
ghcr.io/{owner}/alpha:{tag}
40+
```
41+
42+
Where `{owner}` is your GitHub username or organization name, and `{tag}` is the release version.
43+
44+
### Local Building and Publishing
45+
46+
You can also build and push the Docker image locally using the provided script:
47+
48+
```bash
49+
./docker/publish-image.sh [tag]
50+
```
51+
52+
This script will:
53+
54+
1. Build the Docker image locally
55+
2. Tag it with both the specified tag and 'latest'
56+
3. Push it to GitHub Container Registry (if you're logged in)
57+
58+
### Required Permissions
59+
60+
For the workflow to function properly:
61+
62+
1. The repository must have "Read and write permissions" for "Workflow permissions" in Settings → Actions → General
63+
2. If using organization packages, the repository must have package write access configured in the organization settings
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Build and Publish Docker Image
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
tag:
9+
description: 'Tag to build (leave empty for latest)'
10+
required: false
11+
default: ''
12+
13+
jobs:
14+
build-and-push:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
packages: write
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v3
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v2
28+
29+
- name: Log in to GitHub Container Registry
30+
uses: docker/login-action@v2
31+
with:
32+
registry: ghcr.io
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Set tag variables
37+
id: vars
38+
run: |
39+
if [[ "${{ github.event_name }}" == "release" ]]; then
40+
VERSION=${{ github.event.release.tag_name }}
41+
elif [[ -n "${{ github.event.inputs.tag }}" ]]; then
42+
VERSION=${{ github.event.inputs.tag }}
43+
else
44+
VERSION=latest
45+
fi
46+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
47+
REPO_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
48+
echo "IMAGE_NAME=ghcr.io/${REPO_LOWER}/alpha" >> $GITHUB_ENV
49+
50+
- name: Build and push Docker image
51+
uses: docker/build-push-action@v4
52+
with:
53+
context: .
54+
file: ./docker/Dockerfile
55+
push: true
56+
tags: |
57+
${{ env.IMAGE_NAME }}:${{ env.VERSION }}
58+
${{ env.IMAGE_NAME }}:latest
59+
cache-from: type=gha
60+
cache-to: type=gha,mode=max
61+
62+
- name: Update Docker Hub description
63+
uses: peter-evans/dockerhub-description@v3
64+
if: github.event_name == 'release'
65+
with:
66+
registry: ghcr.io
67+
repository: ${{ github.repository_owner }}/alpha
68+
username: ${{ github.actor }}
69+
password: ${{ secrets.GITHUB_TOKEN }}
70+
short-description: "Alpha cryptocurrency node"
71+
readme-filepath: ./docker/README.md

CLAUDE.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Alpha Project Guidelines
2+
3+
## Build Commands
4+
- Basic build: `./autogen.sh && ./configure && make`
5+
- 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`
6+
- 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`
7+
- Debug build: `./configure --enable-debug && make`
8+
9+
## Test Commands
10+
- All unit tests: `make check`
11+
- Single unit test: `src/test/test_bitcoin --run_test=getarg_tests/doubledash`
12+
- All functional tests: `test/functional/test_runner.py`
13+
- Single functional test: `test/functional/feature_rbf.py`
14+
- Test coverage: `./configure --enable-lcov && make && make cov`
15+
16+
## Lint Commands
17+
- Run all lint checks: `ci/lint_run_all.sh`
18+
- Run clang-tidy: `bear --config src/.bear-tidy-config -- make -j $(nproc) && cd ./src/ && run-clang-tidy -j $(nproc)`
19+
20+
## Code Style
21+
- C++: 4-space indentation, braces on new lines for functions/classes
22+
- Variables: `snake_case`, class members with `m_` prefix, constants in `ALL_CAPS`, globals with `g_` prefix
23+
- Class/methods: `UpperCamelCase` for classes, no `C` prefix
24+
- Commit messages: 50 chars title + blank line + description
25+
- PR titles: Prefix with component (consensus, doc, qt, wallet, etc.)
26+
- Python: Follow PEP-8, use f-strings, include docstrings
27+
- Include guards: `BITCOIN_FOO_BAR_H` format
28+
- Imports: No `using namespace` in global scope
29+
- Error handling: Use `assert`/`Assert` for assumptions, `CHECK_NONFATAL` for recoverable errors
30+
- Use init lists for member initialization: `int x{0};` instead of `int x = 0;`
31+
- Always use full namespace specifiers for function calls

docker/Dockerfile

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
FROM ubuntu:22.04 AS builder
2+
3+
# Set environment variables
4+
ENV DEBIAN_FRONTEND=noninteractive
5+
6+
# Install build dependencies
7+
RUN apt-get update && apt-get install -y \
8+
build-essential libtool autotools-dev automake pkg-config bsdmainutils python3 \
9+
libssl-dev libevent-dev libboost-system-dev libboost-filesystem-dev \
10+
libboost-chrono-dev libboost-test-dev libboost-thread-dev \
11+
libminiupnpc-dev libzmq3-dev libdb-dev libdb++-dev git \
12+
cmake bison \
13+
&& rm -rf /var/lib/apt/lists/*
14+
15+
# Set working directory
16+
WORKDIR /alpha
17+
18+
# Copy the source code
19+
COPY . .
20+
21+
# Build Dependencies and Alpha
22+
RUN ./autogen.sh
23+
RUN make -C depends NO_QT=1 -j$(nproc)
24+
RUN ./configure --without-gui --prefix=$PWD/depends/x86_64-pc-linux-gnu --program-transform-name='s/bitcoin/alpha/g'
25+
RUN make -j$(nproc)
26+
RUN make install
27+
28+
# Second stage: create minimal runtime image
29+
FROM ubuntu:22.04
30+
31+
# Install runtime dependencies
32+
RUN apt-get update && apt-get install -y \
33+
libboost-system1.74.0 libboost-filesystem1.74.0 libboost-thread1.74.0 \
34+
libboost-chrono1.74.0 libevent-2.1-7 libzmq5 libminiupnpc17 \
35+
&& rm -rf /var/lib/apt/lists/*
36+
37+
# Update library path
38+
RUN ldconfig /usr/local/lib
39+
40+
# Copy binaries from builder stage
41+
COPY --from=builder /alpha/depends/x86_64-pc-linux-gnu/bin/alphad /usr/local/bin/
42+
COPY --from=builder /alpha/depends/x86_64-pc-linux-gnu/bin/alpha-cli /usr/local/bin/
43+
44+
# Copy required libraries
45+
COPY --from=builder /alpha/depends/x86_64-pc-linux-gnu/lib/librandomx.* /usr/local/lib/
46+
47+
# Configure library paths
48+
RUN echo "/usr/local/lib" > /etc/ld.so.conf.d/local.conf && ldconfig
49+
50+
# Create directory for alpha config and data
51+
RUN mkdir -p /etc/alpha /root/.alpha
52+
53+
# Copy the default configuration file from the docker directory
54+
COPY docker/alpha.conf.default /etc/alpha/alpha.conf.default
55+
COPY docker/entrypoint.sh /entrypoint.sh
56+
RUN chmod +x /entrypoint.sh
57+
58+
# Expose ports - P2P and RPC
59+
EXPOSE 7933 8589
60+
61+
# This directory was already created above
62+
63+
# Set entrypoint
64+
ENTRYPOINT ["/entrypoint.sh"]
65+
CMD ["alphad"]

0 commit comments

Comments
 (0)