Skip to content

Commit fb06269

Browse files
fix: replace LocalStack with S3Mock (#2280)
1 parent 67af5df commit fb06269

File tree

10 files changed

+31
-88
lines changed

10 files changed

+31
-88
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ batcher_start: ./crates/batcher/.env user_fund_payment_service
490490
@echo "Starting Batcher..."
491491
@cargo run --manifest-path ./crates/batcher/Cargo.toml --release -- --config ./config-files/config-batcher.yaml --env-file ./crates/batcher/.env
492492

493-
batcher_start_local: user_fund_payment_service ## Start the Batcher locally. It runs LocalStack as S3 service.
493+
batcher_start_local: user_fund_payment_service ## Start the Batcher locally. It runs S3Mock as S3 service.
494494
@echo "Starting Batcher..."
495495
@$(MAKE) storage_start &
496496
@cargo run --manifest-path ./crates/batcher/Cargo.toml --release -- --config ./config-files/config-batcher.yaml --env-file ./crates/batcher/.env.dev
@@ -500,7 +500,7 @@ batcher_start_local_no_fund:
500500
@$(MAKE) storage_start &
501501
@cargo run --manifest-path ./crates/batcher/Cargo.toml --release -- --config ./config-files/config-batcher.yaml --env-file ./crates/batcher/.env.dev
502502

503-
batcher_start_ethereum_package: user_fund_payment_service ## Start the Batcher with Ethereum package config. It runs LocalStack as S3 service.
503+
batcher_start_ethereum_package: user_fund_payment_service ## Start the Batcher with Ethereum package config. It runs S3Mock as S3 service.
504504
@echo "Starting Batcher..."
505505
@$(MAKE) storage_start &
506506
@cargo run --manifest-path ./crates/batcher/Cargo.toml --release -- --config ./config-files/config-batcher-ethereum-package.yaml --env-file ./crates/batcher/.env.dev

crates/batcher/.env.docker

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ AWS_SECRET_ACCESS_KEY=test
33
AWS_REGION=us-east-2
44
AWS_ACCESS_KEY_ID=test
55
AWS_BUCKET_NAME=aligned.storage
6-
UPLOAD_ENDPOINT=http://localstack:4566
7-
DOWNLOAD_ENDPOINT=http://localstack:4566/aligned.storage
6+
UPLOAD_ENDPOINT=http://s3mock:9090
7+
DOWNLOAD_ENDPOINT=http://s3mock:9090/aligned.storage
88

99
# Secondary S3 bucket configuration
1010
AWS_SECRET_ACCESS_KEY_SECONDARY=test2
1111
AWS_REGION_SECONDARY=us-west-1
1212
AWS_ACCESS_KEY_ID_SECONDARY=test2
1313
AWS_BUCKET_NAME_SECONDARY=aligned.storage
14-
UPLOAD_ENDPOINT_SECONDARY=http://localstack2:4567
15-
DOWNLOAD_ENDPOINT_SECONDARY=http://localstack2:4567/aligned.storage
14+
UPLOAD_ENDPOINT_SECONDARY=http://s3mock2:9090
15+
DOWNLOAD_ENDPOINT_SECONDARY=http://s3mock2:9090/aligned.storage
1616

1717
RUST_LOG=info
1818
RUST_BACKTRACE=1

crates/batcher/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl Batcher {
143143
pub async fn new(config_file: String) -> Self {
144144
dotenv().ok();
145145

146-
// https://docs.aws.amazon.com/sdk-for-rust/latest/dg/localstack.html
146+
// S3-compatible endpoint (S3Mock for local dev, real S3 in production)
147147
// Primary S3 configuration
148148
let s3_config_primary = s3::S3Config {
149149
access_key_id: env::var("AWS_ACCESS_KEY_ID").ok(),

docker-compose.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
services:
22

3-
localstack:
3+
s3mock:
44
extends:
55
file: storage-docker-compose.yaml
6-
service: localstack
6+
service: s3mock
77
profiles:
88
- base
99

10-
localstack2:
10+
s3mock2:
1111
extends:
1212
file: storage-docker-compose.yaml
13-
service: localstack2
13+
service: s3mock2
1414
profiles:
1515
- base
1616

@@ -115,14 +115,14 @@ services:
115115
AWS_REGION: us-east-2
116116
AWS_ACCESS_KEY_ID: test
117117
AWS_BUCKET_NAME: aligned.storage
118-
UPLOAD_ENDPOINT: http://localstack:4566
119-
DOWNLOAD_ENDPOINT: http://localstack:4566/aligned.storage
118+
UPLOAD_ENDPOINT: http://s3mock:9090
119+
DOWNLOAD_ENDPOINT: http://s3mock:9090/aligned.storage
120120
AWS_SECRET_ACCESS_KEY_SECONDARY: test2
121121
AWS_REGION_SECONDARY: us-west-1
122122
AWS_ACCESS_KEY_ID_SECONDARY: test2
123123
AWS_BUCKET_NAME_SECONDARY: aligned.storage
124-
UPLOAD_ENDPOINT_SECONDARY: http://localstack2:4567
125-
DOWNLOAD_ENDPOINT_SECONDARY: http://localstack2:4567/aligned.storage.secondary
124+
UPLOAD_ENDPOINT_SECONDARY: http://s3mock2:9090
125+
DOWNLOAD_ENDPOINT_SECONDARY: http://s3mock2:9090/aligned.storage.secondary
126126
RUST_LOG: info
127127
RUST_BACKTRACE: 1
128128
build:

docker/batcher.Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef
1111

1212
FROM chef AS planner
1313

14+
COPY crates/sdk/Cargo.toml /aligned_layer/crates/sdk/Cargo.toml
15+
COPY crates/sdk/src/lib.rs /aligned_layer/crates/sdk/src/lib.rs
16+
1417
COPY crates/batcher/Cargo.toml /aligned_layer/crates/batcher/Cargo.toml
1518
COPY crates/batcher/src/main.rs /aligned_layer/crates/batcher/src/main.rs
1619
WORKDIR /aligned_layer/crates/batcher/

docs/3_guides/6_setup_aligned.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ To start the [Batcher](../2_architecture/components/1_batcher.md) locally:
120120
make batcher_start_local
121121
```
122122

123-
This starts a [localstack](https://www.localstack.cloud/) to act as a replacement for S3.
123+
This starts an [S3Mock](https://github.com/adobe/S3Mock) container to act as a replacement for S3.
124124

125125
If you want to use the batcher under a real `S3` connection you'll need to specify the environment variables under `crates/batcher/.env` and then run:
126126

scripts/init-s3-main.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

scripts/init-s3-secondary.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

scripts/init-s3.py

Lines changed: 0 additions & 32 deletions
This file was deleted.

storage-docker-compose.yaml

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,18 @@
11
services:
2-
localstack:
3-
container_name: "${LOCALSTACK_DOCKER_NAME:-localstack-main}"
4-
image: localstack/localstack:s3-latest
2+
s3mock:
3+
container_name: "${S3MOCK_DOCKER_NAME:-s3mock-main}"
4+
image: adobe/s3mock:4.11.0
55
ports:
6-
- "127.0.0.1:4566:4566" # LocalStack Gateway
6+
- "127.0.0.1:4566:9090"
77
environment:
8-
- DEBUG=${DEBUG:-0}
9-
- DEFAULT_REGION=us-east-2
10-
- AWS_ACCESS_KEY_ID=test
11-
- AWS_SECRET_ACCESS_KEY=test
12-
volumes:
13-
- "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
14-
- "/var/run/docker.sock:/var/run/docker.sock"
15-
- "./scripts/init-s3.py:/etc/localstack/init/ready.d/init-s3.py" # bucket initialization script
16-
- "./scripts/init-s3-main.sh:/etc/localstack/init/ready.d/init-s3-main.sh" # bucket initialization script
8+
- COM_ADOBE_TESTING_S3MOCK_STORE_INITIAL_BUCKETS=aligned.storage
9+
- COM_ADOBE_TESTING_S3MOCK_STORE_REGION=us-east-2
1710

18-
localstack2:
19-
container_name: "${LOCALSTACK2_DOCKER_NAME:-localstack-secondary}"
20-
image: localstack/localstack:s3-latest
11+
s3mock2:
12+
container_name: "${S3MOCK2_DOCKER_NAME:-s3mock-secondary}"
13+
image: adobe/s3mock:4.11.0
2114
ports:
22-
- "127.0.0.1:4567:4566" # LocalStack Gateway
15+
- "127.0.0.1:4567:9090"
2316
environment:
24-
- DEBUG=${DEBUG:-0}
25-
- DEFAULT_REGION=us-west-1
26-
- AWS_ACCESS_KEY_ID=test2
27-
- AWS_SECRET_ACCESS_KEY=test2
28-
volumes:
29-
- "${LOCALSTACK2_VOLUME_DIR:-./volume2}:/var/lib/localstack"
30-
- "/var/run/docker.sock:/var/run/docker.sock"
31-
- "./scripts/init-s3.py:/etc/localstack/init/ready.d/init-s3.py" # bucket initialization script
32-
- "./scripts/init-s3-secondary.sh:/etc/localstack/init/ready.d/init-s3-secondary.sh" # bucket initialization script
17+
- COM_ADOBE_TESTING_S3MOCK_STORE_INITIAL_BUCKETS=aligned.storage
18+
- COM_ADOBE_TESTING_S3MOCK_STORE_REGION=us-west-1

0 commit comments

Comments
 (0)