I am trying to deploy and I’m getting the error:
[2025-04-24 04:32:32] │ INFO[0033] Executing 0 build triggers
[2025-04-24 04:32:32] │ INFO[0033] Building stage 'alpine:latest' [idx: '1', base-idx: '-1']
[2025-04-24 04:32:32] │ error building image: error building stage: failed to optimize instructions: failed to get files used from context: failed to get fileinfo for /kaniko/0/app/.env: lstat /kaniko/0/app/.env: no such file or directory
[2025-04-24 04:32:32].
I am using golang:1.24-alpine
but it’s not working. Can you help me check wha’t going on? Locally, the app works properly.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi there,
Looks like the build is failing because it can’t find your
.env
file during the Docker build. In local dev, the file is probably there, but in the remote build context (like with DigitalOcean’s App Platform), only files explicitly added get included.If your Dockerfile has something like
COPY . .
, but.env
is in your.dockerignore
, it won’t be copied. Either remove.env
from.dockerignore
or pass environment variables another way, like through the App Platform’s “Environment Variables” section (which is actually the recommended way).- Bobby
Heya, @pauladeyenuwo
On top of what’s mentioned you can check our docs on How to Use Environment Variables in App Platform:
https://docs.digitalocean.com/products/app-platform/how-to/use-environment-variables/
Regards