Skip to content

Commit

Permalink
Use a Docker volume to store the configuration of the apps and stores
Browse files Browse the repository at this point in the history
  • Loading branch information
timoa committed Sep 1, 2019
1 parent bbbb36a commit 911e26b
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 23 deletions.
7 changes: 1 addition & 6 deletions .gitignore
Expand Up @@ -65,9 +65,4 @@ typings/

# SonarQube
.sonarlint
.scannerwork

# Ignore existing configuration file
# Remove it from this file if you want to save them on your Git repo
src/config/apps.json
src/config/config.json
.scannerwork
4 changes: 1 addition & 3 deletions Dockerfile
Expand Up @@ -28,9 +28,7 @@ HEALTHCHECK --interval=15s --timeout=5s --start-period=30s \

RUN \
npm install --production --unsafe-perm && \
npm cache clean --force && \
mv /opt/app/src/config/apps.sample.json /opt/app/src/config/apps.json && \
mv /opt/app/src/config/config.sample.json /opt/app/src/config/config.json
npm cache clean --force

RUN chown -R app-user /opt/app
USER app-user
Expand Down
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -308,16 +308,16 @@ cd app-stores-prometheus-exporter
npm install
```

Rename the configuration files
Copy the configuration files

| From || To |
|---|---|---|
|config/apps.**sample**.json|=>|config/apps.json|
|config/config.**sample**.json|=>|config/config.json|
|src/examples/apps.json|=>|config/apps.json|
|src/examples/config.json|=>|config/config.json|

``` bash
mv config/apps.sample.json config/apps.json
mv config/config.sample.json config/config.json
mv src/examples/apps.json config/apps.json
mv src/examples/config.json config/config.json
```

Start the App Stores Prometheus Exporter:
Expand Down
Empty file added config/.gitkeep
Empty file.
7 changes: 6 additions & 1 deletion docker-compose.yml
@@ -1,10 +1,15 @@
version: '2'
version: '3.3'

services:
api:
image: timoa/app-stores-prometheus-exporter:latest
environment:
- NODE_ENV=production
volumes:
- ./config:/opt/app/config
ports:
- 9514:9514
restart: always

volumes:
config:
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions src/exporter.js
Expand Up @@ -5,15 +5,15 @@ const path = require('path');

const logger = require('./lib/logger');

// Check if apps.sample.json has been renamed
if (!fs.existsSync(path.resolve(__dirname, 'config/apps.json'))) {
logger.error('Please rename the file "src/config/apps.sample.json" => "src/config/apps.json"');
// Check if there is a `apps.json` in the config folder
if (!fs.existsSync(path.resolve(__dirname, '../config/apps.json'))) {
logger.error('Please copy the file "src/examples/apps.json" => "config/apps.json"');
process.exit(1);
}

// Check if config.sample.json has been renamed
if (!fs.existsSync(path.resolve(__dirname, 'config/config.json'))) {
logger.error('Please rename the file "src/config/config.sample.json" => "src/config/config.json"');
// Check if there is a `config.json` in the config folder
if (!fs.existsSync(path.resolve(__dirname, '../config/config.json'))) {
logger.error('Please copy the file "src/examples/config.json" => "config/config.json"');
process.exit(1);
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib/prometheus.js
Expand Up @@ -6,8 +6,8 @@ const itunes = require('app-store-scraper');
const gplay = require('google-play-scraper');

// Config files
const config = require('../config/config.json');
const apps = require('../config/apps.json');
const config = require('../../config/config.json');
const apps = require('../../config/apps.json');
const metrics = require('../config/metrics.json');

const register = new client.Registry();
Expand Down

0 comments on commit 911e26b

Please sign in to comment.