10 months ago
The objective I am trying to achieve is to: apply database migrations.
I have followed the docs the best I can to achieve this. My attempt now is to try and run migrations before pre-deployment by including the steps in the railpack.json file like so:
```json
{
"$schema": "https://schema.railpack.com",
"steps": {
"install": {
"commands": [
"curl -fsSL https://github.com/amacneil/dbmate/releases/latest/download/dbmate-linux-amd64 -o /usr/local/bin/dbmate && chmod +x /usr/local/bin/dbmate"
]
},
"migrate": {
"inputs": [{ "step": "install" }],
"commands": [
"dbmate --wait-timeout=10s up"
]
}
},
"deploy": {
"startCommand": "hypercorn main:app --bind \"[::]:$PORT\""
}
}The migration cli dbmate reads the env variable DATABASE_URL which I set it to reference the postgres service's own private DATABASE_URL. However, I get an error when it runs. The error says:
dbmate --wait-timeout=10s up
549ms
Error: dial tcp: lookup postgres.railway.internal on 169.254.169.254:53: no such hostThe complete logs are attached here for reference:
[Region: us-west1]
╭─────────────────╮
│ Railpack 0.13.0 │
╰─────────────────╯
↳ Using config file `railpack.json`
⚠ The config file format is not yet finalized and subject to change.
↳ Found .dockerignore file, applying filters
↳ Detected Python
↳ Using uv
Packages
──────────
uv │ 0.9.11 │ railpack default (latest)
python │ 3.13.9 │ railpack default (3.13)
Steps
──────────
▸ install
$ curl -fsSL https://github.com/amacneil/dbmate/releases/latest/download/dbmate-linux-amd64 -o /usr/local/bin/dbmate && chmod +x /usr/local/bin/dbmate
▸ build
$ uv sync --locked --no-dev --no-editable
▸ migrate
$ dbmate --wait-timeout=10s up
Deploy
──────────
$ hypercorn main:app --bind "[::]:$PORT"
Successfully prepared Railpack plan for build
context: p552-Nko5
load build definition from railpack-plan.json
0ms
copy .python-version
78ms
install mise packages: python, uv
3s
mise uv@0.9.11 ✓ installed
curl -fsSL https://github.com/amacneil/dbmate/releases/latest/download/dbmate-linux-amd64 -o /usr/local/bin/dbmate && chmod +x /usr/local/bin/dbmate
990ms
copy /mise/shims, /mise/installs, / /app
1s
dbmate --wait-timeout=10s up
549ms
Error: dial tcp: lookup postgres.railway.internal on 169.254.169.254:53: no such host
uv sync --locked --no-dev --no-editable
450ms
runc run failed: container process is already dead
copy /usr/local/bin/mise
45ms
ERROR: failed to build: failed to solve: process "sh -c dbmate --wait-timeout=10s up" did not complete successfully: exit code: 2Pinned Solution
10 months ago
Hey, private networking is not available in the build process. Please add a pre-deploy command: https://docs.railway.com/guides/pre-deploy-command#%5F%5Fnext. Also, after that feel free to remove the railpack.json as it's not necessary.
2 Replies
10 months ago
Hey there! We've found the following might help you get unblocked faster:
- 🧵 unable to connect PG database from Springboot API
- 🧵 Variable reference not working
- 🧵 internal network not accessible
If you find the answer from one of these, please let us know by solving the thread!
10 months ago
Hey, private networking is not available in the build process. Please add a pre-deploy command: https://docs.railway.com/guides/pre-deploy-command#%5F%5Fnext. Also, after that feel free to remove the railpack.json as it's not necessary.
Status changed to Solved brody • 11 months ago