Skip to content

Commit

Permalink
feat: custom s3 endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
smrz2001 committed Sep 15, 2023
1 parent e63dc83 commit 300d889
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
27 changes: 21 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Dagger CI Workflow

on:
repository_dispatch:
types: [test-success]
paths-ignore:
- '.github/**'
- 'auth/**'
# repository_dispatch:
# types: [test-success]
# paths-ignore:
# - '.github/**'
# - 'auth/**'
workflow_dispatch: # manually triggered

env:
Expand Down Expand Up @@ -81,9 +81,24 @@ jobs:
if: ${{ env.BRANCH == 'main' || env.BRANCH == 'release-candidate' || env.BRANCH == 'develop' }}
run: echo "PUBLISH=true" >> $GITHUB_ENV
-
name: Push Docker image
name: Push private Docker image
if: ${{ env.PUBLISH == 'true' }}
run: dagger do push -w "actions:push:\"${{ env.AWS_REGION }}\":\"${{ env.ENV_TAG }}\":\"${{ env.BRANCH }}\":\"${{ env.SHA }}\":\"${{ env.SHA_TAG }}\":_" -p ${{ env.DAGGER_PLAN }}
-
name: Login to public ECR
uses: docker/login-action@v2
with:
registry: public.ecr.aws
username: ${{ env.AWS_ACCESS_KEY_ID }}
password: ${{ env.AWS_SECRET_ACCESS_KEY }}
env:
AWS_REGION: us-east-1
-
name: Push public Docker image
run: |
docker buildx build --load -t 3box/cas .
docker tag 3box/cas:latest public.ecr.aws/r5b3e0r5/3box/cas:latest
docker push public.ecr.aws/r5b3e0r5/3box/cas:latest
-
name: Create deployment job
if: ${{ env.PUBLISH == 'true' }}
Expand Down
3 changes: 2 additions & 1 deletion config/env/dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"schedulerStopAfterNoOp": "@@SCHEDULER_STOP_AFTER_NO_OP",
"carStorage": {
"mode": "@@MERKLE_CAR_STORAGE_MODE",
"s3BucketName": "@@S3_BUCKET_NAME"
"s3BucketName": "@@S3_BUCKET_NAME",
"s3Endpoint": "@@S3_ENDPOINT"
},
"ipfsConfig": {
"url": "@@IPFS_API_URL",
Expand Down
3 changes: 2 additions & 1 deletion config/env/prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"schedulerStopAfterNoOp": "@@SCHEDULER_STOP_AFTER_NO_OP",
"carStorage": {
"mode": "@@MERKLE_CAR_STORAGE_MODE",
"s3BucketName": "@@S3_BUCKET_NAME"
"s3BucketName": "@@S3_BUCKET_NAME",
"s3Endpoint": "@@S3_ENDPOINT"
},
"ipfsConfig": {
"url": "@@IPFS_API_URL",
Expand Down
13 changes: 12 additions & 1 deletion src/services/merkle-car-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ const MAX_CACHE_SIZE = 100 // ~40MiB if 1 batch is 400KiB

export class S3MerkleCarService implements IMerkleCarService {
readonly s3StorePath: string
readonly s3Endpoint: string
private _s3store?: LevelUp.LevelUp
private readonly cache: LRUCache<string, CAR>

constructor(config: Config) {
this.s3StorePath = config.carStorage.s3BucketName + S3_STORE_SUFFIX
this.s3Endpoint = config.carStorage.s3Endpoint
this.cache = new LRUCache(MAX_CACHE_SIZE)
}

Expand All @@ -68,7 +70,16 @@ export class S3MerkleCarService implements IMerkleCarService {
*/
get s3store(): LevelUp.LevelUp {
if (!this._s3store) {
this._s3store = new LevelUp(new S3LevelDOWN(this.s3StorePath, new AWSSDK.S3()))
const levelDown = this.s3Endpoint
? new S3LevelDOWN(
this.s3StorePath,
new AWSSDK.S3({
endpoint: this.s3Endpoint,
})
)
: new S3LevelDOWN(this.s3StorePath)

this._s3store = new LevelUp(levelDown)
}
return this._s3store
}
Expand Down

0 comments on commit 300d889

Please sign in to comment.