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

Run JetStream without command #110

Open
Lancetnik opened this issue Jul 3, 2023 · 9 comments
Open

Run JetStream without command #110

Lancetnik opened this issue Jul 3, 2023 · 9 comments

Comments

@Lancetnik
Copy link

Is any abilities to configure nats conatiner to run with JetStream mode without using command argument (special label, env variable, etc)?
Now I can't find any official solution to run NatsJS as a Github Action service (GHA doesn't support command attribute).
I don't wont to use or create custom image on top of the official one, suppose, should be a legal solution.

@bruth
Copy link
Member

bruth commented Jul 4, 2023

Hi @Lancetnik, are you saying you don't want to pass a command argument to docker run? e.g.

docker run -p 4222:4222 nats -js

If so, why?

The alternative is to create a config file and mount it at /etc/nats/nats-server.conf

docker run -p 4222:4222 -v nats.conf:/etc/nats/nats-server.conf nats

Where the config file would, at a minimum, be:

jetstream: enabled

Out of curiosity, what is the use case for running it in Github Actions?

@Lancetnik
Copy link
Author

I am working on event-driven framework and should test a huge part of functions on a real external dependencies.
So, I have a some e2e test with real services in my CI
Decision with a config file should be what I need to do, but manipulating volumes in CI is not so comfortable too, by it is still the way.
Little note: configuration of container services via env variables is a lead practice, can't understand why NATS choose a command arguments way

@Lancetnik
Copy link
Author

docker run -p 4222:4222 nats -js

GHA syntax pretty close to docker-compose, but there no option to setup command argument like we can do in compose

nats:
    image: nats
    command: -js
    ports:
      - 4222:4222
      - 8222:8222  

@Lancetnik
Copy link
Author

@bruth anyway, thx for the answer. Will try to include config volume to my CI

@ripienaar
Copy link

Agree something more flexible in the container would be nice.

But there are some options as pointed out, I do it by just replacing the entry point until something better exist.

https://github.com/nats-io/jetstream-gh-action/blob/03c67127e04647dc7b0fea6ee243a3284dd87c95/.github/workflows/update.yaml#L17

As nats (and the containers) are open source you are welcome to contribute improvements.

@Lancetnik
Copy link
Author

@ripienaar thanks, it looks better than config as a volume

@bruth
Copy link
Member

bruth commented Jul 4, 2023

@Lancetnik Understood regarding the env-to-config pattern for containers. It simply has not been something strongly requested, so supported was not added proactively.

A simple option would be to support -e NATS_ARGS="-js" for passing CLI options. I have seen fancier implementations where env vars map to config-file options and the container builds the config based on the passed options.

However, in the meantime, go with @ripienaar's suggestion to not deal with the volume.

@Lancetnik
Copy link
Author

@bruth looks like you can add smth like get_env_or_default instead simple default to all of these functions to check flags from env at first here

This way we have a priority: default < env < config < command-line, that looks reasonable

@Lancetnik
Copy link
Author

-e NATS_ARGS="-js"

Looks worse, I suppose, cuz u need to merge it with a command-line args and solve duplications

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

3 participants