Skip to content

Commit

Permalink
Merge pull request #33 from ISSResearch/ref-struct
Browse files Browse the repository at this point in the history
ref: struct
  • Loading branch information
githubering182 authored Mar 12, 2024
2 parents a28c528 + f69b529 commit b6912ba
Show file tree
Hide file tree
Showing 5 changed files with 216 additions and 42 deletions.
1 change: 1 addition & 0 deletions Dockerfile.frontend
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ COPY ./frontend-app/tsconfig.json ./
COPY ./frontend-app/.eslintrc.json ./

RUN npm install
RUN npm install -g serve

COPY ./frontend-app/src ./src
COPY ./frontend-app/public ./public
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
start:
docker compose up -d

start-b:
start-new:
docker compose up -d --build

stop:
Expand All @@ -10,6 +10,18 @@ stop:
restart:
make stop && make start

start-dev:
docker compose -f docker-compose.dev.yml up -d

start-dev-new:
docker compose -f docker-compose.dev.yml up -d --build

stop-dev:
docker compose -f docker-compose.dev.yml down

restart-dev:
make stop-dev && make start-dev

start-test:
docker compose -f docker-compose.test.yml up -d --build

Expand Down
46 changes: 35 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ISS Data Collection Tool

## Makefile convinience commands (**docker** and **.env** file are supposed to be set):
## Makefile convinient commands (**docker/docker-compose** and **.env file** are supposed to be set):

- start project:
`make start`
Expand All @@ -9,28 +9,37 @@
- restart project:
`make restart`
- start project with rebuild:
`make start-b`
`make start-new`
- start development project:
`make start-dev`
- stop development project:
`make stop-dev`
- restart development project:
`make restart-dev`
- start project with rebuild:
`make start-dev-new`
- start tests:
`make start-test`
- stop tests:
`make stop-test`
- restart tests:
`make restart-test`
- dump main apps database schema:
`make appdb-dump-schema`
- dump main apps database data:
`make appdb-dump-data`
- dump main apps database (schema and data separately):
`make dump-database`

## Deployment

### 1. Install Docker
## Prerequisites:

### 2. Create and fill **.env** file
- **docker/docker-compose** installed
- create and fill **.env** file from sample

For local development copying sample is enough:
`cp .env.sample .env`

### 2. Run Containers:

#### Main App:
## Running Application

Docker Compose file: docker-compose.yml

Expand All @@ -43,6 +52,19 @@ Docker files:
Command:
`docker-compose up -d --build`

## Development

Docker Compose file: docker-compose.dev.yml

Docker files:

- Dockerfile.backend
- Dockerfile.frontend
- Dockerfile.storage

Command:
`docker-compose -f docker-compose.dev.yml up -d --build`

## Testing

Docker Compose file: docker-compose.test.yml
Expand All @@ -59,12 +81,14 @@ Available tests:
- Main Backend:
`docker exec iss-test-back ./manage.py test`
- Storage Backend:
`tdb`
`docker exec iss-test-storage python3 src/test.py`
- Frontend:
`docker exec iss-test-front npm test`
- Selenium Tests (browser emulation):
`docker exec iss-tests python3 test.py`
- Python linter (no output means the lint test is passed):
`docker exec iss-tests flake8`
- JavaScript linter:
`tbd`
`docker exec iss-test-front npm run lint`
- JavaScript ts compiler checker:
`docker exec iss-test-front npm run compile`
165 changes: 165 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
version: "3.8"

services:
iss-main-db:
container_name: iss-main-db
image: postgres:15.3-alpine
restart: always
environment:
POSTGRES_DB: ${DB_APP_DB_NAME}
POSTGRES_HOST_AUTH_METHOD: ${DB_APP_AUTH_METHOD}
volumes:
- ./db:/var/lib/postgresql/data
networks:
- iss_network

iss-storage-db:
image: mongo:7.0.1-rc0
container_name: iss-storage-db
environment:
MONGO_INITDB_ROOT_USERNAME: ${DB_STORAGE_USER}
MONGO_INITDB_ROOT_PASSWORD: ${DB_STORAGE_PASSWORD}
volumes:
- ./storage:/data/db
restart: always
networks:
- iss_network

iss-back:
container_name: iss-back
image: iss-back
build:
dockerfile: Dockerfile.backend
restart: always
environment:
DB_HOST: iss-main-db
DB_NAME: ${DB_APP_DB_NAME}
SERVER_ORIGINS: ${SERVER_ORIGINS}
DEBUG: ${DEBUG}
SECRET_KEY: ${SECRET_KEY}
SECRET_ALGO: ${SECRET_ALGO}
MAX_WORKER: ${MAX_WORKER}
depends_on:
- iss-main-db
volumes:
- ./backend-app:/app
command: >
sh -c "python manage.py makemigrations user &&
python manage.py makemigrations project &&
python manage.py makemigrations attribute &&
python manage.py makemigrations file &&
python manage.py migrate &&
gunicorn --config './conf/gunicorn_conf.py' proj_back.wsgi:application"
networks:
- iss_network

