Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide the ability to use the same environment as a running container for job-run jobs #247

Open
kopf opened this issue Nov 24, 2023 · 3 comments

Comments

@kopf
Copy link

kopf commented Nov 24, 2023

I'd love to use job-run to run my cronjobs - spinning up a new container to service each cronjob. However, my cronjobs (primarily django management jobs) require an awful lot of environment variables to be set in order to do their job.

Therefore, the easiest solution is to simply run them on an already running webserver container. The only problem with this is that they're killed if the webserver container is cycled.

So - wouldn't it be great if we could provide a simple "copy the environment of container X" directive for job-run jobs? Is this possible? If so, I'll have a look at its implementation. If not, thank you for letting me know and saving me the time and effort.

@s-celles
Copy link
Contributor

I wonder if job-run can be used with Docker labels (see my question #270)
This could be a solution to your problement as you could simply copy paste in docker-compose.yml environment variables from one service to an another one.

@kopf
Copy link
Author

kopf commented Apr 11, 2024

@scls19fr - this is undesirable as it would break the DRY principle. You'd have multiple places to update environment variables when they're changed.

@s-celles
Copy link
Contributor

s-celles commented Apr 11, 2024

I understand. Maybe you can put values into a .env file like so

MYSERVER_NAME=myserver
[email protected]

and use docker-compose.yml like so

environment:
  - MYSERVER_NAME=${MYSERVER_NAME}
  - MYSERVER_EMAIL=${MYSERVER_EMAIL}

so you won't have to modify you docker-compose into several places... just one your .env file (to avoid to repeat yourself).

That's just an idea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants