10 months ago
Hi,
I'm trying to figure out how to use use secrets with Railpack, and could not find any real example.
I'm trying to do something like the following but it seems to be incorrect.
My understanding is that under the hood, Buildpack is using Build secrets, so I would expect GITHUB_TOKEN to be populated withe value of the variable GITHUB_TOKEN in Railway service configuration.
I'm probably misunderstanding something fundamental. Any help really appreciated.
```
{
"$schema": "https://schema.railpack.com",
"secrets": ["GITHUB_TOKEN"],
"steps": {
"setup": {
"secrets": ["*"],
"commands": [
"git config --global url.\"https://${GITHUB_TOKEN}@github.com/\".insteadOf \"https://github.com/\";"
]
}
},
"deploy": {
"startCommand": "uvicorn --port=4100 --host 0.0.0.0 src.main:app"
}
}
```
3 Replies
10 months ago
Hey wnz,
First, I'd read our docs on secrets: https://railpack.com/architecture/secrets
The format you're using looks correct to me. Is there an error that you're encountering? If so can you share your error log?
Status changed to Awaiting User Response Railway • 11 months ago
10 months ago
Hi,
I had read the docs, and really could not figure out where the problem is.
I'm not trying to deploy a service with the following railpack.json file:
{
"$schema": "https://schema.railpack.com",
"secrets": ["TEST_SECRET", "PORT"],
"steps": {
"setup": {
"secrets": ["*"],
"commands": [
"echo 'TEST_SECRET: $TEST_SECRET'",
"echo 'PORT: $PORT'",
"ls -la /run/secrets"
]
}
},
"deploy": {
"startCommand": "uvicorn --port=${PORT} --host 0.0.0.0 src.main:app"
}
}
And I get logs in the attached image.
The service has TEST_SECRET and PORT env variables set in the Variables section.
If my understanding is correct, secrets should be mounted as files in /run/secrets/
Could you please clarify or provide an example railpack.json file to deploy a test service with secrets from variables?
Attachments
Status changed to Awaiting Railway Response Railway • 11 months ago
10 months ago
Hello,
When on Railway building with Railpack, all service variables will automatically be available to the build context.
Can you try removing your railpack.json file and provide the actual error? I have a feeling your issue lies elsewhere and you are going down a rabbit hole.
Best,
Brody
Status changed to Awaiting User Response Railway • 11 months ago
7 months ago
This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!
Status changed to Solved Railway • 7 months ago