Skip to content

Commit

Permalink
update .gitignore to exclude nats; add nats script
Browse files Browse the repository at this point in the history
  • Loading branch information
matoszz committed Jul 11, 2023
1 parent 29831c6 commit d24f4cc
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .devcontainer/nats/nats-server.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
server_name: nats

# Client port of 4222 on all interfaces
port: 4222

# HTTP monitoring port
monitor_port: 8222

# # This is for clustering multiple servers together.
# cluster {
# name: "cluster1"
# listen: 0.0.0.0:6222
# routes = [nats://127.0.0.1:6222]
# cluster_advertise: nats-server:6222
# connect_retries: 0
# }

jetstream: enabled
jetstream {
store_dir: /data/jetstream
max_mem: 10M
max_file: 1G
}

debug: true
logtime: true

max_payload: 4MB
lame_duck_grace_period: 10s
lame_duck_duration: 30s

include "resolver.conf"
15 changes: 15 additions & 0 deletions .devcontainer/nats/resolver.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Operator "LOCAL"
operator: eyJ0eXAiOiJKV1QiLCJhbGciOiJlZDI1NTE5LW5rZXkifQ.eyJqdGkiOiJCQUg0SENWUVVGM1ZYQ0ZaV0VRNjVWTEZHWFBKVlFaQ1RXN1RETkdBN1g2SVVTUTY2RFpRIiwiaWF0IjoxNjg5MDM5NTAzLCJpc3MiOiJPQ0NZNEdaWkdCRVozVlBRR1ZTN1QzTUVMT1VPWDVSWkhBWlNFSlpLQVZFS1hQNVQ3RUxWRllZMyIsIm5hbWUiOiJMT0NBTCIsInN1YiI6Ik9DQ1k0R1paR0JFWjNWUFFHVlM3VDNNRUxPVU9YNVJaSEFaU0VKWktBVkVLWFA1VDdFTFZGWVkzIiwibmF0cyI6eyJzaWduaW5nX2tleXMiOlsiT0JQQUNLWEU3SEhCSVJMU0ZQN1pBWFlaVFRJQlpLUzdBTENWWEtLRVNDUExRM1I3SkFVSEVYQUkiXSwiYWNjb3VudF9zZXJ2ZXJfdXJsIjoibmF0czov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VyYXRpb24vc3lzX2FjY291bnRzIn0seyJuYW1lIjoiYWNjb3VudC1tb25pdG9yaW5nLXNlcnZpY2VzIiwic3ViamVjdCI6IiRTWVMuUkVRLkFDQ09VTlQuKi4qIiwidHlwZSI6InNlcnZpY2UiLCJyZXNwb25zZV90eXBlIjoiU3RyZWFtIiwiYWNjb3VudF90b2tlbl9wb3NpdGlvbiI6NCwiZGVzY3JpcHRpb24iOiJSZXF1ZXN0IGFjY291bnQgc3BlY2lmaWMgbW9uaXRvcmluZyBzZXJ2aWNlcyBmb3I6IFNVQlNaLCBDT05OWiwgTEVBRlosIEpTWiBhbmQgSU5GTyIsImluZm9fdXJsIjoiaHR0cHM6Ly9kb2NzLm5hdHMuaW8vbmF0cy1zZXJ2ZXIvY29uZmlndXJhdGlvbi9zeXNfYWNjb3VudHMifV0sImxpbWl0cyI6eyJzdWJzIjotMSwiZGF0YSI6LTEsInBheWxvYWQiOi0xLCJpbXBvcnRzIjotMSwiZXhwb3J0cyI6LTEsIndpbGRjYXJkcyI6dHJ1ZSwiY29ubiI6LTEsImxlYWYiOi0xfSwic2lnbmluZ19rZXlzIjpbIkFEQ1JRVllVWENCRVQ0QUhSM0RCMjUyVzdVTlZSQ05MMlhPUDJXUUFJQ05GMlBDWFpEQzNEQlQ3Il0sImRlZmF1bHRfcGVybWlzc2lvbnMiOnsicHViIjp7fSwic3ViIjp7fX0sImF1dGhvcml6YXRpb24iOnsiYXV0aF91c2VycyI6bnVsbH0sInR5cGUiOiJhY2NvdW50IiwidmVyc2lvbiI6Mn19.xg91hQ99-nGyv4kNXp856UQOAplFC2X3fgmwF4IOP1cjCXpUc2S7tE-rSGi6FfzzB5T_ISRyC327r9eIxSD5Bg

}
7 changes: 7 additions & 0 deletions .devcontainer/scripts/app-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

set -e

.devcontainer/scripts/nats_account.sh

sleep infinity
35 changes: 35 additions & 0 deletions .devcontainer/scripts/nats_init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/sh

set -e

# script to bootstrap a nats operator environment

if nsc describe operator; then
echo "operator exists, not overwriting config"
exit 0
fi

echo "Cleaning up NATS environment"
rm -rf /nsc/*

echo "Creating NATS operator"
nsc add operator --generate-signing-key --sys --name LOCAL
nsc edit operator -u 'nats://nats:4222'
nsc list operators
nsc describe operator

export OPERATOR_SIGNING_KEY_ID=`nsc describe operator -J | jq -r '.nats.signing_keys | first'`

echo "Creating NATS account for location-api"
nsc add account -n LOC -K ${OPERATOR_SIGNING_KEY_ID}
nsc edit account LOC --sk generate --js-mem-storage -1 --js-disk-storage -1 --js-streams -1 --js-consumer -1
nsc describe account LOC

export ACCOUNTS_SIGNING_KEY_ID=`nsc describe account LOC -J | jq -r '.nats.signing_keys | first'`

echo "Creating NATS user for location-api"
nsc add user -n USER -K ${ACCOUNTS_SIGNING_KEY_ID}
nsc describe user USER

echo "Generating NATS resolver.conf"
nsc generate config --mem-resolver --sys-account SYS --config-file /nats/resolver.conf --force
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@

# Go workspace file
go.work

# Don't check in generated NATs bits
nats/api-creds/*
nats/config/resolver.conf
nats/nsc/*

0 comments on commit d24f4cc

Please sign in to comment.