-
Notifications
You must be signed in to change notification settings - Fork 1
Ci #4
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
Open
alysiahuggins
wants to merge
6
commits into
main
Choose a base branch
from
ci
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+398
−45
Open
Ci #4
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cc083c6
lint solidity code in ci
alysiahuggins b6fdff4
dry run deployment in ci
alysiahuggins eecd038
docker set up for deployments
alysiahuggins 42833cc
dry run deployment using the deploy script
alysiahuggins ddbcbff
only check network connection if it is not a dry run
alysiahuggins cdef9ca
only specify rpc url when it is not a dry run
alysiahuggins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Git files | ||
.git | ||
.gitignore | ||
|
||
# Docker files | ||
Dockerfile* | ||
docker-compose.yml | ||
.dockerignore | ||
|
||
# Build artifacts | ||
out/ | ||
cache/ | ||
target/ | ||
|
||
# Environment files (we'll pass these as environment variables) | ||
.env | ||
.env.* | ||
|
||
# IDE files | ||
.vscode/ | ||
.idea/ | ||
*.swp | ||
*.swo | ||
|
||
# OS files | ||
.DS_Store | ||
Thumbs.db | ||
|
||
# Documentation (we'll generate this fresh) | ||
docs/ | ||
|
||
# Large library files (we'll install these in the container) | ||
lib/ | ||
|
||
# Logs | ||
*.log |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,9 @@ out/ | |
# Docs | ||
docs/ | ||
|
||
# Dotenv file | ||
# Dotenv files | ||
.env | ||
docker/docker.env | ||
|
||
# Lock files | ||
foundry.lock |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Docker Setup | ||
|
||
Run everything in Docker containers. | ||
|
||
All commands need `cd docker` first. | ||
|
||
## Setup | ||
|
||
```bash | ||
cd docker | ||
cp docker.env.example docker.env | ||
./build-docker-images.sh | ||
``` | ||
|
||
## Usage | ||
|
||
```bash | ||
cd docker | ||
|
||
# start blockchain | ||
docker-compose up -d anvil | ||
|
||
# deploy | ||
docker-compose run --rm dev script/deploy.sh | ||
|
||
# test | ||
docker-compose run --rm dev forge test | ||
|
||
# interactive shell | ||
docker-compose run --rm dev bash | ||
|
||
# stop | ||
docker-compose down | ||
``` | ||
|
||
## Troubleshooting | ||
|
||
- **"exec format error"**: Use `docker-compose run` not `exec` | ||
- **"Port 8545 in use"**: `pkill anvil` | ||
- **"Build failed"**: `./build-docker-images.sh clean` | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Development environment for Timeboost Contracts | ||
# Use Ubuntu as base | ||
FROM ubuntu:22.04 | ||
|
||
# Install system dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
curl \ | ||
git \ | ||
bash \ | ||
ca-certificates \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Install Foundry | ||
RUN curl -L https://foundry.paradigm.xyz | bash | ||
RUN /root/.foundry/bin/foundryup | ||
|
||
# Verify installation | ||
RUN /root/.foundry/bin/forge --version | ||
|
||
# Add Foundry to PATH | ||
ENV PATH="/root/.foundry/bin:${PATH}" | ||
|
||
# Set working directory | ||
WORKDIR /app | ||
|
||
# Copy project files | ||
COPY . . | ||
|
||
# Initialize git (needed for forge install) | ||
RUN git init | ||
|
||
# Install dependencies | ||
RUN forge install | ||
|
||
# Make scripts executable | ||
RUN chmod +x script/deploy.sh | ||
|
||
# Set default command | ||
CMD ["bash"] | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
# Build script for Timeboost Contracts Docker images | ||
# Supports multi-architecture builds for CI and local development | ||
|
||
usage() { | ||
>&2 cat <<"EOF" | ||
Usage: | ||
|
||
build-docker-images [--image image] [--platform platform] | ||
build-docker-images clean | ||
|
||
Build timeboost-contracts docker images for multiple architectures. | ||
|
||
- The script supports building all images (the default) or one specific image | ||
- By default builds for both linux/amd64 and linux/arm64 (multi-arch) | ||
- Use --platform to build for specific architecture only | ||
|
||
Examples: | ||
|
||
# build for all supported platforms | ||
build-docker-images | ||
|
||
# build for specific platform (CI) | ||
build-docker-images --platform linux/amd64 | ||
|
||
# build for Apple Silicon only | ||
build-docker-images --platform linux/arm64 | ||
|
||
# clean the build artifacts | ||
build-docker-images clean | ||
EOF | ||
} | ||
|
||
# Default values | ||
docker_build_args="" | ||
image="" | ||
platform="" | ||
clean="" | ||
|
||
# Parse arguments | ||
while [[ $# -gt 0 ]]; do | ||
case "$1" in | ||
-h|--help) | ||
usage | ||
exit 0 | ||
;; | ||
-i|--image) | ||
if [[ -n "${image:-}" ]]; then | ||
>&2 echo "Error: --image option specified multiple times" | ||
>&2 echo "" | ||
usage | ||
exit 1 | ||
fi | ||
image="$2" | ||
shift 2 | ||
;; | ||
-p|--platform) | ||
if [[ -n "${platform:-}" ]]; then | ||
>&2 echo "Error: --platform option specified multiple times" | ||
>&2 echo "" | ||
usage | ||
exit 1 | ||
fi | ||
platform="$2" | ||
shift 2 | ||
;; | ||
clean) | ||
clean="true" | ||
shift | ||
;; | ||
*) | ||
>&2 echo "Error: Unknown option '$1'" | ||
>&2 echo "" | ||
usage | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
# Handle clean command | ||
if [[ "${clean:-}" == "true" ]]; then | ||
echo "Cleaning Docker build artifacts..." | ||
docker system prune -f | ||
docker builder prune -f | ||
echo "Clean complete!" | ||
exit 0 | ||
fi | ||
|
||
# Set default platform if not specified | ||
if [[ -z "${platform:-}" ]]; then | ||
platform="linux/amd64,linux/arm64" | ||
fi | ||
|
||
# Set default image if not specified | ||
if [[ -z "${image:-}" ]]; then | ||
image="all" | ||
fi | ||
|
||
echo "Building Docker images..." | ||
echo "Image: ${image}" | ||
echo "Platform: ${platform}" | ||
echo "" | ||
|
||
build_base_image() { | ||
echo "Building base image..." | ||
|
||
if [[ "$platform" == *","* ]]; then | ||
echo "Multi-platform build for: ${platform}" | ||
docker buildx build \ | ||
--platform "${platform}" \ | ||
--file "Dockerfile.dev" \ | ||
--tag "timeboost-contracts:latest" \ | ||
--load \ | ||
.. | ||
else | ||
echo "Single platform build for: ${platform}" | ||
docker buildx build \ | ||
--platform "${platform}" \ | ||
--file "Dockerfile.dev" \ | ||
--tag "timeboost-contracts:latest" \ | ||
--load \ | ||
.. | ||
fi | ||
|
||
echo "Base image built successfully" | ||
echo "" | ||
} | ||
|
||
# Build the single image (all services use the same image) | ||
build_base_image | ||
|
||
echo "Build complete!" | ||
echo "" | ||
echo "To test the images:" | ||
echo " docker-compose up -d anvil" | ||
echo " docker-compose run --rm dev script/deploy.sh" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
services: | ||
# Our main development environment | ||
dev: | ||
# Build the image directly | ||
build: | ||
context: .. | ||
dockerfile: docker/Dockerfile.dev | ||
image: timeboost-contracts:latest | ||
|
||
volumes: | ||
- ../src:/app/src # Source code | ||
- ../script:/app/script # Deployment scripts | ||
- ../test:/app/test # Test files | ||
- ../lib:/app/lib # Dependencies (forge-std, openzeppelin, etc.) | ||
- ../broadcast:/app/broadcast # Deployment transaction logs | ||
- ../foundry.toml:/app/foundry.toml # Foundry configuration | ||
- ../README.md:/app/README.md # Documentation | ||
|
||
env_file: | ||
- docker.env | ||
|
||
# Set the working directory | ||
working_dir: /app | ||
|
||
# Keep the container running and allow interaction | ||
stdin_open: true | ||
tty: true | ||
|
||
command: bash | ||
|
||
depends_on: | ||
- anvil | ||
|
||
# Local Ethereum blockchain for testing | ||
anvil: | ||
# Use the same base image | ||
image: timeboost-contracts:latest | ||
|
||
# Command to run when container starts | ||
command: anvil --host 0.0.0.0 --port 8545 | ||
|
||
# Expose port 8545 to your computer | ||
ports: | ||
- "8545:8545" | ||
|
||
# Health check for anvil | ||
healthcheck: | ||
test: ["CMD", "curl", "-f", "http://localhost:8545"] | ||
interval: 30s | ||
timeout: 10s | ||
retries: 3 | ||
start_period: 10s | ||
|
||
# Keep container running | ||
stdin_open: true | ||
tty: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Docker environment variables for development | ||
# Copy this file to docker.env and customize as needed | ||
MANAGER_ADDRESS=0x1234567890123456789012345678901234567890 | ||
RPC_URL=http://anvil:8545 | ||
MNEMONIC=test test test test test test test test test test test junk | ||
ACCOUNT_INDEX=0 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
what is the difference between this and the else?