-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e6a2aa4
Showing
61 changed files
with
15,590 additions
and
0 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,38 @@ | ||
.idea | ||
.vscode | ||
*.iml | ||
*.p12 | ||
.DS_Store | ||
builds | ||
build | ||
dist | ||
venv | ||
/**/target | ||
/**/*.pyc | ||
k8.cert | ||
db.sqlite3 | ||
*.pyc | ||
.venv | ||
**/node_modules/ | ||
**/.next | ||
/.pnp | ||
.pnp.js | ||
coverage/ | ||
build/ | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.eslintcache | ||
*.tfvars | ||
*.jks | ||
*.pem | ||
*.cert | ||
*.tfstate* | ||
.terraform | ||
.coverage | ||
*.md | ||
.git |
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,61 @@ | ||
name: Django Backend | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
paths: [ "django_backend/**", ".github/workflows/django_backend.yml" ] | ||
branches: [ main ] | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
strategy: | ||
max-parallel: 4 | ||
matrix: | ||
python-version: [3.7] | ||
|
||
defaults: | ||
run: | ||
working-directory: ./django_backend | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: "3.7" | ||
- name: Install Dependencies | ||
run: | | ||
pip install pipenv && pipenv sync | ||
- name: Run Linter | ||
run: | | ||
pipenv run flake8 | ||
- name: Run Tests | ||
run: | | ||
pipenv run ./manage.py test | ||
analyze: | ||
name: Analyze | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
language: [ 'python' ] | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v1 | ||
with: | ||
languages: ${{ matrix.language }} | ||
|
||
- name: Autobuild | ||
uses: github/codeql-action/autobuild@v1 | ||
|
||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v1 |
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,51 @@ | ||
name: React Frontend | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
paths: [ "react_frontend/**", ".github/workflows/react_frontend.yml" ] | ||
branches: [ main ] | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
|
||
defaults: | ||
run: | ||
working-directory: ./react_frontend | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: "12.x" | ||
- run: npm ci | ||
- run: npm run lint | ||
- run: npm run test:cover | ||
- run: npm run build | ||
|
||
analyze: | ||
name: Analyze | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
language: [ 'javascript' ] | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v1 | ||
with: | ||
languages: ${{ matrix.language }} | ||
|
||
- name: Autobuild | ||
uses: github/codeql-action/autobuild@v1 | ||
|
||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v1 |
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,35 @@ | ||
.idea | ||
.vscode | ||
*.iml | ||
*.p12 | ||
.DS_Store | ||
builds | ||
build | ||
dist | ||
venv | ||
/**/target | ||
/**/*.pyc | ||
k8.cert | ||
db.sqlite3 | ||
*.pyc | ||
.venv | ||
node_modules/ | ||
/.pnp | ||
.pnp.js | ||
coverage/ | ||
build/ | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.eslintcache | ||
*.tfvars | ||
*.jks | ||
*.pem | ||
*.cert | ||
*.tfstate* | ||
.terraform | ||
.coverage |
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,35 @@ | ||
FROM nginx:mainline | ||
RUN apt-get -y update && apt-get -y upgrade && apt-get -y install python3 python3-pip npm libsm6 libxrender-dev libxext6 | ||
|
||
# Copy the React frontend app files into the container, install dependencies and build it. | ||
COPY react_frontend /applications/scrounger/react_frontend | ||
WORKDIR /applications/scrounger/react_frontend | ||
ARG CI_COMMIT_SHA | ||
RUN npm install -g npm@latest | ||
RUN npm cache verify | ||
RUN npm ci && CI_COMMIT_SHA=$CI_COMMIT_SHA npm run build | ||
|
||
# Install Python dependencies and copy the Django backend application files into the container. | ||
COPY django_backend/Pipfile /applications/scrounger/Pipfile | ||
COPY django_backend/Pipfile.lock /applications/scrounger/Pipfile.lock | ||
WORKDIR /applications/scrounger | ||
ENV PYTHONPATH /applications/scrounger/api:$PATH | ||
RUN pip3 install --upgrade pip \ | ||
&& pip3 install pipenv \ | ||
&& pipenv install --system --deploy | ||
COPY django_backend /applications/scrounger/django_backend | ||
|
||
# Run the Django collect static command. This will bundle of the static files required for | ||
# Django admin pages. | ||
WORKDIR /applications/scrounger/django_backend | ||
RUN python3 ./manage.py collectstatic --no-input | ||
|
||
# Copy the Nginx configuration file into the default location. | ||
COPY nginx_server/nginx.conf /etc/nginx/conf.d/default.conf | ||
|
||
# Set the entrypoint to run a script that will run the frontend and backend application | ||
# servers. The main nginx server that is exposed to outside world runs on container | ||
# startup as a background service. | ||
COPY nginx_server/start-servers.sh /applications/scrounger/start-servers.sh | ||
WORKDIR / | ||
ENTRYPOINT ["sh", "/applications/scrounger/start-servers.sh"] |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Zorroa | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,105 @@ | ||
![Django Backend](https://github.com/Zorroa/scrounger/workflows/Django%20Backend/badge.svg) ![React Frontend](https://github.com/Zorroa/scrounger/workflows/React%20Frontend/badge.svg) | ||
# What is Scrounger? | ||
|
||
Scrounger is an open source content search application built by [Zorroa](https://zorroa.com), the makers of a GUI-driven machine learning integration platform. The app is designed to let its users experience what it’s like to load their media assets and run an ML-powered search within a custom app, in under an hour. | ||
The purpose of the Scrounger application is to: | ||
- Guide developers on the best practices of integrating ML-generated metadata into a proprietary or third party app using the Zorroa Python library. | ||
- Enable business end-users to evaluate the accelerated value Zorroa's search capability can deliver to their organization. | ||
- Serve as a starting point for a media storage and search app that can be extended into a proprietary app to meet unique business needs. | ||
|
||
# Deployment | ||
Scrounger consists of a single Docker container that can be configured using environment | ||
variables. It can be deployed anywhere a container can be run but we have included easy | ||
instructions for deploying in the two most common scenarios. | ||
|
||
### Prerequisites | ||
- Zorroa API Key with "Assets Read" permission - [API Key Instructions](https://zorroa.gitbook.io/zmlp/getting-started/quick-start/python-zvi-client#get-api-key) | ||
|
||
## Cloud Deployment | ||
We suggest using Digital Ocean to get up and running with the | ||
least amount of friction. The deployment process tasks about 10 minutes and costs less | ||
than $20/month. Full instructions are at the link below. | ||
|
||
[Digital Ocean Deployment Instructions](https://zorroa.gitbook.io/scrounger/) | ||
|
||
## On-Prem Deployment | ||
The following instructions are intended for an on-prem deployment used for testing and | ||
evaluation purposes. This is not intended to be a production-grade installation; the | ||
server will only accept HTTP connections on port 80 and users are tracked in a sqlite | ||
database. | ||
|
||
To start up scrounger run the following commands on a server that has docker installed and | ||
is exposed on your network. | ||
|
||
```bash | ||
docker pull zmlp/scrounger | ||
docker run -d -p 80:8080 -v /var/lib/scrounger:/applications/scrounger/django_backend/scrounger/sqlite -e ZMLP_API_KEY='<ZMLP_API_KEY>' zmlp/scrounger | ||
``` | ||
|
||
Scrounger will now be running at http://<hostname_or_ip_address> | ||
|
||
# Development | ||
|
||
## Architecture | ||
|
||
Scrounger is open-sourced under the MIT license and we encourage anyone to fork this repo and | ||
use this as a base for building a proprietary web application that leverages Zorroa for | ||
improving search capabilities of unknown and unstructured data. Below is a description of the | ||
applications architecture and how to get started extending it. | ||
|
||
|
||
|
||
|
||
+------------------------+ | ||
| | | ||
| NGINX Server | | ||
| | | ||
+------------------------+ | ||
| | | ||
| | | ||
| | | ||
v v | ||
+-------------------------+ +---------------------------+ | ||
| | | | | ||
| React Node Application | | Django uWSGI Application | | ||
| (Frontend) | | (Backend) | | ||
| | | | | ||
+-------------------------+ +---------------------------+ | ||
| | ||
v | ||
+---------------------+ | ||
| | | ||
| Relational Database | | ||
| | | ||
+---------------------+ | ||
|
||
|
||
|
||
|
||
Scrounger consists of 3 major components. | ||
|
||
### Nginx Server | ||
Nginx server exposed to the outside world. It is responsible for routing | ||
requests to either the frontend or backend application based on the path. Any request beginning | ||
with `/api` or `/admin` is routed to the Django backend and all other requests are routed to | ||
the React frontend. | ||
|
||
### React Node Application | ||
Frontend application responsible for rendering | ||
all pages that are sent to the client. It is a React app served by a Next.js server | ||
running on port 3000. | ||
|
||
### Django uWSGI Application | ||
Backend application responsible for providing the API | ||
endpoints the frontend uses for fetching data and handling authentication and user administration. | ||
It is a Django/uWSGI application served by a gunicorn server on port 8000. | ||
|
||
## Getting Started. | ||
To get started extending any of these components view the README.md found in each of their | ||
respective folders for more information. | ||
|
||
[nginx_server/](https://github.com/Zorroa/scrounger/tree/main/nginx_server) | ||
|
||
[react_frontend/](https://github.com/Zorroa/scrounger/tree/main/react_frontend) | ||
|
||
[django_backend/](https://github.com/Zorroa/scrounger/tree/main/django_backend) |
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,16 @@ | ||
[[source]] | ||
name = "pypi" | ||
url = "https://pypi.org/simple" | ||
verify_ssl = true | ||
|
||
[dev-packages] | ||
|
||
[packages] | ||
django = "*" | ||
flake8 = "*" | ||
gunicorn = "*" | ||
zvi-client = "*" | ||
psycopg2-binary = "*" | ||
|
||
[requires] | ||
python_version = "3.7" |
Oops, something went wrong.