(KeyError) key :database not found
on migration run when running blockscout-optimism:latest
backend for OP Rollup in AWS ECS
#8993
-
Hi, Does anyone have an idea why a I'm attempting to deploy the blockscout containers to an AWS ECS instance using custom terraform. I translated the docker compose setup to a terraform setup that spins up blockscout and indexes an OP stack chain (OP Rollup). This is my AWS ECS task definition json for my database and backend containers. ( {
"name": "db",
"image": "postgres:14",
"cpu": 1638,
"memory": 6294,
"portMappings": [
{
"containerPort": 5432,
"hostPort": 7432,
"protocol": "tcp"
}
],
"essential": false,
"command": [
"postgres",
"-c",
"max_connections=200",
"-c",
"client_connection_check_interval=60000"
],
"environment": [
{
"name": "POSTGRES_USER",
"value": "blockscout"
},
{
"name": "POSTGRES_PASSWORD",
"value": "ceWb1MeLBEeOIfk65gU8EjF8"
},
{
"name": "POSTGRES_DB",
"value": "blockscout"
}
],
"mountPoints": [
{
"sourceVolume": "scripts",
"containerPath": "/scripts",
"readOnly": false
},
{
"sourceVolume": "blockscout-db-data",
"containerPath": "/var/lib/postgresql/data",
"readOnly": false
}
],
"volumesFrom": [],
"dependsOn": [
{
"containerName": "db-init",
"condition": "COMPLETE"
}
],
"user": "2000:2000",
"healthCheck": {
"command": [
"CMD-SHELL",
"pg_isready -U blockscout -d blockscout"
],
"interval": 10,
"timeout": 5,
"retries": 5,
"startPeriod": 10
}
},
{
"name": "backend",
"image": "blockscout/blockscout-optimism:latest",
"cpu": 1638,
"memory": 6294,
"links": [
"db:database"
],
"portMappings": [],
"essential": false,
"entryPoint": [
"/scripts/backend-start.sh"
],
"environment": [],
"mountPoints": [
{
"sourceVolume": "scripts",
"containerPath": "/scripts",
"readOnly": false
},
{
"sourceVolume": "logs",
"containerPath": "/app/logs",
"readOnly": false
}
],
"volumesFrom": [],
"dependsOn": [
{
"containerName": "database",
"condition": "HEALTHY"
},
{
"containerName": "redis-db",
"condition": "START"
}
],
} I use a command to start up the database container: This is the content of my backend container entrypoint script: #!/bin/sh
source /scripts/common-blockscout.env
bin/blockscout eval "Elixir.Explorer.ReleaseTasks.create_and_migrate()"
exec bin/blockscout start
This setup runs fine until the backend attempts to run its migrations with:
This looks like the blockscout database doesn't exist but I've logged into the running database container and verified that a database named ''blockscout" exists within postgres inside of the container It also looks like it could be an issue with the connection between the backend and database containers, but I've manually logged into a running backend container and I then used
Any idea why this might be happening? Backend environment variablesblockckscout-common.envs
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Run the backend container manually once more and recheck that your envs are in place via |
Beta Was this translation helpful? Give feedback.
-
Turns out that the blockscout binary didn't have access to the sourced envs. I needed to export the envs. Updated my entrypoint script and it works like a charm #!/bin/sh
set -a
source /scripts/common-blockscout.env
set +a
bin/blockscout eval "Elixir.Explorer.ReleaseTasks.create_and_migrate()"
exec bin/blockscout start |
Beta Was this translation helpful? Give feedback.
Turns out that the blockscout binary didn't have access to the sourced envs.
I needed to export the envs. Updated my entrypoint script and it works like a charm