This repository has been archived by the owner on Aug 27, 2024. It is now read-only.
-
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.
Created docker image and compose configuration for MeMaS (#39)
- Loading branch information
Showing
13 changed files
with
342 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
memas/memas-config.yml |
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,37 @@ | ||
FROM python:3.10 | ||
|
||
# Create app directory | ||
WORKDIR /memas | ||
|
||
# Install Universal Sentence Encoder | ||
RUN wget https://tfhub.dev/google/universal-sentence-encoder/4?tf-hub-format=compressed -O use4.tar | ||
RUN mkdir -p encoder/universal-sentence-encoder_4 | ||
RUN tar -xf use4.tar -C encoder/universal-sentence-encoder_4 | ||
RUN rm use4.tar | ||
|
||
# Install app dependencies | ||
COPY requirements.txt ./requirements.txt | ||
RUN pip install -r requirements.txt | ||
RUN python3 -c "import nltk; nltk.download('punkt')" | ||
|
||
|
||
# Bundle app source | ||
COPY logging.ini ./logging.ini | ||
COPY memas ./memas | ||
COPY --chmod=0755 memas-docker/wait-for-it.sh ./wait-for-it.sh | ||
COPY --chmod=0755 memas-docker/init.sh ./init.sh | ||
|
||
|
||
# Copy in the default config | ||
ARG conf_file=memas-config.yml | ||
ENV conf_file=${conf_file} | ||
COPY memas-docker/${conf_file} ./memas/${conf_file} | ||
# TODO: provide way to use custom configs in docker compose | ||
|
||
|
||
# Set the python path to include memas, since memas isn't technically a python package | ||
ENV PYTHONPATH "$PYTHONPATH:memas" | ||
|
||
|
||
EXPOSE 8010 | ||
CMD gunicorn -b :8010 -w 1 -k eventlet "memas.app:create_app(config_filename=\"${conf_file}\")" |
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,29 @@ | ||
#!/bin/bash | ||
# Init script for MeMaS. Sleeps for x seconds to wait for service initialization | ||
|
||
# Check if an argument is provided | ||
if [ "$#" -ne 1 ]; then | ||
echo "Usage: $0 <number-of-secs-to-sleep>" | ||
exit 1 | ||
fi | ||
|
||
num=$1 | ||
version="2023-09-06" | ||
|
||
# Check if the entered value is a valid number | ||
if ! [[ "$num" =~ ^[0-9]+$ ]]; then | ||
echo "Please enter a valid number." | ||
exit 1 | ||
fi | ||
|
||
# TODO: introduce actual way of waiting for the dependencies reliably, instead of sleeping. (Note even after the current health checks path, scylla is still not ready) | ||
echo "sleeping $num" | ||
sleep $num | ||
|
||
|
||
if [ ! -e /memas/first-init.lock ] | ||
then | ||
# If initialization succeeded, create the lock file, and write our current version to it | ||
# FIXME: is running flask instead of gunicorn a security concern? Gunicorn keeps on trying to restart the worker thread despite we're intentionally exiting | ||
flask --app "memas.app:create_app(config_filename=\"$conf_file\", first_init=True)" run && touch /memas/first-init.lock; echo $version > /memas/first-init.lock | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
CASSANDRA: | ||
ip: "scylla" | ||
port: 9042 | ||
keyspace: "memas" | ||
replication_factor: 1 | ||
|
||
ELASTICSEARCH: | ||
ip: "memas-es01" | ||
port: 9200 | ||
|
||
MILVUS: | ||
ip: "milvus-standalone" | ||
port: 19530 |
Oops, something went wrong.