Skip to content

Commit

Permalink
Merge pull request #8 from neo4j-labs/dev
Browse files Browse the repository at this point in the history
new docker build
  • Loading branch information
snehalmaidneo authored Jan 28, 2025
2 parents c62ae1a + bd59a99 commit 1a339e1
Show file tree
Hide file tree
Showing 21 changed files with 461 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docker/v2/build_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
###
### Usage: sh ./build_docker.sh <dir1> <dir2>
### This script will run the build.sh file for keymaker & any other directories specified in the args
###
echo ""
echo "*** Cleaning build folder ***"
echo ""
find ./build -exec rm -rdf "{}" \;
mkdir ./build
### Build keymaker
cd ./keymaker
./build.sh
cd ..
48 changes: 48 additions & 0 deletions docker/v2/build_package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/sh
if [ -z "$KEYMAKER_VERSION" ]
then
echo "KEYMAKER_VERSION must be set first by running command:"
echo " source ./getVersion.sh"
exit 1
else
echo "KEYMAKER_VERSION is ${KEYMAKER_VERSION}, ok to proceed? (y/n)"
read isVersionOk
if [ "$isVersionOk" != "y" ]
then
echo "Stopping build, re-run when version is ok."
exit 1
else
echo "Building with KEYMAKER_VERSION ${KEYMAKER_VERSION}"
fi
fi

