Popularity
0.6
Declining
Activity
0.0
Declining
2
2
0

Description

`run` replaces _tokens_ in a config file tempalte by values from the specific data sources, saves a new config file and executes a command.

It was designed to be used in _docker containers_ where a config file should receive values from the data sources before running the container's command.

Programming language: Go
License: MIT License
Tags: Utilities     Command Line     Configuration     Tools     Template     Files    
Latest version: v1.3.1

run alternatives and similar packages

Based on the "Command Line" category.
Alternatively, view run alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of run or a related project?

Add another 'Command Line' Package

README

Codeship Codecov Go Report Card

run

run replaces tokens in a config file tempalte by values from the specific data sources, saves a new config file and executes a command.

It was designed to be used in docker containers where a config file should receive values from the data sources before running the container's command.

Data sources

  • Environment variables
  • Local JSON file
  • Remote JSON file
  • AWS SecretManager

Options

--input value, -i value        The config template with the tokens to be replaced [$RUN_INPUT]
--output value, -o value       The output path for the compiled config file [$RUN_OUTPUT]
--delay value, -d value        Number of seconds to wait before running the command (default: 0) [$RUN_DELAY]
--json value, -j value         JSON data to be used by JSONLoader [$RUN_JSON]
--remote-json value, -r value  URL to a JSON file to be used by RemoteJSONLoader [$RUN_REMOTE_JSON]
--json-file value, -f value    Path to a JSON file to be used by JSONFileLoader [$RUN_JSON_FILE]
--aws-secret value             The ARN or name of a secret with a JSON encoded value [$RUN_AWS_SECRET_ARN]
--env-file value               A dotenv file template to be rendered and added to the environment [$RUN_ENV_FILE]
--env-output-var value         Create a environment variable with the contents of the output file [$RUN_ENV_OUTPUT_VAR]
--help, -h                     show help
--version, -v                  print the version

Example

The example below is of a container with a webserver but before starting the server it will compile the config file template using the run command.

Environment variables (.env)

MONGO_URL="mongodb://user:[email protected]/mydb"
JWT_SECRET="my$uper$ecret"
SERVER_BIND="0.0.0.0"
SERVER_PORT="8000"

Local JSON file (/mnt/shared/secrets/vars.json)

{
  "server": {
    "bind": "0.0.0.0"
  }
}

Remote JSON file (http://config-service/app/config.json)

{
  "server": {
    "port": "1234"
  }
}

AWS SecretManager

Secret name: jwtconfig

{
  "jwt": {
    "secret": "myjwtsecret"
  }
}

Config template (config.toml.dist)

[database]
url = "{{MONGO_URL}}"

[jwt]
secret = "{{jwt.secret|JWT_SECRET}}"

[server]
bind = "{{server.bind|SERVER_BIND}}"
port = "{{server.port|SERVER_PORT}}"

Dockerfile

FROM busybox:1.25.1

MAINTAINER Tarcisio Gruppi <[email protected]>

ADD https://github.com/txgruppi/run/releases/download/0.0.1/run_linux_amd64 /app/run
ADD ./config.toml.dist /app/config.toml.dist
ADD ./server /app/server

RUN run \
  -d 2 \
  --json-file /mnt/shared/secrets/vars.json \
  --remote-json http://config-service/app/config.json \
  --aws-secret jwtconfig \
  -i /app/config.toml.dist \
  -o /app/config.toml \
  /app/server -c /app/config.toml

Running the container

docker run -d --restart=always --env-file .env -p 1234 txgruppi/run-sample

Compiled config file (config.toml)

[database]
url = "mongodb://user:[email protected]/mydb"

[jwt]
secret = "myjwtsecret"

[server]
bind = "0.0.0.0"
port = "1234"