Skip to content

Commit

Permalink
Added logic to create base relayer image (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
andynog committed Dec 2, 2020
1 parent bf6ca29 commit 080cb31
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 8 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
11 changes: 11 additions & 0 deletions ci/setup_relayer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

echo "Setting up relayer for chains:"
echo Chain: "$CHAIN_A"
echo Chain: "$CHAIN_B"

# Check gaia version
echo "-------------------------------------------------------------------------------------------------------------------"
echo "Relayer version"
echo "-------------------------------------------------------------------------------------------------------------------"
rrly
28 changes: 28 additions & 0 deletions ci/simple_config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[global]
timeout = '10s'
strategy = 'naive'

[[chains]]
id = 'ibc0'
rpc_addr = 'tcp://ibc0:26657'
grpc_addr = 'tcp://localhost:9090'
account_prefix = 'cosmos'
key_name = 'testkey'
store_prefix = 'ibc'
client_ids = ['ethbridge']
gas = 200000
clock_drift = '5s'
trusting_period = '14days'

[[chains]]
id = 'ibc1'
rpc_addr = 'tcp://localhost:26557'
grpc_addr = 'tcp://localhost:9090'
account_prefix = 'cosmos'
key_name = 'testkey'
store_prefix = 'ibc'
client_ids = ['ibconeclient']
gas = 200000
clock_drift = '5s'
trusting_period = '14days'

16 changes: 13 additions & 3 deletions ci/docker-compose.yml → docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
- P2P_PORT=26656
- GRPC_PORT=9090
networks:
localnet:
relaynet:
ipv4_address: 192.168.10.2
ibc1:
container_name: ibc1
Expand All @@ -31,11 +31,21 @@ services:
- P2P_PORT=26556
- GRPC_PORT=9091
networks:
localnet:
relaynet:
ipv4_address: 192.168.10.3
relayer:
depends_on:
- ibc0
- ibc1
container_name: relayer
image: "informal/relayer"
environment:
- CHAIN_A=ibc0
- CHAIN_B=ibc1
- CONFIG=simple_config.toml

networks:
localnet:
relaynet:
driver: bridge
ipam:
driver: default
Expand Down
6 changes: 1 addition & 5 deletions ci/gaia.Dockerfile → docker-gaia.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ ENV GAIA /gaia
# Install ca-certificates
RUN apk add --update ca-certificates

# Add dependenncies
RUN apk add --no-cache tree

RUN addgroup gaia && \
adduser -S -G gaia gaia -h "$GAIA"

Expand All @@ -44,10 +41,9 @@ WORKDIR $GAIA

# Copy over binaries from the build-env
COPY --from=build-env /go/bin/gaiad /usr/bin/gaiad
COPY --from=build-env /go/bin/gaiad /usr/bin/tree

# Copy bootstrap script
COPY bootstrap_gaia.sh .
COPY ci/bootstrap_gaia.sh .

# Set root to change permission
USER root
Expand Down
52 changes: 52 additions & 0 deletions docker-relayer.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#####################################################
#### Build image ####
#####################################################
FROM rust:slim AS build-env

# Output Rust version
RUN cargo --version

# Set working dir
WORKDIR /repo

# Logic to cache cargo dependecies across builds
COPY Cargo.lock .
COPY Cargo.toml .
COPY modules/Cargo.toml /repo/modules/Cargo.toml
COPY proto/Cargo.toml /repo/proto/Cargo.toml
COPY relayer/Cargo.toml /repo/relayer/Cargo.toml
COPY relayer-cli/Cargo.toml /repo/relayer-cli/Cargo.toml
RUN mkdir .cargo
RUN cargo vendor > .cargo/config

# Copy project files
COPY . .

# Build files
RUN cargo build --workspace --all

#####################################################
#### Relayer image ####
#####################################################
FROM rust:slim

# Copy relayer executable
COPY --from=build-env /repo/target/debug/rrly /usr/bin/rrly

ENV RELAYER /relayer

WORKDIR $RELAYER

COPY /repo/vendor /vendor

# Copy configuration file
COPY ci/simple_config.toml .

# Copy setup script
COPY ci/setup_relayer.sh .

# Make it executable
RUN chmod +x setup_relayer.sh

# Entrypoint
ENTRYPOINT ["/bin/sh", "-c", "/relayer/setup_relayer.sh"]
4 changes: 4 additions & 0 deletions modules/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ description = """
Implementation of the Inter-Blockchain Communication Protocol (IBC).
"""

[lib]
name = "ibc"
path = "src/lib.rs"

[features]
# This feature grants access to development-time mocking libraries, such as `MockContext` or `MockHeader`.
# Depends on the `testgen` suite for generating Tendermint light blocks.
Expand Down
4 changes: 4 additions & 0 deletions proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ description = """
ibc-proto is a the Rust implementation of the Cosmos SDK proto structs.
"""

[lib]
name = "ibc_proto"
path = "src/lib.rs"

[package.metadata.docs.rs]
all-features = true

Expand Down
4 changes: 4 additions & 0 deletions relayer-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ authors = [
"Informal Systems <hello@informal.systems>"
]

[[bin]]
name = "rrly"
path = "src/bin/relayer/main.rs"

[dependencies]
relayer = { path = "../relayer" }
ibc = { path = "../modules" }
Expand Down
4 changes: 4 additions & 0 deletions relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ authors = [
"Informal Systems <hello@informal.systems>"
]

[lib]
name = "relayer"
path = "src/lib.rs"

[dependencies]
ibc = { path = "../modules" }
ibc-proto = { version = "0.4.0", path = "../proto" }
Expand Down

0 comments on commit 080cb31

Please sign in to comment.