Skip to content
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

Dockerized Amagama #3233

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
40 changes: 40 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM alpine:3.7

MAINTAINER Navaneeth Sen <[email protected]>

# install dependencies
RUN \
apk add --no-cache python3 postgresql-libs libxslt-dev && \
apk add --no-cache --virtual .build-deps g++ gcc libc-dev libxslt python3-dev musl-dev postgresql-dev libffi-dev

# create a soft link for python3 as python
RUN \
ln -s /usr/bin/python3 /usr/bin/python

# upgrade the pip
RUN \
python -m pip install --upgrade pip

# change working directory
WORKDIR /usr/src/app

# copy files
COPY . .

# install the application specific python libraries
RUN \
python -m pip install -r ./requirements/recommended.txt --no-cache-dir && \
apk --purge del .build-deps

# set the environment variables
ENV PYTHONUNBUFFERED 1
ENV PATH "$PATH:./bin"
ENV PYTHONPATH "$PYTHONPATH:."

# set the executable permissions for the scripts to be run on docker start
RUN chmod a+x /usr/src/app/start_app.sh
RUN chmod a+x /usr/src/app/add_translations.sh

# the entry point
EXPOSE 8888
CMD ["/usr/src/app/start_app.sh"]
7 changes: 7 additions & 0 deletions add_translations.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

export PATH=$(pwd)/bin:/usr/local/bin:$PATH
export PYTHONPATH=$(pwd):$PYTHONPATH

amagama-manage initdb -s en
amagama-manage build_tmdb --verbose -s en -t pt -i translations/
4 changes: 4 additions & 0 deletions required.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
blinker>=0.9
Flask==1.1.4
psycopg2>=2.7
translate-toolkit>=1.8.0
26 changes: 26 additions & 0 deletions settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os

# Global config

DEBUG = os.getenv('SECRET_KEY', False)
SECRET_KEY = os.getenv('SECRET_KEY', 'foobar')
ENABLE_WEB_UI = os.getenv('ENABLE_WEB_UI', True)
ENABLE_DATA_ALTERING_API = os.getenv('ENABLE_DATA_ALTERING_API', False)

# Database config

DB_NAME = os.getenv('DB_NAME', 'amagama')
DB_USER = os.getenv('DB_USER', 'postgres')
DB_PASSWORD = os.getenv('DB_PASSWORD', '')
DB_HOST = os.getenv('DB_HOST', '')
DB_PORT = os.getenv('DB_PORT', '')

# Database pool config
DB_MIN_CONNECTIONS = os.getenv('DB_MIN_CONNECTIONS', 2)
DB_MAX_CONNECTIONS = os.getenv('DB_MAX_CONNECTIONS', 20)

# Levenshtein config

MAX_LENGTH = os.getenv('MAX_LENGTH', 2000)
MIN_SIMILARITY = os.getenv('MIN_SIMILARITY', 70)
MAX_CANDIDATES = os.getenv('MAX_CANDIDATES', 5)
6 changes: 6 additions & 0 deletions start_app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

export PATH=$(pwd)/bin:/usr/local/bin:$PATH
export PYTHONPATH=$(pwd):$PYTHONPATH

amagama -b 0.0.0.0 -p 8888 --debug