diff --git a/Dockerfile b/Dockerfile index ed889f2..223033a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,15 +9,17 @@ RUN apt-get update \ WORKDIR /install -COPY ./bk_api . +COPY ./bk_api ./bk_api -RUN mv ./bk_api/ocr_module/tesseract_data/pol.traineddata /usr/share/tesseract-ocr/4.00/tessdata +WORKDIR /install/bk_api + +RUN mv ./ocr_module/tesseract_data/pol.traineddata /usr/share/tesseract-ocr/4.00/tessdata RUN pip3 install pipenv_to_requirements gunicorn && \ pipenv run pipenv_to_requirements && \ pip3 install --no-cache -r requirements.txt -# WORKDIR /install +CMD exec gunicorn bk_api.wsgi:application --bind 0.0.0.0:8000 --workers 3 diff --git a/Jenkinsfile b/Jenkinsfile index e6e0c6e..f195cc4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,10 +9,10 @@ pipeline { } stage('Test') { steps { - echo 'Testing..' + echo '> Test tesseract installation...' sh 'sh scripts/check_tesseract.sh' - sh 'ls -la /usr/share/tesseract-ocr/4.00/tessdata/' - sh 'python api/main.py -i api/img/biedra.jpg' + echo '> Test OCR api module...' + sh 'python bk_api/ocr_module/main.py -i bk_api/ocr_module/img/biedra.jpg' } } } diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c3fef12 --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +.PHONY: build run logs + +build: + docker build --tag bk_api -f Dockerfile . + +run: + docker run -d --name api -p 127.0.0.1:3000:8000 bk_api + +logs: + docker logs api --follow + +start: + docker start api + +stop: + docker stop api diff --git a/Pipfile b/bk_api/Pipfile similarity index 100% rename from Pipfile rename to bk_api/Pipfile diff --git a/Pipfile.lock b/bk_api/Pipfile.lock similarity index 100% rename from Pipfile.lock rename to bk_api/Pipfile.lock diff --git a/bk_api/bk_api/urls.py b/bk_api/bk_api/urls.py index 5fa99af..af4dd92 100644 --- a/bk_api/bk_api/urls.py +++ b/bk_api/bk_api/urls.py @@ -13,6 +13,7 @@ Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ +from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.contrib import admin from django.urls import include, path @@ -20,3 +21,5 @@ urlpatterns = [ path('polls/', include('core.urls')), path('admin/', admin.site.urls), ] + +urlpatterns += staticfiles_urlpatterns()