-
Notifications
You must be signed in to change notification settings - Fork 21
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
feat: Add attestation entry point to Docker Images #1476
Open
fabergat
wants to merge
13
commits into
main
Choose a base branch
from
feat/add_attestation_validation_script
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.
+152
−0
Open
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
798809c
Add new workflow
fabergat 73fe0a8
Update vars
fabergat 9921d67
Add environment
fabergat 3d027b3
Fix vars
fabergat d1e52d7
Add script
fabergat 7e10b76
Change verify command
fabergat 7fb2141
Move to another strategy
fabergat 6d3bab8
Fix upload
fabergat 3e3cfcc
wMerge branch 'main' into feat/add_attestation_validation_script
fabergat 872f831
Fix comment
fabergat 4c17d83
Improvements in the readme
fabergat ec6fbf0
Fix file name on pipeline
fabergat 887a6c3
Fix workflow
fabergat 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 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 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 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 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,103 @@ | ||
# **Docker Image with Attestation Verification** | ||
|
||
This repository provides a Docker image that can be used to run a signer application with **attestation verification**. Before running the application, the image verifies its attestation, ensuring that the image and its contents are trusted. | ||
|
||
## **Features** | ||
- **Attestation Verification**: Verifies the integrity of the Docker image before execution using GitHub's attestation tools. | ||
- **Custom Entry Point**: Uses a custom entry point script to enforce attestation verification before running the signer app. | ||
- **Supports Local Files for Attestation**: Instead of URLs, this setup uses local file paths for the attestation bundle and trusted root. | ||
|
||
--- | ||
|
||
## **Environment Variables** | ||
|
||
- `TAG`: The tag of the Docker image you want to verify (e.g., `signer-test-attestation`). | ||
- `BUNDLE_PATH`: Local path to the attestation bundle file (e.g., `/path/to/bundle.jsonl`). | ||
- `TRUSTED_ROOT_PATH`: Local path to the trusted root file (e.g., `/path/to/trusted_root.jsonl`). | ||
|
||
--- | ||
|
||
## **Example Docker Command:** | ||
|
||
To run your Docker image and perform attestation verification, use the following command: | ||
|
||
```bash | ||
docker run --rm \ | ||
-e TAG="signer" \ | ||
-e BUNDLE_PATH="/path/to/your/bundle.jsonl" \ | ||
-e TRUSTED_ROOT_PATH="/path/to/your/trusted_root.jsonl" \ | ||
-v /path/to/your/bundle.jsonl:/path/to/your/bundle.jsonl \ | ||
-v /path/to/your/trusted_root.jsonl:/path/to/your/trusted_root.jsonl \ | ||
--entrypoint /entrypoint.sh \ | ||
image_name \ | ||
/usr/local/bin/signer --config /signer-config.toml --migrate-db | ||
``` | ||
|
||
```bash | ||
docker run --rm \ | ||
-e TAG="blocklist-cli" \ | ||
-e BUNDLE_PATH="/path/to/your/bundle.jsonl" \ | ||
-e TRUSTED_ROOT_PATH="/path/to/your/trusted_root.jsonl" \ | ||
-v /path/to/your/bundle.jsonl:/path/to/your/bundle.jsonl \ | ||
-v /path/to/your/trusted_root.jsonl:/path/to/your/trusted_root.jsonl \ | ||
--entrypoint /entrypoint.sh \ | ||
image_name \ | ||
/usr/local/bin/blocklist-client | ||
``` | ||
|
||
This command will: | ||
1. **Set the environment variables**: `TAG`, `BUNDLE_PATH` and `TRUSTED_ROOT_PATH` | ||
|
||
2. **Use [/entrypoint.sh](/docker/mainnet/gh-attestation/entrypoint.sh)**: The entrypoint of the Docker image is overridden to run the `entrypoint.sh` script, which performs the attestation verification before running the application. | ||
|
||
3. **Run the Signer Application**: The signer application is started with the provided configuration file (`/signer-config.toml`) and the database will be migrated using the `--migrate-db` flag. | ||
|
||
--- | ||
|
||
## **Example Docker Compose Configuration:** | ||
|
||
```yaml | ||
services: | ||
signer: | ||
image: signer | ||
environment: | ||
- TAG="signer" # Set your specific image tag | ||
- BUNDLE_PATH="/path/to/your/bundle.jsonl" | ||
- TRUSTED_ROOT_PATH="/path/to/your/trusted_root.jsonl" | ||
volumes: | ||
- /path/to/your/bundle.jsonl:/path/to/your/bundle.jsonl | ||
- /path/to/your/trusted_root.jsonl:/path/to/your/trusted_root.jsonl | ||
entrypoint: ["/entrypoint.sh"] | ||
command: ["/usr/local/bin/signer", "--config", "/signer-config.toml", "--migrate-db"] | ||
``` | ||
|
||
```yaml | ||
services: | ||
signer: | ||
image: blocklist-cli | ||
environment: | ||
- TAG="blocklist-cli" # Set your specific image tag | ||
- BUNDLE_PATH="/path/to/your/bundle.jsonl" | ||
- TRUSTED_ROOT_PATH="/path/to/your/trusted_root.jsonl" | ||
volumes: | ||
- /path/to/your/bundle.jsonl:/path/to/your/bundle.jsonl | ||
- /path/to/your/trusted_root.jsonl:/path/to/your/trusted_root.jsonl | ||
entrypoint: ["/entrypoint.sh"] | ||
command: ["/usr/local/bin/blocklist-client"] | ||
``` | ||
|
||
This will: | ||
1. **Set up the Docker container** with the required environment variables for attestation. | ||
2. **Use [/entrypoint.sh](/docker/mainnet/gh-attestation/entrypoint.sh)**: The entry point script checks the attestation and proceeds if verified. | ||
3. **Run the signer application** with the provided config file and migration option. | ||
|
||
To start the service with Docker Compose, use: | ||
|
||
```bash | ||
docker-compose up | ||
``` | ||
--- | ||
|
||
## **Additional Information** | ||
|
||
The image requires the GitHub CLI (`gh`) to verify the attestation. |
This file contains 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,24 @@ | ||
#!/bin/bash | ||
set -e # Exit on error | ||
|
||
# Ensure required environment variables are set | ||
if [[ -z "$BUNDLE_PATH" || -z "$TRUSTED_ROOT_PATH" ]]; then | ||
echo "❌ ERROR: BUNDLE_PATH and TRUSTED_ROOT_PATH environment variables must be set." | ||
exit 1 | ||
fi | ||
|
||
# Define the image and repo (since they are fixed) | ||
IMAGE="index.docker.io/blockstack/sbtc:$TAG" # You can pass $TAG as environment variable | ||
REPO="stacks-network/sbtc" | ||
|
||
# Verifying attestation | ||
echo "✅ Verifying attestation for image: $IMAGE..." | ||
gh attestation verify \ | ||
oci://$IMAGE \ | ||
-R "$REPO" \ | ||
--bundle "$BUNDLE_PATH" \ | ||
--custom-trusted-root "$TRUSTED_ROOT_PATH" | ||
|
||
# If verification succeeds, run the signer app | ||
echo "🎉 Attestation verified successfully! Running the signer..." | ||
exec "$@" |
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.
Considering the section "Enviroment Variables", The description could be simplified in something like this:
By this the message is still the same, but get rid off duplication respect of the "Environment Variables" section
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.
done