Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker file #45

Merged
merged 10 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

# BUILD BIN

FROM golang:1.22.0 as builder
# Install go modules
WORKDIR /flow-evm-gateway
COPY go.* ./
COPY . ./
RUN go mod download
RUN go mod verify
RUN CGO_ENABLED=0 go build -o evm-gateway ./cmd/server/main.go
RUN chmod a+x evm-gateway
RUN chmod a+x ./scripts/run.sh

RUN wget https://github.com/m-Peter/flow-cli-custom-builds/raw/main/flow-x86_64-linux-
RUN chmod a+x flow-x86_64-linux-

# RUN APP
FROM debian:latest
WORKDIR /flow-evm-gateway
COPY --from=builder /flow-evm-gateway/evm-gateway /flow-evm-gateway/evm-gateway
COPY --from=builder /flow-evm-gateway/flow-x86_64-linux- /flow-evm-gateway/flow-x86_64-linux-
COPY --from=builder /flow-evm-gateway/flow.json /flow-evm-gateway/flow.json
COPY --from=builder /flow-evm-gateway/api/cadence/transactions/create_bridged_account.cdc /flow-evm-gateway/create_bridged_account.cdc
COPY --from=builder /flow-evm-gateway/scripts/run.sh /flow-evm-gateway/run.sh
EXPOSE 8545
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to expose this so it can be templated and set externally

CMD cd /flow-evm-gateway && ./run.sh
4 changes: 2 additions & 2 deletions api/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestServerJSONRPCOveHTTPHandler(t *testing.T) {
blockchainAPI := api.NewBlockChainAPI(config, store, mockFlowClient)
supportedAPIs := api.SupportedAPIs(blockchainAPI)
srv.EnableRPC(supportedAPIs)
srv.SetListenAddr("localhost", 8545)
srv.SetListenAddr("", 8545)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious, did you encounter a problem with "localhost"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, there was an issue in cloud run
it's a specific requirement for cloud run

The ingress container within an instance must listen for requests on 0.0.0.0 on the port to which requests are sent.

https://cloud.google.com/run/docs/container-contract

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comment as above about the port needing to be an injected variable

err := srv.Start()
defer srv.Stop()
if err != nil {
Expand Down Expand Up @@ -460,7 +460,7 @@ func TestServerJSONRPCOveWebSocketHandler(t *testing.T) {
blockchainAPI := api.NewBlockChainAPI(config, store, flowClient)
supportedAPIs := api.SupportedAPIs(blockchainAPI)
srv.EnableWS(supportedAPIs)
srv.SetListenAddr("localhost", 8545)
srv.SetListenAddr("", 8545)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment

err = srv.Start()
defer srv.Stop()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func runServer(config *api.Config, store *storage.Store, logger zerolog.Logger)
srv.EnableRPC(supportedAPIs)
srv.EnableWS(supportedAPIs)

srv.SetListenAddr("localhost", 8545)
srv.SetListenAddr("", 8545)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same again


err = srv.Start()
if err != nil {
Expand Down
23 changes: 23 additions & 0 deletions scripts/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# Start the first process & redirect output to a temporary file
./flow-x86_64-linux- emulator --evm-enabled > temp_output.txt &

# PID of the first process
FIRST_PROCESS_PID=$!

# Monitor the temporary file for a specific output
PATTERN="3569"
while ! grep -q "$PATTERN" temp_output.txt; do
sleep 1
done

# Once the pattern is found, you can kill the first process if needed
# kill $FIRST_PROCESS_PID

# Run the second process

./flow-x86_64-linux- transactions send /flow-evm-gateway/create_bridged_account.cdc 1500.0 --network=emulator --signer=emulator-account && ./evm-gateway
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to be able to pass in the network to be used, whether emulator or other network


# Clean up temporary file
rm temp_output.txt
Loading