Skip to content

Commit

Permalink
feat: integrate docker setup (#8)
Browse files Browse the repository at this point in the history
* chore: add .env file to gitignore

* feat: allow setting bidder address via environment variable

* chore: add env.example file with configuration placeholders

* feat: integrate docker setup
  • Loading branch information
iowar authored Oct 9, 2024
1 parent 21d286c commit b933d2b
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ mev-commit_0.3.0_Linux_x86_64.tar.gz
launchmevcommit
*.swp
**/data/*
.env
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM golang:1.23-alpine AS builder

WORKDIR /app
COPY . .

RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w" -o bidder ./cmd/sendblob.go

FROM alpine:latest


RUN apk --no-cache add curl
RUN apk add --no-cache jq

COPY --from=builder /app/bidder /app/bidder
COPY --from=builder /app/entrypoint.sh /entrypoint.sh

RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
up-bidder:
@if [ ! -f .env ]; then \
echo "\033[31mOops! \033[91mLooks like the \033[93m.env \033[91mfile is missing. 😱\n\033[96mPlease ensure the \033[93m.env \033[96mfile exists before running this command.\033[0m"; \
exit 1; \
fi; \
docker compose --profile bidder up --build -d

down:
@echo "\033[96mShutting down services from default docker compose file...\033[0m"
docker compose --profile bidder down --remove-orphans


7 changes: 6 additions & 1 deletion cmd/sendblob.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,13 @@ func main() {
log.Crit("Failed to authenticate private key:", "err", err)
}

bidderAddress := os.Getenv("BIDDER_ADDRESS")
if bidderAddress == "" {
bidderAddress = "127.0.0.1:13524"
}

cfg := bb.BidderConfig{
ServerAddress: "127.0.0.1:13524",
ServerAddress: bidderAddress,
LogFmt: "json",
LogLevel: "info",
}
Expand Down
22 changes: 22 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
services:
bidder:
build:
context: .
dockerfile: Dockerfile
container_name: bidder
environment:
BIDDER_ADDRESS: 10.0.0.1:13524
env_file:
- .env
entrypoint: ./entrypoint.sh
profiles:
- bidder
networks:
primev_net:
ipv4_address: 10.0.0.2

networks:
primev_net:
ipam:
config:
- subnet: 10.0.0.0/16
8 changes: 8 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

/app/bidder \
--rpc-endpoints ${RPC_ENDPOINTS} \
--ws-endpoint ${WS_ENDPOINT} \
--privatekey ${PRIVATE_KEY} \
--use-payload ${USE_PAYLOAD}

4 changes: 4 additions & 0 deletions env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
RPC_ENDPOINTS="http://52.11.201.67:8545/"
WS_ENDPOINT="ws://52.11.201.67:8546/"
PRIVATE_KEY=
USE_PAYLOAD=true

0 comments on commit b933d2b

Please sign in to comment.