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!
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
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.