Replies: 9 comments 4 replies
-
It would be better if |
Beta Was this translation helpful? Give feedback.
-
Another idea is passing the destination with the
This also has the benefit of not breaking or modifying the current workflow, it's more of an opt-in process. Some people really will have just one remote destination and that's perfectly fine. |
Beta Was this translation helpful? Give feedback.
-
+1 on changing Depending on how your Rails app is configured, it may automatically pick up ENV vars from A few things have to go wrong for this to happen, but it's not that far fetched. I came pretty far into this process myself, but caught it just on time. |
Beta Was this translation helpful? Give feedback.
-
Kamal already generates a The current default seems to be intended for CI where the risk of overriding vars is much lower. |
Beta Was this translation helpful? Give feedback.
-
Did I understood this conversation correctly, kamal does not enable for multiple environments, e.g. dev, stage, prod? |
Beta Was this translation helpful? Give feedback.
-
I've found a good solution to support several hosts (production, demo, etc.) with the same config but different env values. service: <%= ENV['DOCKER_CONTAINER'] %>
image: <%= ENV['DOCKER_IMAGE'] %>
registry:
server: <%= ENV['DOCKER_SERVER'] %>
username: <%= ENV['DOCKER_USERNAME'] %>
password:
- DOCKER_REGISTRY_PASSWORD
ssh:
user: <%= ENV['SERVER_USER'] %>
... and # Just copied one line to avoid an error of the nil Hash keys
service: <%= ENV['DOCKER_CONTAINER'] %> and added ################################################# Docker
DOCKER_SERVER=registry.gitlab.com
DOCKER_USERNAME=user
DOCKER_REGISTRY_PASSWORD=glpat-token
DOCKER_IMAGE=user/myapp/myapp-demo
DOCKER_CONTAINER=myapp-demo
################################################# Server
SERVER_USER=deployer
SERVER_IP=1.2.3.4
SERVER_HOSTNAME=myapp.host.org
################################################# DB Postgres
DB_HOST=1.2.3.4
DB_NAME=DB_NAME
DB_USER=deployer
POSTGRES_PASSWORD=pass
# ... Deploy works smoothly:
If you need more servers, just create yet one-line file Also, there is the full process of Rails project deployment with Kamal https://github.com/abratashov/kamal-blog/blob/main/docs/install_prod.md |
Beta Was this translation helpful? Give feedback.
-
Here to cross reference rails/rails#51829. There really seem to be some problems related to Kamal/Foreman/DotEnv confusions. |
Beta Was this translation helpful? Give feedback.
-
This is really bad, I just connected to my production database running rails console in development - had no idea DATABASE_URL ENV var would override my development db settings |
Beta Was this translation helpful? Give feedback.
-
+1 - not as severe as In hindsight this was trivial to realize/fix, I should have known better, lesson learned, etc. That said... the suggested fix would be awesome. |
Beta Was this translation helpful? Give feedback.
-
Background: The
.env
file is used for development secrets and config for many developers but Kamal treats it like 'production' data.The developer experience of kamal initializing a config/deploy.yml file and associating that with a
.env
file feels not explicit enough.What if instead
kamal init
:config/deploy.production.yml
file.env.production
file it not already existingThis would be less surprising to me. By default I'm using Kamal to deploy to production and associating a .env.production file with it.
The current setup of
config/deploy.yml
and a.env
file made me confused how I could modify it to support production secrets. Would I have to use some different mechanism, switch to Rails credentials completely, do some manual switching out of .env* files just before runningkamal env push
andkamal env deploy
, etc. I think it Kamal was more explicit by generatingconfig/deploy.production.yml
out the gate this confusion would be minimized.Beta Was this translation helpful? Give feedback.
All reactions