### Cleaning build directory
echo ""
echo "*** Cleaning build directory ***"
echo ""
rm -r ./build/*
### Packaging Docker images
echo ""
echo "*** Packaging docker images ***"
echo ""
docker save keymaker-ui:${KEYMAKER_VERSION} keymaker-admin-api:${KEYMAKER_VERSION} keymaker-engine-api:${KEYMAKER_VERSION} | gzip > keymakerDocker.tar.gz
mv keymakerDocker.tar.gz ./build
### Packaging Config
echo ""
echo "*** Packaging Keymaker config ***"
echo ""

tar --exclude='movies*' -zcvf keymaker_config.tar.gz ./config
mv ./keymaker_config.tar.gz ./build


#cp docker-compose.yml ./build/docker-compose.yml
sed 's|${KEYMAKER_VERSION}|'$KEYMAKER_VERSION'|g' docker-compose.yml > ./build/docker-compose.yml
cp ./keymaker.sh ./build/keymaker.sh
cp ../../admin-api/scripts/create-user.sh ./build
echo ""
echo "*** Packaging everything ***"
echo ""
cd ./build
tar cvf keymaker.tar.gz *
echo "*** Done ***"
1 change: 1 addition & 0 deletions docker/v2/config/keymaker-license/license.lic
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
==== Keymaker 7.0.0 - Labs ==== ub6KcYH91hgO0v/NLrGzeD0/vl2iP76afPZmg97dwODgSR9XfqOEccwWOtVdgnzs8JmhkNV046Akg5zlmp6t6yM2JxxfDHhZO3D7uh2WSFA0GOJBoMznzx3iXAZETg3fJLK2WH6cAX/uLT0bFBTPvpRyc/hQMe4hK28nJh0608bcSudoe6wU0x92aZD0VHji/8D7Ol0FWmuLeVg8o+pmzYYODrLCE+36Pr49GhIdLzn+fhkSvYmbK2nVWlW4MVp4KLRP2ZM6h4YFKoEPyP3BmG5YakRLNGD6ZOMWdthucdTYWtAoXq/1S8fJ26wFBJvZlH0iX8jQIWRnlPo+tqdzkg==_$$_e3AEUk9sWOpvbb+5Ch6VprpZGv24V8SgfscmIKo8yicEOVqWVL5GZUmdi/zjKUfgjjdoS7ryFbKDPgMSSHP4Aw==
56 changes: 56 additions & 0 deletions docker/v2/config/keymaker-ui-nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
user nginx;
worker_processes auto;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

#gzip on;

server {
listen 3080;
listen 3443 ssl;
server_name localhost;
ssl_certificate neo4j.com.crt;
ssl_certificate_key neo4j.com.key;

#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri /index.html;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}

14 changes: 14 additions & 0 deletions docker/v2/config/keymaker-ui/env-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
window._dynamicEnv_ = {
REACT_APP_GRAPHQL_URI: "http://localhost:36402/graphql",
REACT_APP_RECOMMENDATION_URI: "http://localhost:36401/graphql",
REACT_APP_EULA_GRAPHQL_URI: "ignore",
REACT_APP_AUTH_DOMAIN: "none",
REACT_APP_AUTH_CLIENT_ID: "none",
REACT_APP_AUTH_CALLBACK: "none",
REACT_APP_AUTH_METHOD: "local",
REACT_APP_AUTH_LOGOUT_URL: "localhost",
REACT_APP_EXPIRE_TIME: "3600",
REACT_APP_HIVE_URI: "",
REACT_APP_HIVE_UI: "",
REACT_APP_SOLUTION: "",
};
Empty file.
76 changes: 76 additions & 0 deletions docker/v2/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
version: "1"

services:
keymaker-admin-api:
image: keymaker-admin-api:${KEYMAKER_VERSION}
ports:
- "36402:4002"
volumes:
- ./config/keymaker-license:/app/license
- ./config/keymaker-certificate:/app/ssh_keys
- ./config/logs:/app/logs
environment:
- LICENSE_FILE=/app/license/license.lic
- NEO4J_URI=neo4j://localhost:7687
- NEO4J_USER=neo4j
- NEO4J_PASSWORD=neo4j
- NEO4J_DATABASE=neo4j
- GRAPHQL_LISTEN_PORT=4002
- ENCRYPTION_KEY=keymakerEncryptionKey
- ENGINE_API_APIKEY=LZmIbId7He4dh0hH7ZUVKz5A
- AUTH_METHOD=local
- HOST_NAME=localhost
- HOST_PROTOCOL=http
- LOGS_DIR=/app/logs
- LOG_LEVEL=info
- LOG_MAX_SIZE=20m
- LOG_RETENTION_PERIOD=14d
- MAX_CACHED_DRIVERS=100
- MAX_DRIVER_AGE=3600000
- NEO4J_TRANSACTION_TIMEOUT=300000
- DRIVER_CACHE_PRUNE_INTERVAL=600000
keymaker-engine-api:
image: keymaker-engine-api:${KEYMAKER_VERSION}
ports:
- "36401:4001"
volumes:
- ./config/keymaker-license:/app/license
- ./config/keymaker-certificate:/app/ssh_keys
- ./config/whitelist:/app/config
- ./config/logs:/app/logs
environment:
- LICENSE_FILE=/app/license/license.lic
- WHITELISTED_ORIGINS_FILE=/app/config/whitelisted-origins.txt
- NEO4J_URI=neo4j://localhost:7687
- NEO4J_USERNAME=neo4j
- NEO4J_PASSWORD=neo4j
- NEO4J_DATABASE=neo4j
- GRAPHQL_LISTEN_PORT=4001
- ENCRYPTION_KEY=keymakerEncryptionKey
- HOST_NAME=localhost
- HOST_PROTOCOL=http
- MAX_CACHED_DRIVERS=100
- MAX_DRIVER_AGE=3600000
- NEO4J_TRANSACTION_TIMEOUT=300000
- DRIVER_CACHE_PRUNE_INTERVAL=600000
- MAX_CACHED_APIKEYS=100
- APIKEY_CACHE_PRUNE_INTERVAL=600000
- LOGS_DIR=/app/logs
- LOG_LEVEL=info
- LOG_MAX_SIZE=20m
- LOG_RETENTION_PERIOD=14d
- MAX_CACHED_ENGINES=100
- MAX_ENGINE_AGE=3600000
- ENGINE_CACHE_PRUNE_INTERVAL=600000
- ENGINE_CACHE_RESET_INTERVAL=86400000
keymaker-ui:
image: keymaker-ui:${KEYMAKER_VERSION}
ports:
- "36081:3080"
- "36444:3443"
volumes:
- ./config/keymaker-ui:/usr/share/nginx/html/config
- ./config/keymaker-ui-nginx:/usr/share/nginx/conf
depends_on:
- "keymaker-engine-api"
- "keymaker-admin-api"
24 changes: 24 additions & 0 deletions docker/v2/getVersion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

# Get the directory of the current script
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Path to the version.js file
input="$SCRIPT_DIR/../../ui/src/version.js"

# Check if the input file exists
if [[ ! -f "$input" ]]; then
echo "Error: File $input not found."
return 1 # Use 'return' instead of 'exit' when sourcing
fi

# Extract the version number using sed
VERSION=$(sed -n "s/export const VERSION = '\([^']*\)';/\1/p" "$input")

# Replace '-' and '+' with '_'
VERSION=${VERSION//-/_}
VERSION=${VERSION//+/_}

# Output the version and export it as an environment variable
echo "VERSION: $VERSION"
export KEYMAKER_VERSION=$VERSION
38 changes: 38 additions & 0 deletions docker/v2/keymaker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/sh
doExit () {
echo >&2 "$@"
exit 1
}

[ "$#" -eq 1 ] || doExit "Usage: keymaker (start | stop | status | unpack)"
if [ "$1" = "start" ]
then
echo "Starting Keymaker services"
docker-compose --project-name keymaker up --detach --remove-orphans --force-recreate
echo "Keymaker should be available in a few minutes"
echo " Keymaker Admin UI: http://localhost:36081"
elif [ "$1" = "stop" ]
then
echo "Stopping Keymaker services"
docker-compose --project-name keymaker stop
elif [ "$1" = "status" ]
then
echo "Keymaker status"
docker ps | grep keymaker
elif [ "$1" = "unpack" ]
then
if [ -d "./keymaker_config" ]
then
echo "*** Config folder exists. Skipping unpacking of config ***"
else
echo ""
echo "*** Unpacking config ***"
echo ""
tar xvfz keymaker_config.tar.gz
fi
echo ""
echo "*** Unpacking docker images ***"
echo ""
docker load < keymakerDocker.tar.gz
echo ""
fi
Binary file added docker/v2/keymaker/.DS_Store
Binary file not shown.
30 changes: 30 additions & 0 deletions docker/v2/keymaker/admin-api/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

# Clean dir before build
echo ">>> Removing ./admin-api folder"
./cleanup.sh $1
# Copy in source code
echo ">>> Copying ./admin-api folder without node_modules"
rsync -av --progress ../../../../admin-api . --exclude node_modules
cd admin-api

# Install deps
echo ">>> Installing dependencies"
if [ "$1" = "-skipNpmInstall" ]
then
echo ">>> Skipping npm install"
mv ../keep/node_modules .
else
echo ">>> Doing npm install"
npm install
fi
# Copy in empty .env files (vars are specified in docker-compose.yml)
cp ../.env ./.env
cp ../.env ./dist/.env
# Build docker image
echo ">>> Doing docker build"
docker build --no-cache -f Dockerfile ./ -t keymaker-admin-api:${KEYMAKER_VERSION}
# Remove source code
echo ">>> Removing ./admin-api folder"
cd ..
./cleanup.sh $1
9 changes: 9 additions & 0 deletions docker/v2/keymaker/admin-api/cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
if [ "$1" = "-skipNpmInstall" ]
then
mkdir ./keep
mv ./admin-api/node_modules ./keep
find ./admin-api -exec rm -rdf "{}" \;
else
find ./admin-api -exec rm -rdf "{}" \;
fi
3 changes: 3 additions & 0 deletions docker/v2/keymaker/admin-api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions docker/v2/keymaker/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh
if [ -z "$KEYMAKER_VERSION" ]
then
echo "KEYMAKER_VERSION must be set first by running command:"
echo " source ./getVersion.sh"
exit 1
else
echo "KEYMAKER_VERSION is ${KEYMAKER_VERSION}, ok to proceed? (y/n)"
read isVersionOk
if [ "$isVersionOk" != "y" ]
then
echo "Stopping build, re-run when version is ok."
exit 1
else
echo "Building with KEYMAKER_VERSION ${KEYMAKER_VERSION}"
fi
fi

echo ""
echo "*** Building Keymaker ***"
echo ""
### Build Keymaker Admin API
echo ""
echo "*** Building Keymaker Admin API ***"
echo ""
cd ./admin-api
./build.sh $1
cd ..
### Build Keymaker Engine API
echo ""
echo "*** Building Keymaker Engine API ***"
echo ""
cd ./engine-api
./build.sh $1
cd ..
### Build Keymaker UI
echo ""
echo "*** Building Keymaker UI ***"
echo ""
cd ./ui
./build.sh $1
cd ..
Loading

0 comments on commit 1a339e1

Please sign in to comment.