generated from amosproj/amos202Xss0Y-projname
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into search-highlight
- Loading branch information
Showing
52 changed files
with
828 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# syntax=docker/dockerfile:1 | ||
# This implements a multi-stage container build process | ||
|
||
# First build the project | ||
FROM node:14-alpine AS dev | ||
RUN apk update && apk add --no-cache python g++ make bash | ||
|
||
# Set environment variables | ||
ENV DOCKER=DOCKER | ||
|
||
# Set our working directory | ||
WORKDIR /usr/src/kmap/backend | ||
|
||
# Install our dependencies | ||
COPY package*.json ./ | ||
COPY yarn.lock* ./ | ||
COPY scripts scripts/ | ||
RUN chmod +x scripts/backend-prebuild.sh | ||
RUN yarn install | ||
|
||
# Build the project | ||
COPY . . | ||
RUN yarn run build | ||
|
||
# Now build the container that is used in production | ||
FROM node:14.17-alpine as prod | ||
|
||
# Install bash | ||
RUN apk update && apk add --no-cache bash | ||
|
||
# Set environment variables | ||
ARG NODE_ENV=production | ||
ENV NODE_ENV=${NODE_ENV} | ||
ENV DOCKER=DOCKER | ||
|
||
# Set our working directory | ||
WORKDIR /usr/src/kmap/backend | ||
|
||
# Install our dependencies (production only) | ||
COPY package*.json ./ | ||
COPY yarn.lock* ./ | ||
COPY scripts scripts/ | ||
RUN chmod +x scripts/backend-prebuild.sh | ||
RUN yarn install --production | ||
|
||
# Copy the dist folder from the dev container | ||
COPY --from=dev /usr/src/kmap/backend/dist dist | ||
|
||
# Copy the docker specific scripts and files | ||
COPY docker docker | ||
|
||
# Start | ||
RUN chmod +x docker/run.sh | ||
CMD ["docker/run.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
# If the host points to localhost (or is not set), we need have to replace this | ||
# with the address of the docker host | ||
if [[ -z ${NEO4J_HOST} || ${NEO4J_HOST} == localhost || ${NEO4J_HOST} == 127.0.0.1 || ${NEO4J_HOST} == ::1 ]]; then | ||
echo "Rewrite neo4j host to docker host, as localhost was specified" | ||
export NEO4J_HOST=$(ip route show | awk '/default/ {print $3}'); | ||
fi | ||
|
||
if [[ -z ${NEO4J_PORT} ]]; then | ||
echo "Using default neo4j port 7687" | ||
export NEO4J_PORT=7687; | ||
fi | ||
|
||
# TODO | ||
export NEO4J_SCHEME=neo4j; | ||
|
||
echo "Starting backend..." | ||
node dist/src/main.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
build/backend-prebuild.ps1 → backend/scripts/backend-prebuild.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Please make sure that this file is executable if you are working in a windows environment | ||
# This can be done by running "git update-index --chmod=+x .\backend-prebuild.sh" in the build directory | ||
|
||
# Goto the backend dir | ||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" | ||
cd "$SCRIPT_DIR"/.. | ||
|
||
# Only execute if not running inside a docker container | ||
if [ "$DOCKER" != "DOCKER" ]; then | ||
# Copy shared files | ||
cp -a ../shared/src/. ./src/shared/ | ||
|
||
# Execute linter | ||
rimraf dist | ||
yarn lint | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
const debug = false; | ||
|
||
function camelize(str) { | ||
return str | ||
.split('-') | ||
.map( | ||
(item, index) => index > 0 ? item.charAt(0).toUpperCase() + item.slice(1).toLowerCase() : item.toLowerCase() | ||
).join(""); | ||
} | ||
|
||
function logFound(arg, key, value) { | ||
if (debug) { | ||
console.log("Found argument '" + arg + "'. Writing property '" + key + "' with value '" + value + "' to args object."); | ||
} | ||
} | ||
|
||
const parseArgs = function(input, flags, args) { | ||
const result = {}; | ||
|
||
for (let i = 0; i < input.length; i++) { | ||
const key = input[i]; | ||
let argProcessed = false; | ||
|
||
if (flags) { | ||
for (const flag of flags) { | ||
if ('--' + flag.name === key || (typeof flag.abbr === 'string' && '-' + flag.abbr === key)) { | ||
|
||
const camelizedName = camelize(flag.name); | ||
|
||
logFound(flag.name, camelizedName, 'true'); | ||
|
||
result[camelizedName] = true; | ||
argProcessed = true; | ||
} | ||
} | ||
} | ||
|
||
if (!argProcessed && args) { | ||
for (const arg of args) { | ||
if ('--' + arg.name === key) { | ||
i++; | ||
|
||
if (i >= input.length) { | ||
throw new Error('No value present for command-line argument:' + key); | ||
} | ||
|
||
const value = input[i]; | ||
const camelizedName = camelize(arg.name); | ||
|
||
logFound(arg.name, camelizedName, value); | ||
|
||
result[camelizedName] = value; | ||
argProcessed = true; | ||
} | ||
} | ||
} | ||
|
||
if (!argProcessed) { | ||
throw new Error('Unknown command-line argument: ' + key); | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
|
||
exports.parseArgs = parseArgs; |
Oops, something went wrong.