Skip to content

Commit 11137a0

Browse files
committed
Move local splunk to a dockerized setup
1 parent b5b87da commit 11137a0

9 files changed

Lines changed: 35 additions & 29 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ licenses.json
2020
functional-temp
2121
splunktional-temp
2222

23-
output/
23+
output/

Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ clean:
3232
rm -rf venv
3333
rm -rf venv-tools
3434
rm -rf packages/flare/bin/vendor
35-
@unlink "/Applications/Splunk/etc/apps/flare" || true
3635
@find . -type d -name "node_modules" -exec rm -rf {} +
3736
rm -rf output/flare
3837
@rm -f output/flare.tar.gz
@@ -105,6 +104,5 @@ sl: splunk-local
105104

106105
.PHONY: splunk-local
107106
splunk-local: venv setup-web
108-
@echo "Create symlink from app to Splunk Enterprise and start watching files"
109-
SPLUNK_HOME="/Applications/Splunk" yarn run link
107+
docker-compose up -d
110108
yarn run start

README.md

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,14 @@ managing and publishing multiple packages in the same repository.
1919

2020

2121
## Development
22+
We use an official splunk docker image for development, by binding the local folder to a folder in the container. In order for this to work, you need to have build the application before starting the docker.
2223

23-
If you have your own Splunk Enterprise installed locally, you can use
24-
25-
```
26-
make splunk-local
24+
```bash
25+
make build
2726
```
2827

29-
to download the required dependencies, watch the file changes to re-compile on the fly and generate a symlink between the Splunk app and the Splunk Enterprise applications folder.
28+
Then you can start the local docker and the frontend runner.
3029

31-
To be able to see your changes when refreshing, add this at the end of this file:
32-
```
33-
File: /Applications/Splunk/etc/system/local/web.conf
34-
35-
[settings]
36-
cacheEntriesLimit = 0
37-
cacheBytesLimit = 0
30+
```bash
31+
make splunk-local
3832
```
39-
Then restart your Splunk Enterprise instance.

docker-compose.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
services:
2+
splunk:
3+
image: splunk/splunk:latest
4+
container_name: splunk
5+
platform: linux/amd64
6+
restart: unless-stopped
7+
ports:
8+
- "8000:8000"
9+
environment:
10+
- SPLUNK_START_ARGS=--accept-license
11+
- SPLUNK_PASSWORD=a_password
12+
- IS_LOCAL_BUILD=true
13+
volumes:
14+
- ./output/flare:/opt/splunk/etc/apps/flare
15+
- ./splunk/default.yml:/tmp/defaults/default.yml

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
"lint": "lerna run lint --no-sort",
1010
"setup": "yarn && lerna run build",
1111
"start": "lerna run start --stream --no-sort --concurrency 100",
12-
"unlink": "cd packages/flare && node build.js unlink",
13-
"link": "cd packages/flare && node build.js unlink && node build.js link",
1412
"test": "cd packages/react-components && yarn run test",
1513
"test:ci": "cd packages/react-components && yarn run test:ci"
1614
},

packages/flare/bin/logger.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,18 @@
1010
class Logger:
1111
def __init__(self, *, class_name: str) -> None:
1212
splunk_home = os.environ.get("SPLUNK_HOME")
13-
is_local_build = False
1413
log_filepath = ""
1514
if splunk_home:
1615
log_filepath = os.path.join(
1716
splunk_home, "var", "log", "splunk", f"{APP_NAME}.log"
1817
)
19-
application_folder = os.path.join(splunk_home, "etc", "apps", APP_NAME)
20-
is_local_build = os.path.islink(application_folder)
2118
else:
2219
log_filepath = os.path.join(tempfile.gettempdir(), f"{APP_NAME}.log")
2320

2421
self.tag_name = os.path.splitext(os.path.basename(class_name))[0]
2522
self._logger = logging.getLogger(f"flare-{self.tag_name}")
2623

27-
if is_local_build:
28-
# If the application is a symlink, it's been installed locally
24+
if os.environ.get("IS_LOCAL_BUILD"):
2925
self._logger.setLevel(logging.INFO)
3026
else:
3127
self._logger.setLevel(logging.ERROR)

packages/flare/build.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const shell = require('shelljs');
44
const OS = require('os').platform().toLocaleLowerCase();
55

66
const arg = process.argv[2];
7-
const commands = ['build', 'link', 'unlink'];
7+
const commands = ['build'];
88

99
if (!arg) {
1010
shell.echo(
@@ -22,12 +22,9 @@ if (!commands.includes(arg)) {
2222
const runCommands = {
2323
win32: {
2424
build: () => shell.exec('set NODE_ENV=production&&.\\node_modules\\.bin\\webpack --mode=production'),
25-
link: () => shell.exec('mklink /D "%SPLUNK_HOME%\\etc\\apps\\flare" "%cd%\\..\\..\\output\\flare"'),
2625
},
2726
nix: {
2827
build: () => shell.exec('export NODE_ENV=production && ./node_modules/.bin/webpack --mode=production'),
29-
unlink: () => shell.exec('unlink $SPLUNK_HOME/etc/apps/flare || true'),
30-
link: () => shell.exec('ln -s $PWD/../../output/flare $SPLUNK_HOME/etc/apps/flare'),
3128
},
3229
};
3330

packages/react-components/build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const shell = require('shelljs');
44
const OS = require('os').platform().toLocaleLowerCase();
55

66
const arg = process.argv[2];
7-
const commands = ['build', 'link'];
7+
const commands = ['build'];
88

99
if (!arg) {
1010
shell.echo(

splunk/default.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
splunk:
2+
conf:
3+
- key: web
4+
value:
5+
directory: /opt/splunk/etc/system/local
6+
content:
7+
settings:
8+
cacheEntriesLimit: 0
9+
cacheBytesLimit: 0

0 commit comments

Comments
 (0)