-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60ac928
commit 3bec3ce
Showing
13 changed files
with
164 additions
and
93 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: Snapshot Service Image | ||
|
||
# Cancel workflow if there is a new change to the branch. | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
tags: | ||
- "*" | ||
merge_group: | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
build-and-push-docker-image: | ||
name: Build images and push to GHCR | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
steps: | ||
- name: List cached docker images | ||
run: docker image ls | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Login to Github Packages | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# This step yields the following labels | ||
# - date+sha, e.g. 2023-01-19-da4692d, | ||
# - tag (if pushed). | ||
- name: Docker Meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ghcr.io/chainsafe/forest-snapshot-service | ||
flavor: | | ||
latest=false | ||
tags: | | ||
type=raw,value={{date 'YYYY-MM-DD'}}-{{sha}} | ||
type=ref,event=tag | ||
type=edge | ||
- name: Build image and push to GitHub Container Registry | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ./images/snapshot-service/ | ||
build-contexts: | | ||
common=./tf-managed/scripts/ | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
push: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }} | ||
|
||
- name: List docker images | ||
run: docker image ls |
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,25 @@ | ||
# Snapshot service Dockerfile. | ||
# It is meant to produce a single snapshot of the given chain in the Filecoin network and upload it to S3 (preferably Cloudflare R2, it should work for other providers as well, but it wasn't tested). | ||
FROM docker:24 | ||
LABEL org.opencontainers.image.description "Forest snapshot service generator and uploader for Filecoin" | ||
|
||
RUN apk add --no-cache \ | ||
ruby=3.2.2-r1 \ | ||
ruby-dev=3.2.2-r1 \ | ||
docker=24.0.7-r0 \ | ||
aws-cli=2.13.25-r0 \ | ||
bash=5.2.21-r0 && \ | ||
gem install \ | ||
docker-api:1.28.0 \ | ||
slack-ruby-client:2.2 \ | ||
activesupport:7.0.8 | ||
|
||
COPY ./src /opt/snapshot-service | ||
|
||
# TODO: Change this once `sync-check` is fully-dockerized as well. | ||
# hadolint ignore=DL3022 | ||
COPY --from=common ruby_common /opt/snapshot-service/ruby_common | ||
|
||
WORKDIR /opt/snapshot-service | ||
|
||
CMD ["bash", "run.sh"] |
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,14 @@ | ||
# TODO MOAR | ||
## Variables | ||
|
||
```bash | ||
R2_ACCESS_KEY= | ||
R2_SECRET_KEY= | ||
R2_ENDPOINT= | ||
|
||
SLACK_API_TOKEN= | ||
SLACK_CHANNEL= | ||
|
||
NETWORK_CHAIN= | ||
FOREST_TAG= | ||
``` |
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,17 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
# Assert that all required environment variables are set | ||
: "${R2_ACCESS_KEY:?}" | ||
: "${R2_SECRET_KEY:?}" | ||
: "${SLACK_API_TOKEN:?}" | ||
: "${SLACK_NOTIFICATION_CHANNEL:?}" | ||
: "${NETWORK_CHAIN:?}" | ||
: "${FOREST_TAG:?}" | ||
|
||
aws configure set default.s3.multipart_chunksize 4GB | ||
aws configure set aws_access_key_id "$R2_ACCESS_KEY" | ||
aws configure set aws_secret_access_key "$R2_SECRET_KEY" | ||
|
||
ruby daily_snapshot.rb "$NETWORK_CHAIN" |
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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
#!/bin/bash | ||
|
||
# shellcheck source=/dev/null | ||
source ~/.forest_env | ||
cd "$BASE_FOLDER" || exit | ||
flock -n /tmp/calibnet.lock -c "ruby daily_snapshot.rb calibnet >> logs/calibnet_log.txt 2>&1" | ||
cd $HOME | ||
flock -n /tmp/calibnet.lock -c "docker run --privileged -v /var/run/docker.sock:/var/run/docker.sock --rm --env-file .forest_env -e NETWORK_CHAIN=calibnet ghcr.io/chainsafe/forest-snapshot-service:latest >> calibnet_log.txt 2>&1" |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
#!/bin/bash | ||
|
||
# shellcheck source=/dev/null | ||
source ~/.forest_env | ||
cd "$BASE_FOLDER" || exit | ||
flock -n /tmp/mainnet.lock -c "ruby daily_snapshot.rb mainnet > mainnet_log.txt 2>&1" || exit | ||
cd $HOME | ||
flock -n /tmp/mainnet.lock -c "docker run --privileged -v /var/run/docker.sock:/var/run/docker.sock --rm --env-file .forest_env -e NETWORK_CHAIN=mainnet ghcr.io/chainsafe/forest-snapshot-service:latest >> mainnet_log.txt 2>&1" |
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