Skip to content

feat: added nix support #2

feat: added nix support

feat: added nix support #2

---
name: "Binary and Docker Build"
on:
push:
branches:
- feat/binary-builds
env:
GIT_SHA: ${{ github.sha }}
GIT_BRANCH: ${{ github.ref_name }}
BUILD_DATE: ${{ github.event.head_commit.timestamp }}
BUILT_VIA_BUILDKIT: "true"
PROFILE: "release"
FEATURES: ""
CARGO_TARGET_DIR: "target/release"
jobs:
build-default-members:
name: "Build Default Members Binaries"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: movementlabsxyz/aptos-core/.github/actions/rust-setup@feat/binary-builds
- name: Build default-members binaries
run: |
echo "Building all default-members binaries..."
echo "PROFILE: $PROFILE"
echo "CARGO_TARGET_DIR: $CARGO_TARGET_DIR"
# Build all default-members as defined in Cargo.toml
cargo build --locked --profile=$PROFILE \
--workspace \
--exclude aptos-move-examples \
--exclude move-examples \
--exclude aptos-framework \
--exclude aptos-stdlib \
--exclude aptos-token \
--exclude aptos-token-objects \
--exclude move-stdlib \
--exclude aptos-experimental \
--exclude cached-packages \
--exclude table-natives
- name: Prepare binary artifacts
run: |
# Create dist directory for binaries
mkdir -p dist
# Copy the main default-member binaries to dist
DEFAULT_MEMBER_BINS=(
"aptos-node"
"aptos-safety-rules"
"aptos"
"aptos-debugger"
"aptos-faucet-service"
"aptos-keygen"
"aptos-rate-limiter"
"aptos-rosetta"
"aptos-transaction-emitter"
"aptos-backup-cli"
"aptos-node-checker"
)
for BIN in "${DEFAULT_MEMBER_BINS[@]}"; do
if [ -f "$CARGO_TARGET_DIR/$PROFILE/$BIN" ]; then
cp "$CARGO_TARGET_DIR/$PROFILE/$BIN" "dist/$BIN"
echo "Copied $BIN to dist/"
else
echo "Warning: Binary $BIN not found in target directory"
fi
done
# List all binaries in dist
echo "Binaries in dist directory:"
ls -la dist/
- name: Upload binary artifacts
uses: actions/upload-artifact@v4
with:
name: aptos-core-binaries
path: dist/
retention-days: 7
# build-docker-image:
# name: "Build Docker Image"
# needs: build-default-members
# runs-on: ubuntu-latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# - name: Download binary artifacts
# uses: actions/download-artifact@v4
# with:
# name: aptos-core-binaries
# path: dist/
# - name: Set up Docker Buildx
# uses: aptos-labs/aptos-core/.github/actions/buildx-setup@main
# - name: Prepare Docker context
# run: |
# # Make binaries executable
# chmod +x dist/*
# # List downloaded binaries
# echo "Downloaded binaries:"
# ls -la dist/
# # Set environment variables for Docker build
# echo "GIT_SHA=$GIT_SHA" >> $GITHUB_ENV
# echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_ENV
# echo "BUILD_DATE=$BUILD_DATE" >> $GITHUB_ENV
# - name: Build Docker image
# run: |
# # Create a simple Dockerfile for the binaries
# cat > Dockerfile.binaries << 'EOF'
# FROM ubuntu:22.04
# # Install runtime dependencies
# RUN apt-get update && apt-get install -y \
# ca-certificates \
# curl \
# libssl3 \
# libpq5 \
# && rm -rf /var/lib/apt/lists/*
# # Copy binaries
# COPY dist/* /usr/local/bin/
# # Set permissions
# RUN chmod +x /usr/local/bin/*
# # Create aptos user
# RUN useradd -m -s /bin/bash aptos
# USER aptos
# WORKDIR /home/aptos
# # Default command
# CMD ["/usr/local/bin/aptos-node"]
# EOF
# # Build the Docker image
# docker build \
# -f Dockerfile.binaries \
# -t "aptoslabs/aptos-core:feat-binary-builds-$GIT_SHA" \
# -t "aptoslabs/aptos-core:feat-binary-builds-latest" \
# --build-arg GIT_SHA="$GIT_SHA" \
# --build-arg GIT_BRANCH="$GIT_BRANCH" \
# --build-arg BUILD_DATE="$BUILD_DATE" \
# .
# - name: Verify Docker image
# run: |
# echo "Docker image built successfully!"
# docker images | grep aptoslabs/aptos-core
# # Test that the image can run
# echo "Testing Docker image..."
# docker run --rm \
# aptoslabs/aptos-core:feat-binary-builds-$GIT_SHA \
# /usr/local/bin/aptos --version || true
# # Show image size
# docker images aptoslabs/aptos-core:feat-binary-builds-$GIT_SHA \
# --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}"
# - name: Save Docker image
# run: |
# # Save the Docker image as a tar file for potential future use
# docker save aptoslabs/aptos-core:feat-binary-builds-$GIT_SHA | \
# gzip > aptos-core-docker-image.tar.gz
# - name: Upload Docker image artifact
# uses: actions/upload-artifact@v4
# with:
# name: aptos-core-docker-image
# path: aptos-core-docker-image.tar.gz
# retention-days: 7