Replies: 1 comment 1 reply
-
I ran into this issue as well using Kamal 2. It looks like Next.js requires a .env file inside the container, and the secrets from Kamal are only supplied at Docker runtime, so it doesn't work. I mentioned the solution I came up with here #925 (comment). The issue with this currently is that I have to keep changing my .env before deploying, which is annoying. I was thinking of adding a pre-build step where it copies the .kamal/secrets to a .env file. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, I have build a simple nextjs app for trying to understand kamal better before I use it in production. What I need to do is that I have variables in my code that are taken form the .env file. Locally it runs perfectly but I want to use them also when kamal deploys this app.
Steps I have followed
Fist created the nextjs app using one the free templates that nextjs offers. Then initialized kamal and git in this folder. Now the
kamal init
command created files like in the documentation, one of them being .env. Now inside this .env I put the variables that kamal generated and the variables I use in my code. Then committed the repository and rankamal setup
command. Everything went smoothly and deployment was successful. When I open the page in my web browser where I have used the variable that I added, the value of that isn't retrived.What I have tried
I read the documentation and tried to use the
kamal env push
but it doesn't do anything. Tried to add the env block in thedeploy.yml
like this:and ran
kamal env push
but not working either. Also tried withkamal deploy
but no luck either. How I use this variable VALUE is simple, as I said I am doing it just for testing purposes, like this:Would appreciate any help. Maybe i am missing something or doing it wrong but I am new to programming and the kamal tool and would like to really learn it. If you have any question please do ask me.Thank you!
Also if you have please do provide and tips or tricks to keep in mind when configuring the
deploy.yml
Beta Was this translation helpful? Give feedback.
All reactions