iss-storage:
container_name: iss-storage
image: iss-storage
build:
dockerfile: Dockerfile.storage
restart: always
environment:
DB_HOST: iss-storage-db
APP_BACKEND_URL: iss-back:8000
DB_USER: ${DB_STORAGE_USER}
DB_PASSWORD: ${DB_STORAGE_PASSWORD}
DEBUG: ${DEBUG}
CELERY_BROKER_URL: ${BROKER_URL}
SECRET_KEY: ${SECRET_KEY}
SECRET_ALGO: ${SECRET_ALGO}
MAX_WORKER: ${MAX_WORKER}
depends_on:
- iss-storage-db
- iss-back
volumes:
- ./storage-app/src:/app/src
command: python3 src/app.py
networks:
- iss_network

iss-front:
container_name: iss-front
image: iss_front
build:
dockerfile: Dockerfile.frontend
restart: always
depends_on:
- iss-back
ports:
- 3000:3000
volumes:
- ./frontend-app/src:/app/src
- ./frontend-app/public:/app/public
command: npm start
networks:
- iss_network

iss-broker:
container_name: iss-broker
image: redis:alpine3.18
restart: always
volumes:
- ./broker-db:/data
- ./redis:/conf
command: redis-server /conf/redis.conf
networks:
- iss_network

iss-worker:
container_name: iss-worker
build:
dockerfile: Dockerfile.storage
restart: always
volumes:
- ./storage-app/src:/app/src
environment:
DB_HOST: iss-storage-db
APP_BACKEND_URL: iss-back:8000
DB_USER: ${DB_STORAGE_USER}
DB_PASSWORD: ${DB_STORAGE_PASSWORD}
DEBUG: ${DEBUG}
CELERY_BROKER_URL: ${BROKER_URL}
SECRET_KEY: ${SECRET_KEY}
SECRET_ALGO: ${SECRET_ALGO}
depends_on:
- iss-broker
- iss-back
command: python3 src/worker.py
networks:
- iss_network

iss-proxy:
container_name: iss-proxy
image: nginx:1.25.1-alpine
restart: always
depends_on:
- iss-back
- iss-storage
ports:
- 9000:9000
- 8000:8000
volumes:
- ./nginx:/etc/nginx/conf.d
networks:
- iss_network

dashboard:
container_name: iss_dashboard
build:
dockerfile: Dockerfile.storage
ports:
- 9090:5555
environment:
CELERY_BROKER_URL: ${BROKER_URL}
CELERY_RESULT_BACKEND: ${BROKER_URL}
restart: always
depends_on:
- iss-broker
- iss-worker
command: celery --broker=redis://iss-broker:6379/0 flower --port=5555
networks:
- iss_network

networks:
iss_network:
32 changes: 2 additions & 30 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,11 @@ services:
DB_HOST: iss-main-db
DB_NAME: ${DB_APP_DB_NAME}
SERVER_ORIGINS: ${SERVER_ORIGINS}
DEBUG: ${DEBUG}
SECRET_KEY: ${SECRET_KEY}
SECRET_ALGO: ${SECRET_ALGO}
MAX_WORKER: ${MAX_WORKER}
depends_on:
- iss-main-db
volumes:
- ./backend-app:/app
command: >
sh -c "python manage.py makemigrations user &&
python manage.py makemigrations project &&
Expand All @@ -64,16 +61,13 @@ services:
APP_BACKEND_URL: iss-back:8000
DB_USER: ${DB_STORAGE_USER}
DB_PASSWORD: ${DB_STORAGE_PASSWORD}
DEBUG: ${DEBUG}
CELERY_BROKER_URL: ${BROKER_URL}
SECRET_KEY: ${SECRET_KEY}
SECRET_ALGO: ${SECRET_ALGO}
MAX_WORKER: ${MAX_WORKER}
depends_on:
- iss-storage-db
- iss-back
volumes:
- ./storage-app/src:/app/src
command: python3 src/app.py
networks:
- iss_network
Expand All @@ -88,10 +82,8 @@ services:
- iss-back
ports:
- 3000:3000
volumes:
- ./frontend-app/src:/app/src
- ./frontend-app/public:/app/public
command: npm start
command: >
sh -c "npm run build && serve -s build"
networks:
- iss_network

Expand All @@ -111,14 +103,11 @@ services:
build:
dockerfile: Dockerfile.storage
restart: always
volumes:
- ./storage-app/src:/app/src
environment:
DB_HOST: iss-storage-db
APP_BACKEND_URL: iss-back:8000
DB_USER: ${DB_STORAGE_USER}
DB_PASSWORD: ${DB_STORAGE_PASSWORD}
DEBUG: ${DEBUG}
CELERY_BROKER_URL: ${BROKER_URL}
SECRET_KEY: ${SECRET_KEY}
SECRET_ALGO: ${SECRET_ALGO}
Expand All @@ -144,22 +133,5 @@ services:
networks:
- iss_network

dashboard:
container_name: iss_dashboard
build:
dockerfile: Dockerfile.storage
ports:
- 9090:5555
environment:
CELERY_BROKER_URL: ${BROKER_URL}
CELERY_RESULT_BACKEND: ${BROKER_URL}
restart: always
depends_on:
- iss-broker
- iss-worker
command: celery --broker=redis://iss-broker:6379/0 flower --port=5555
networks:
- iss_network

networks:
iss_network:

0 comments on commit b6912ba

Please sign in to comment.