Skip to content

Commit

Permalink
Added improved base structure with dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoFHG committed Apr 22, 2020
1 parent 0eda799 commit ba46a9a
Show file tree
Hide file tree
Showing 12 changed files with 268 additions and 3 deletions.
18 changes: 17 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
FROM python:3.8.2-alpine3.11

RUN apk add --no-cache git
RUN apk add --no-cache git \
&& pip install --upgrade pip \
&& adduser -D worker \
&& pip install pipenv

USER worker

WORKDIR /home/worker

ENV PATH="/home/worker/.local/bin:${PATH}"

COPY --chown=worker:worker Pipfile Pipfile
RUN pipenv lock -r > requirements.txt
RUN pip install --user -r requirements.txt

COPY --chown=worker:worker . .

2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tty:
docker exec --user="worker" -ti fileindexerapi_file-indexer-api_1 /bin/sh
15 changes: 15 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
pylint = "*"

[packages]
flask = "*"
flask-restful = "*"
py4j = "*"

[requires]
python_version = "3.8"
201 changes: 201 additions & 0 deletions Pipfile.lock

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

4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ services:
build:
context: .
volumes:
- .:/home/app/
working_dir: /home/app
- .:/home/worker/
working_dir: /home/worker
tty: true
5 changes: 5 additions & 0 deletions file_indexer_api/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from app import app

if __name__ == '__main__':
app.run(debug=True)

11 changes: 11 additions & 0 deletions file_indexer_api/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from flask import Flask
from flask_restful import Api
from controllers.indexer_controller import IndexerController
from controllers.search_controller import SearchController

app = Flask(__name__)
api = Api(app)

api.add_resource(IndexerController, '/index')
api.add_resource(SearchController, '/search')

10 changes: 10 additions & 0 deletions file_indexer_api/controllers/indexer_controller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from flask_restful import Resource, reqparse

parser = reqparse.RequestParser()
parser.add_argument('path')

class IndexerController(Resource):
def post(self):
args = parser.parse_args()

return {'path': args['path']}
5 changes: 5 additions & 0 deletions file_indexer_api/controllers/search_controller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from flask_restful import Resource, reqparse

class SearchController(Resource):
def get(self):
return {'message': 'SearchController'}
Empty file.
Empty file.
Empty file.

0 comments on commit ba46a9a

Please sign in to comment.