Skip to content

Dockerizing the search indexer so we don't have to run any dotnet com… #347

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion SearchIndexer
Submodule SearchIndexer deleted from fa3af4
10 changes: 0 additions & 10 deletions bin/setup.js
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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')
22 changes: 13 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "3"
version: '3'

services:
api:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
25 changes: 25 additions & 0 deletions indexer/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
6 changes: 6 additions & 0 deletions indexer/init.sh
Original file line number Diff line number Diff line change
@@ -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
28 changes: 7 additions & 21 deletions website/package-lock.json

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