96 lines
2.1 KiB
Markdown
96 lines
2.1 KiB
Markdown
|
|
# Fix YAML Quote Issues in docker-compose.yml
|
||
|
|
|
||
|
|
## Problem
|
||
|
|
Docker Compose is failing with "No closing quotation" error because the command string has nested quotes that aren't properly escaped.
|
||
|
|
|
||
|
|
## Solution: Use YAML List Format
|
||
|
|
|
||
|
|
Instead of:
|
||
|
|
```yaml
|
||
|
|
command: sh -c "bin/blockscout eval \"Explorer.Release.migrate()\" && bin/blockscout start"
|
||
|
|
```
|
||
|
|
|
||
|
|
Use YAML list format:
|
||
|
|
```yaml
|
||
|
|
command:
|
||
|
|
- sh
|
||
|
|
- -c
|
||
|
|
- "bin/blockscout eval \"Explorer.Release.migrate()\" && bin/blockscout start"
|
||
|
|
```
|
||
|
|
|
||
|
|
## Commands to Fix
|
||
|
|
|
||
|
|
```bash
|
||
|
|
cd /opt/blockscout
|
||
|
|
|
||
|
|
# Backup
|
||
|
|
cp docker-compose.yml docker-compose.yml.backup3
|
||
|
|
|
||
|
|
# Fix using Python
|
||
|
|
python3 << 'PYTHON'
|
||
|
|
import re
|
||
|
|
|
||
|
|
with open('docker-compose.yml', 'r') as f:
|
||
|
|
lines = f.readlines()
|
||
|
|
|
||
|
|
new_lines = []
|
||
|
|
i = 0
|
||
|
|
while i < len(lines):
|
||
|
|
line = lines[i]
|
||
|
|
# Check if this is a command line with blockscout start
|
||
|
|
if 'command:' in line and ('blockscout start' in line or '/app/bin/blockscout start' in line):
|
||
|
|
# Replace with YAML list format
|
||
|
|
indent = len(line) - len(line.lstrip())
|
||
|
|
new_lines.append(' ' * indent + 'command:\n')
|
||
|
|
new_lines.append(' ' * (indent + 2) + '- sh\n')
|
||
|
|
new_lines.append(' ' * (indent + 2) + '- -c\n')
|
||
|
|
new_lines.append(' ' * (indent + 2) + '- "bin/blockscout eval \\"Explorer.Release.migrate()\\" && bin/blockscout start"\n')
|
||
|
|
i += 1
|
||
|
|
# Skip continuation lines if any
|
||
|
|
while i < len(lines) and (lines[i].strip().startswith('-') or lines[i].strip() == ''):
|
||
|
|
i += 1
|
||
|
|
continue
|
||
|
|
new_lines.append(line)
|
||
|
|
i += 1
|
||
|
|
|
||
|
|
with open('docker-compose.yml', 'w') as f:
|
||
|
|
f.writelines(new_lines)
|
||
|
|
|
||
|
|
print("✅ Updated docker-compose.yml")
|
||
|
|
PYTHON
|
||
|
|
|
||
|
|
# Verify
|
||
|
|
grep -A 4 "command:" docker-compose.yml
|
||
|
|
|
||
|
|
# Start
|
||
|
|
docker-compose up -d blockscout
|
||
|
|
```
|
||
|
|
|
||
|
|
## Alternative: Manual Edit
|
||
|
|
|
||
|
|
If Python doesn't work, edit manually:
|
||
|
|
|
||
|
|
```bash
|
||
|
|
cd /opt/blockscout
|
||
|
|
nano docker-compose.yml
|
||
|
|
```
|
||
|
|
|
||
|
|
Find:
|
||
|
|
```yaml
|
||
|
|
command: /app/bin/blockscout start
|
||
|
|
```
|
||
|
|
|
||
|
|
Replace with:
|
||
|
|
```yaml
|
||
|
|
command:
|
||
|
|
- sh
|
||
|
|
- -c
|
||
|
|
- "bin/blockscout eval \"Explorer.Release.migrate()\" && bin/blockscout start"
|
||
|
|
```
|
||
|
|
|
||
|
|
Save and exit, then:
|
||
|
|
```bash
|
||
|
|
docker-compose up -d blockscout
|
||
|
|
```
|
||
|
|
|