10 months ago
I have a build variable which is a secret, your system does not support build secret so I am forced to use variables, so i add it and seal it, seems good...
No, because when dockerfile is being executed, it prints out every command including the secret!
Why does seal not prevent the value from being printed? seems like an oversight to me!
3 Replies
Status changed to Awaiting User Response Railway • 10 months ago
brody
Hello, It would be best to avoid using variables directly in commands.
10 months ago
I'd love to know how, literally all the docs say RUN --mount=type=secret but then railway says no...
Status changed to Awaiting Railway Response Railway • 10 months ago
a month ago
Sealing hides the value from Railway's UI/API; it still reaches builds and deployments. It is not documented as a guarantee against a build command printing the value. Sealed-variable docs.
Railway's Dockerfile path uses build ARGs; staff confirm secret mounts are unsupported. Moving an ARG into a script is not equivalent security: it can remain in image metadata.
To keep your Dockerfile and use real secret mounts, build in CI, then deploy the prebuilt image on Railway:
- Map your CI secret to the runner environment variable
BUILD_TOKEN. Remove its Dockerfile ARG/ENV declarations. Mount it only where needed:
# syntax=docker/dockerfile:1
RUN --mount=type=secret,id=BUILD_TOKEN,env=BUILD_TOKEN,required=true \
./build.sh- After registry authentication, build and push from CI:
docker buildx build --secret id=BUILD_TOKEN,env=BUILD_TOKEN -t REGISTRY/APP:TAG --push .Replace the image placeholder and adapt build.sh; it reads BUILD_TOKEN from its environment. No token value goes in that command. Docker secret docs, GitHub Actions mapping.
- Select that image as Railway's source: image deployment guide. Private registries require Pro.
The build tool must not print or embed the token in artifacts; mounts do not prevent that. Rotate the exposed token and test first with a harmless canary.
AI-assisted; source-checked. I have not executed this Docker build or tested your service.