Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .github/workflows/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v33
uses: tj-actions/changed-files@v32
with:
files: |
server/src/configs/default.json
- name: Setup Node.js environment
if: steps.changed-files.outputs.any_changed == 'true'
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
- name: Run script
if: steps.changed-files.outputs.any_changed == 'true'
run: |
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v32
with:
files: |
server/src/configs/*.json
- name: Setup Node.js environment
if: steps.changed-files.outputs.any_changed == 'true'
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v33
with:
files: |
server/src/configs/default.json
- name: Generate latest env vars
if: steps.changed-files.outputs.any_changed == 'true'
run: |
Expand Down
33 changes: 29 additions & 4 deletions docker-compose.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,54 @@ services:
command: sh -c "yarn start"
restart: unless-stopped
environment:
# All database values are ignored if you are using a `local.json` file!

# Your Scanner Database
SCANNER_DB_HOST: 127.0.0.1
SCANNER_DB_PORT: 3306
SCANNER_DB_USERNAME: scanner_username
SCANNER_DB_PASSWORD: scanner_user_pw
SCANNER_DB_NAME: realdevicemap
SCANNER_DB_NAME: scanner_db

# Your ReactMap Database
# optional, but recommended, if omitted it will default to your manual database
REACT_MAP_DB_HOST: 127.0.0.1
REACT_MAP_DB_PORT: 3306
REACT_MAP_DB_USERNAME: react_map_username
REACT_MAP_DB_PASSWORD: react_map_user_pw
REACT_MAP_DB_NAME: react_map_db

# Your Manual Database (Optional - Nests & Portals)
MANUAL_DB_HOST: 127.0.0.1
MANUAL_DB_PORT: 3306
MANUAL_DB_USERNAME: manual_username
MANUAL_DB_PASSWORD: manual_user_pw
MANUAL_DB_NAME: manual_db

# Other config values - the below env vars will override anything, including `local.json`
# More config values you can add:
# https://github.com/WatWowMap/ReactMap/blob/main/server/src/configs/custom-environment-variables.json
# Config wiki page:
# https://github.com/WatWowMap/ReactMap/wiki/04.-Full-Config-Explanation
# Devs recommened that you use a `local.json` config file though instead of env variables!
MAP_GENERAL_TITLE: ReactMap
MAP_GENERAL_START_LAT: 0
MAP_GENERAL_START_LON: 0
ARRAY_VALUE_EXAMPLE: "[3, 4, 5]"
# ARRAY_VALUE_EXAMPLE: "[3, 4, 5]"

volumes:
# All of these are optional - comment out whichever ones you aren't using
- ./server/src/configs/areas.json:/home/node/server/src/configs/areas.json
- ./server/src/configs/local.json:/home/node/server/src/configs/local.json
- ./server/src/configs/geofence.json/:/home/node/server/src/configs/geofence.json
- ./example.env:/home/node/.env

security_opt:
- no-new-privileges:true #https://nodramadevops.com/2019/06/running-docker-application-containers-more-securely/
# https://nodramadevops.com/2019/06/running-docker-application-containers-more-securely/
- no-new-privileges:true

ports:
- "9090:8080"
- '9090:8080'
# nginx:
# image: nginx
# container_name: nginx
Expand Down
11 changes: 5 additions & 6 deletions esbuild.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ const esbuildMxnCopy = require('esbuild-plugin-mxn-copy')
const aliasPlugin = require('esbuild-plugin-path-alias')
const { eslintPlugin } = require('esbuild-plugin-eslinter')

const pkg = require('./package.json')

const env = fs.existsSync(resolve(__dirname, '.env'))
? dotenv.config()
: { parsed: process.env }
const { version } = JSON.parse(
fs.readFileSync(resolve(__dirname, 'package.json')),
)
const isDevelopment = Boolean(process.argv.includes('--dev'))
const isRelease = Boolean(process.argv.includes('--release'))
const isServing = Boolean(process.argv.includes('--serve'))
Expand Down Expand Up @@ -112,7 +111,7 @@ ${customPaths.map((x, i) => ` ${i + 1}. src/${x.split('src/')[1]}`).join('\n')}
},
})
}
console.log(`[BUILD] Building production version: ${version}`)
console.log(`[BUILD] Building production version: ${pkg.version}`)
}

const esbuild = {
Expand All @@ -121,7 +120,7 @@ const esbuild = {
bundle: true,
outdir: 'dist/',
publicPath: '/',
entryNames: isDevelopment ? undefined : `[name]-${version}-[hash]`,
entryNames: isDevelopment ? undefined : `[name]-${pkg.version}-[hash]`,
metafile: true,
minify: env.parsed.NO_MINIFIED ? false : isRelease || !isDevelopment,
logLevel: isDevelopment ? 'info' : 'error',
Expand All @@ -143,7 +142,7 @@ const esbuild = {
SENTRY_DSN: env.parsed.SENTRY_DSN || '',
SENTRY_TRACES_SAMPLE_RATE: env.parsed.SENTRY_TRACES_SAMPLE_RATE || 0.1,
SENTRY_DEBUG: env.parsed.SENTRY_DEBUG || false,
VERSION: version,
VERSION: pkg.version,
DEVELOPMENT: isDevelopment,
CUSTOM: hasCustom,
LOCALES: fs.readdirSync(resolve(__dirname, 'public/locales')),
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"migrate:latest": "knex --knexfile server/knexfile.cjs migrate:latest",
"migrate:rollback": "knex --knexfile server/knexfile.cjs migrate:rollback",
"release": "node server/scripts/newRelease.js",
"prettier:check": "prettier --check \"**/*.{css,html,js,jsx}\"",
"prettier:fix": "prettier --write \"**/*.{css,html,js,jsx}\"",
"prettier:check": "prettier --check \"**/*.{css,html,js,jsx,yml}\"",
"prettier:fix": "prettier --write \"**/*.{css,html,js,jsx,yml}\"",
"eslint:check": "eslint \"**/*.{js,jsx}\"",
"eslint:fix": "eslint \"**/*.{js,jsx}\" --fix"
},
Expand Down
7 changes: 4 additions & 3 deletions server/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const { sessionStore } = require('./services/sessionStore')
const rootRouter = require('./routes/rootRouter')
const typeDefs = require('./graphql/typeDefs')
const resolvers = require('./graphql/resolvers')
const { version } = require('../../package.json')
const pkg = require('../../package.json')

