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

Fixes #127 #107 - deployment and run docker instances #160

Merged
merged 2 commits into from
May 12, 2023
Merged
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
39 changes: 33 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Trash AI: Web application for serverless image classification of trash
[![Website](https://img.shields.io/badge/Web-TrashAI.org-blue)](https://www.trashai.org)

[![Website](https://img.shields.io/badge/Web-TrashAI.org-blue)](https://www.trashai.org)

### Project Information

Expand All @@ -13,29 +13,56 @@
Trash AI is a web application where users can upload photos of litter, which will be labeled using computer vision to detect and categorize litter in the image by type. Early inspiration from [WADE AI](https://github.com/letsdoitworld/wade-ai) streamlined this development. Trash AI will enhance the abilities of researchers to quickly label trash in photos.

#### Demo

[![image](https://user-images.githubusercontent.com/26821843/188515526-33e1196b-6830-4187-8fe4-e68b2bd4019e.png)](https://youtu.be/HHrjUpQynUM)

## Deployment

You can simply go to www.trashai.org to start using the tool or deploy it yourself. Current self-deployment options are local deployment with docker to remote on Amazon Web Services (AWS).
You can simply go to www.trashai.org to start using the tool or deploy it yourself. Current self-deployment options are local deployment with docker to remote on Amazon Web Services (AWS).

### [Run Local Docker Instance](https://hub.docker.com/r/code4sac/trashai)

```
docker run -p 5150:5150 -it code4sac/trashai:latest
```

Navigate to to http://localhost:5150

### Deploy to Any Webserver

If you want to deploy this to a static web directory and serve it using
`apache` or `nginx`, you can do so with the following command using `/var/www/html`
as an example destination directory.

```
# create container from latest public trash ai docker image
id=$(docker create code4sac/trashai:latest)

# copy the static files
docker cp $id:/usr/share/nginx/html /var/www/html

# remove created container
docker rm -v $id
```

### [Local Development](./docs/localdev.md)

- Run the environment live with localstack and docker.
- Run the environment live with localstack and docker.

### [AWS Deployment](./docs/git-aws-account-setup.md)

- Instructions on bringing up a new AWS deployment.
- Instructions on bringing up a new AWS deployment.

#### [Continuous Integration and Continuous Delivery (CI/CD) - Github Actions](./docs/github-actions.md)

- Mostly CD at this point.
- Mostly CD at this point.

#### [Github Actions AWS Deployment Role](./docs/github-actions-deployment-role.md)

- Runs the complex stuff so you don't have to.
- Runs the complex stuff so you don't have to.

## Contribute

We welcome contributions of all kinds.

To get started, look at the `Start Here` section of the [project board](https://github.com/orgs/code4sac/projects/13)
Expand Down
3 changes: 2 additions & 1 deletion bin/runfrontend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ IFS=$'\n\t'

export PATH="$PATH:/node_modules/.bin:/stack/bin:node_modules/.bin"

wait-for-it.sh -t 300 -h backend -p 4000
# Disabling until backend is needed
# wait-for-it.sh -t 300 -h backend -p 4000
cd /stack/frontend
while true; do
yarn
Expand Down
80 changes: 41 additions & 39 deletions localdev/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,60 +1,62 @@
version: "3.9"

services:
localstack:
image: localstack/localstack:0.13.3
ports:
# - "127.0.0.1:53:53" # only required for Pro
# - "127.0.0.1:53:53/udp" # only required for Pro
# - "127.0.0.1:443:443" # only required for Pro
- "127.0.0.1:4510-4530:4510-4530"
- "127.0.0.1:4566:4566"
- "127.0.0.1:4571:4571"
environment:
- LOCALSTACK_TMP_FOLDER=/tmp/trash-ai-localstack-tmp/
- LOCALSTACK_DATA_DIR=/tmp/trash-ai-localstack-persist/
volumes:
- ${LOCALSTACK_TMP_FOLDER}:/tmp/localstack
- ${LOCALSTACK_DATA_DIR}:/tmp/localstack_persist
- "/var/run/docker.sock:/var/run/docker.sock"

restart: always
# Disabling backend components util needed again
# localstack:
# image: localstack/localstack:0.13.3
# ports:
# # - "127.0.0.1:53:53" # only required for Pro
# # - "127.0.0.1:53:53/udp" # only required for Pro
# # - "127.0.0.1:443:443" # only required for Pro
# - "127.0.0.1:4510-4530:4510-4530"
# - "127.0.0.1:4566:4566"
# - "127.0.0.1:4571:4571"
# environment:
# - LOCALSTACK_TMP_FOLDER=/tmp/trash-ai-localstack-tmp/
# - LOCALSTACK_DATA_DIR=/tmp/trash-ai-localstack-persist/
# volumes:
# - ${LOCALSTACK_TMP_FOLDER}:/tmp/localstack
# - ${LOCALSTACK_DATA_DIR}:/tmp/localstack_persist
# - "/var/run/docker.sock:/var/run/docker.sock"
#
# restart: always

build_img:
image: trash_ai_bs
build:
context: ../
dockerfile: localdev/Dockerfile

bootstrap:
image: trash_ai_bs
env_file: ./.env
volumes:
- ../:/stack
command: /stack/bin/runbootstrap.sh
depends_on:
- build_img
# Disabling backend components util needed again
# bootstrap:
# image: trash_ai_bs
# env_file: ./.env
# volumes:
# - ../:/stack
# command: /stack/bin/runbootstrap.sh
# depends_on:
# - build_img

backend:
image: trash_ai_bs
env_file: ./.env
volumes:
- ../:/stack
command: /stack/bin/runbackend.sh
links:
- "bootstrap"
ports:
- ${VITE_BACKEND_PORT}:${VITE_BACKEND_PORT}
restart: always
# backend:
# image: trash_ai_bs
# env_file: ./.env
# volumes:
# - ../:/stack
# command: /stack/bin/runbackend.sh
# links:
# - "bootstrap"
# ports:
# - ${VITE_BACKEND_PORT}:${VITE_BACKEND_PORT}
# restart: always

frontend:
image: trash_ai_bs
env_file: ./.env
volumes:
- ../:/stack
command: /stack/bin/runfrontend.sh
links:
- "backend"
# links:
# - "backend"

environment:
VITE_GOOGLE_MAPS_API_KEY: ${VITE_GOOGLE_MAPS_API_KEY-:"NOGOOGLEKEY"}
Expand Down