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

feat: enable SSL for block explorer #24

Merged
merged 6 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
4 changes: 2 additions & 2 deletions configs/l2-explorer/envs/common-frontend.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NEXT_PUBLIC_API_HOST=${COMMON_HOST}
NEXT_PUBLIC_API_PROTOCOL=http
NEXT_PUBLIC_API_PROTOCOL=https
NEXT_PUBLIC_NETWORK_NAME=${L2_CHAIN_NAME}
NEXT_PUBLIC_NETWORK_SHORT_NAME=${L2_CHAIN_NAME}
NEXT_PUBLIC_NETWORK_ID=${L2_CHAIN_ID}
Expand All @@ -15,7 +15,7 @@ NEXT_PUBLIC_APP_PROTOCOL=http
NEXT_PUBLIC_HOMEPAGE_CHARTS=['daily_txs']
NEXT_PUBLIC_VISUALIZE_API_HOST=http://${COMMON_HOST}:8083
NEXT_PUBLIC_IS_TESTNET=true
NEXT_PUBLIC_API_WEBSOCKET_PROTOCOL=ws
NEXT_PUBLIC_API_WEBSOCKET_PROTOCOL=wss
NEXT_PUBLIC_API_SPEC_URL=https://raw.githubusercontent.com/blockscout/blockscout-api-v2-swagger/main/swagger.yaml
NEXT_PUBLIC_NETWORK_LOGO=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-logos/optimism.svg
NEXT_PUBLIC_NETWORK_ICON=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/optimism-short.svg
Expand Down
11 changes: 9 additions & 2 deletions scripts/l2-explorer/l2-blockscout-set-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ L1_SYSTEM_CONFIG_ADDRESS=$(jq -r '.l1_system_config_address' "$ROLLUP_JSON")
OUTPUT_ORACLE_ADDRESS=$(jq -r '.L2OutputOracleProxy' "$OP_DEPLOYMENTS_JSON_PATH")

# Update .explorer.env file
sed -i "s/^L1_SYSTEM_CONFIG_CONTRACT=.*/L1_SYSTEM_CONFIG_CONTRACT=$L1_SYSTEM_CONFIG_ADDRESS/" "$ENV_FILE"
sed -i "s/^L1_OUTPUT_ORACLE_CONTRACT=.*/L1_OUTPUT_ORACLE_CONTRACT=$OUTPUT_ORACLE_ADDRESS/" "$ENV_FILE"
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
sed -i '' "s|^L1_SYSTEM_CONFIG_CONTRACT=.*|L1_SYSTEM_CONFIG_CONTRACT=$L1_SYSTEM_CONFIG_ADDRESS|" "$ENV_FILE"
sed -i '' "s|^L1_OUTPUT_ORACLE_CONTRACT=.*|L1_OUTPUT_ORACLE_CONTRACT=$OUTPUT_ORACLE_ADDRESS|" "$ENV_FILE"
else
# Linux and others
sed -i "s|^L1_SYSTEM_CONFIG_CONTRACT=.*|L1_SYSTEM_CONFIG_CONTRACT=$L1_SYSTEM_CONFIG_ADDRESS|" "$ENV_FILE"
sed -i "s|^L1_OUTPUT_ORACLE_CONTRACT=.*|L1_OUTPUT_ORACLE_CONTRACT=$OUTPUT_ORACLE_ADDRESS|" "$ENV_FILE"
fi
Copy link
Member

Choose a reason for hiding this comment

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

we can also use the sed -i.bak which works on both macOS and Linux, but need to remove the generated backup file, like:

sed -i.bak "s|^L1_SYSTEM_CONFIG_CONTRACT=.*|L1_SYSTEM_CONFIG_CONTRACT=$L1_SYSTEM_CONFIG_ADDRESS|" "$ENV_FILE"
rm $ENV_FILE.bak

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, updated!

echo "Updated .explorer.env file for Blockscout"
18 changes: 18 additions & 0 deletions scripts/l2-explorer/l2-explorer-restart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
Copy link
Member

@bap2pecs bap2pecs Oct 25, 2024

Choose a reason for hiding this comment

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

should we add a Make command?

Copy link
Member

Choose a reason for hiding this comment

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

#25


set -e

# Run the l2-blockscout-set-env.sh script
"$(pwd)/scripts/l2-explorer/l2-blockscout-set-env.sh"

# Source the .env.explorer file
set -a
source $(pwd)/.env
source $(pwd)/.env.explorer
set +a

# Stop services
docker compose -f "$(dirname "$0")/../../docker/docker-compose-l2-explorer.yml" stop backend frontend stats smart-contract-verifier visualizer sig-provider visualizer-proxy proxy

# Start services
docker compose -f "$(dirname "$0")/../../docker/docker-compose-l2-explorer.yml" up -d backend frontend stats smart-contract-verifier visualizer sig-provider visualizer-proxy proxy