if (!config.devOptions.skipUpdateCheck) {
require('./services/checkForUpdates')
Expand All @@ -41,8 +41,9 @@ const server = new ApolloServer({
Db,
Event,
perms,
serverV: version,
clientV: req.headers['apollographql-client-version']?.trim() || version,
serverV: pkg.version || 1,
clientV:
req.headers['apollographql-client-version']?.trim() || pkg.version || 1,
}
},
formatError: (e) => {
Expand Down
48 changes: 38 additions & 10 deletions server/src/services/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ if (!fs.existsSync(resolve(`${__dirname}/../configs/local.json`))) {
SCANNER_DB_NAME,
SCANNER_DB_USERNAME,
SCANNER_DB_PASSWORD,
REACT_MAP_DB_HOST,
REACT_MAP_DB_PORT,
REACT_MAP_DB_USERNAME,
REACT_MAP_DB_PASSWORD,
REACT_MAP_DB_NAME,
MANUAL_DB_HOST,
MANUAL_DB_PORT,
MANUAL_DB_NAME,
Expand All @@ -49,13 +54,26 @@ if (!fs.existsSync(resolve(`${__dirname}/../configs/local.json`))) {
MAP_GENERAL_START_LON,
} = process.env

if (
const hasScannerDb =
SCANNER_DB_HOST &&
SCANNER_DB_PORT &&
SCANNER_DB_NAME &&
SCANNER_DB_USERNAME &&
SCANNER_DB_PASSWORD
) {
const hasReactMapDb =
REACT_MAP_DB_HOST &&
REACT_MAP_DB_PORT &&
REACT_MAP_DB_USERNAME &&
REACT_MAP_DB_PASSWORD &&
REACT_MAP_DB_NAME
const hasManualDb =
MANUAL_DB_HOST &&
MANUAL_DB_PORT &&
MANUAL_DB_NAME &&
MANUAL_DB_USERNAME &&
MANUAL_DB_PASSWORD

if (hasScannerDb) {
config.database.schemas.push({
host: SCANNER_DB_HOST,
port: +SCANNER_DB_PORT,
Expand All @@ -77,20 +95,30 @@ if (!fs.existsSync(resolve(`${__dirname}/../configs/local.json`))) {
'Missing scanner database config! \nCheck to make sure you have SCANNER_DB_HOST,SCANNER_DB_PORT, SCANNER_DB_NAME, SCANNER_DB_USERNAME, and SCANNER_DB_PASSWORD',
)
}
if (
MANUAL_DB_HOST &&
MANUAL_DB_PORT &&
MANUAL_DB_NAME &&
MANUAL_DB_USERNAME &&
MANUAL_DB_PASSWORD
) {
if (hasReactMapDb) {
config.database.schemas.push({
host: REACT_MAP_DB_HOST,
port: +REACT_MAP_DB_PORT,
database: REACT_MAP_DB_USERNAME,
username: REACT_MAP_DB_PASSWORD,
password: REACT_MAP_DB_NAME,
useFor: ['session', 'user'],
})
} else {
console.log(
'Missing ReactMap specific table, attempting to use the manual database instead.',
)
}
if (hasManualDb) {
config.database.schemas.push({
host: MANUAL_DB_HOST,
port: +MANUAL_DB_PORT,
database: MANUAL_DB_NAME,
username: MANUAL_DB_USERNAME,
password: MANUAL_DB_PASSWORD,
useFor: ['session', 'user', 'nest', 'portal'],
useFor: hasReactMapDb
? ['nest', 'portal']
: ['session', 'user', 'nest', 'portal'],
})
} else {
console.error(
Expand Down