diff --git a/README.md b/README.md index 5f6bfeec..4cdd73ce 100644 --- a/README.md +++ b/README.md @@ -53,11 +53,6 @@ You will need to download and install [Ruby](https://www.ruby-lang.org/en/downlo node bin/setup.js docker-compose up -d -cd SearchIndexer - -dotnet ./App/bin/Debug/netcoreapp2.2/App.dll create-index -e "http://localhost:9200" -n podcasts -f Examples/elastic-podcast-index-definition.json -u elastic -p QITROCKS! -dotnet ./App/bin/Debug/netcoreapp2.2/App.dll update-documents -f Examples/podcast-feeds.json -e "http://localhost:9200" -n podcasts -u elastic -p QITROCKS! - # Setup front-end cd ../website npm start diff --git a/SearchIndexer b/SearchIndexer deleted file mode 160000 index fa3af468..00000000 --- a/SearchIndexer +++ /dev/null @@ -1 +0,0 @@ -Subproject commit fa3af46874618c11c5f9205fa0bbcf74043172f2 diff --git a/bin/setup.js b/bin/setup.js index bef1f400..463772fd 100755 --- a/bin/setup.js +++ b/bin/setup.js @@ -1,13 +1,10 @@ #!/usr/bin/env node const path = require('path') -const fs = require('fs') const { execSync } = require('child_process') const ROOT_DIR = path.normalize(`${__dirname}/..`) const WEBSITE_DIR = path.normalize(`${ROOT_DIR}/website`) -const INDEXER_DIR = path.normalize(`${ROOT_DIR}/SearchIndexer`) -const API_DIR = path.normalize(`${ROOT_DIR}/qit-api`) // Execute a command synchronously but wrap it with formatted console logs // so each commands output can be separated from each other. @@ -21,16 +18,9 @@ function executeCommand (command, description) { process.chdir(ROOT_DIR) executeCommand('npm install', 'INSTALLING ROOT NODE MODULES') -executeCommand('git submodule init', 'INITIALIZING SEARCHINDEXER SUBMODULE') -executeCommand('git submodule update', 'UPDATING SEARCHINDEXER SUBMODULE') process.chdir(WEBSITE_DIR) executeCommand('npm install', 'INSTALLING WEBSITE NODE MODULES') -process.chdir(INDEXER_DIR) - -//TODO: error check if dotnet is installed -executeCommand('dotnet build', 'BUILDING SEARCHINDEXER') - console.log('QIT: SETUP - COMPLETE') diff --git a/docker-compose.yml b/docker-compose.yml index bbf80668..f6550fd4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: "3" +version: '3' services: api: @@ -9,12 +9,12 @@ services: ports: - 3005:3005 environment: - - "DOCKER=true" - - "QIT_API_DATABASE_USERNAME=postgres" - - "QIT_API_DATABASE_PASSWORD=" - - "QIT_API_DATABASE_NAME=postgres" - - "QIT_API_DATABASE_HOST=db" - - "QIT_API_SECRET=QITROCKS!" + - 'DOCKER=true' + - 'QIT_API_DATABASE_USERNAME=postgres' + - 'QIT_API_DATABASE_PASSWORD=' + - 'QIT_API_DATABASE_NAME=postgres' + - 'QIT_API_DATABASE_HOST=db' + - 'QIT_API_SECRET=QITROCKS!' db: image: library/postgres @@ -33,7 +33,7 @@ services: - node.name=es01 - cluster.initial_master_nodes=es01 - ELASTIC_PASSWORD=QITROCKS! - - "ES_JAVA_OPTS=-Xms512m -Xmx512m" + - 'ES_JAVA_OPTS=-Xms512m -Xmx512m' - xpack.license.self_generated.type=basic - xpack.security.enabled=true - xpack.security.transport.ssl.enabled=true @@ -48,10 +48,14 @@ services: ports: - 5601:5601 environment: - ELASTICSEARCH_HOSTS: "http://es01:9200" + ELASTICSEARCH_HOSTS: 'http://es01:9200' ELASTICSEARCH_USERNAME: elastic ELASTICSEARCH_PASSWORD: QITROCKS! + indexer: + build: + context: ./indexer + volumes: search: driver: local diff --git a/indexer/Dockerfile b/indexer/Dockerfile new file mode 100644 index 00000000..c592b8cc --- /dev/null +++ b/indexer/Dockerfile @@ -0,0 +1,25 @@ +# source +FROM alpine/git:v2.24.3 as source + +WORKDIR /app +RUN git clone https://github.com/codingblocks/SearchIndexer.git + +# build +FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build +WORKDIR /app +COPY --from=source /app/SearchIndexer . + +RUN dotnet restore +RUN dotnet publish -c release -o /dist --no-restore + +# runtime +FROM mcr.microsoft.com/dotnet/core/runtime:2.2 +WORKDIR /app +COPY --from=build /dist . + +COPY --from=source /app/SearchIndexer/Examples/elastic-podcast-index-definition.json /config/index.json +COPY --from=source /app/SearchIndexer/Examples/podcast-feeds.json /config/feeds.json + +COPY init.sh . +RUN chmod +x init.sh +ENTRYPOINT ["/app/init.sh"] \ No newline at end of file diff --git a/indexer/init.sh b/indexer/init.sh new file mode 100644 index 00000000..8bd988e7 --- /dev/null +++ b/indexer/init.sh @@ -0,0 +1,6 @@ +#!/bin/bash +password=QITROCKS! +url="http://es01:9200" +echo Initializing $url +dotnet App.dll create-index -e $url -n podcasts -f /config/index.json -u elastic -p $password +dotnet App.dll update-documents -f /config/feeds.json -e $url -n podcasts -u elastic -p $password \ No newline at end of file diff --git a/website/package-lock.json b/website/package-lock.json index 6d2d39bc..5fa58046 100644 --- a/website/package-lock.json +++ b/website/package-lock.json @@ -5417,13 +5417,11 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true, - "optional": true + "bundled": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -5436,18 +5434,15 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "concat-map": { "version": "0.0.1", - "bundled": true, - "optional": true + "bundled": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "core-util-is": { "version": "1.0.2", @@ -5550,8 +5545,7 @@ }, "inherits": { "version": "2.0.3", - "bundled": true, - "optional": true + "bundled": true }, "ini": { "version": "1.3.5", @@ -5561,7 +5555,6 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -5574,20 +5567,17 @@ "minimatch": { "version": "3.0.4", "bundled": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true, - "optional": true + "bundled": true }, "minipass": { "version": "2.2.4", "bundled": true, - "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -5604,7 +5594,6 @@ "mkdirp": { "version": "0.5.1", "bundled": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -5677,8 +5666,7 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true, - "optional": true + "bundled": true }, "object-assign": { "version": "4.1.1", @@ -5688,7 +5676,6 @@ "once": { "version": "1.4.0", "bundled": true, - "optional": true, "requires": { "wrappy": "1" } @@ -5794,7 +5781,6 @@ "string-width": { "version": "1.0.2", "bundled": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",