Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into feat/add-deposited-tab
Browse files Browse the repository at this point in the history
  • Loading branch information
obah committed Jan 23, 2025
2 parents 76991da + 8c170ab commit f8fb02e
Show file tree
Hide file tree
Showing 15 changed files with 299 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ jobs:
ssh -p ${{ secrets.SERVER_PORT }} ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} "
mkdir -p ${{ secrets.PROJECT_PATH }}
cd ${{ secrets.PROJECT_PATH }}
docker-compose pull && docker-compose up --detach --remove-orphans
docker compose -f devops/docker-compose.yaml pull && docker compose -f devops/docker-compose.yaml up --detach--remove-orphans
"
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ jobs:
run: cp .env.dev .env

- name: Start services
run: docker compose -f docker-compose.dev.yaml --env-file .env up -d --build
run: docker compose -f devops/docker-compose.dev.yaml --env-file .env up -d --build

- name: Run tests
run: |
docker compose exec backend poetry run pytest web_app/tests
docker compose -f devops/docker-compose.dev.yaml exec -T backend poetry run pytest web_app/tests
- name: Run tests coverage
run: |
docker compose exec backend poetry run pytest --cov=web_app/tests --cov-fail-under=90
docker compose -f devops/docker-compose.dev.yaml exec -T backend poetry run pytest --cov=web_app/tests --cov-fail-under=90
- name: Tear down
run: |
docker compose down
docker compose -f devops/docker-compose.dev.yaml down
14 changes: 7 additions & 7 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- name: Build and Start Containers
run: |
docker compose -f docker-compose.dev.yaml --env-file .env up -d --build
docker compose -f devops/docker-compose.dev.yaml --env-file .env up -d --build
echo "Waiting for containers to be ready..."
sleep 30
Expand All @@ -65,31 +65,31 @@ jobs:
# Check if the container is still running before logging
if ! docker ps | grep -q backend; then
echo "Backend container is not running!"
docker compose -f docker-compose.dev.yaml logs backend || true
docker compose -f devops/docker-compose.dev.yaml logs backend || true
exit 1
fi
# Log the backend service status for debugging purposes.
docker compose -f docker-compose.dev.yaml logs backend || true
docker compose -f devops/docker-compose.dev.yaml logs backend || true
done
- name: Apply Migrations
run: |
docker exec backend_dev alembic -c web_app/alembic.ini upgrade head || {
echo "Migration failed. Showing backend logs:"
docker compose -f docker-compose.dev.yaml logs backend || true
docker compose -f devops/docker-compose.dev.yaml logs backend || true
exit 1
}
- name: Run Integration Tests with Coverage
run: |
docker compose exec backend bash -c "cd /app && python -m pytest web_app/test_integration/ -v"
docker compose -f devops/docker-compose.dev.yaml exec backend bash -c "cd /app && python -m pytest web_app/test_integration/ -v"
- name: Clean Up
if: always()
run: |
docker compose -f docker-compose.dev.yaml logs > docker-logs.txt || true
docker compose -f docker-compose.dev.yaml down -v
docker compose -f devops/docker-compose.dev.yaml logs > docker-logs.txt || true
docker compose -f devops/docker-compose.dev.yaml down -v
- name: Upload Docker Logs on Failure
if: failure()
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
prod:
@echo "Setting up production environment..."
@docker-compose -f docker-compose.yaml up --build
@docker compose -f devops/docker-compose.yaml up --build
@echo "Production environment is ready."

dev:
@echo "Setting up development environment..."
@docker-compose -f docker-compose.dev.yaml up --build
@docker compose -f devops/docker-compose.dev.yaml up --build

windows:
@echo "Setting up for Windows..."
@docker-compose -f docker-compose.dev-windows.yaml up --build
@docker compose -f devops/docker-compose.dev-windows.yaml up --build
@echo "Windows setup completed."

back:
@echo "Starting backend services..."
@docker-compose -f docker-compose.back.yaml up --build
@docker compose -f devops/docker-compose.back.yaml up --build
@echo "Backend services are running."

all:
Expand Down
71 changes: 55 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,49 @@ This guide explains how to start the development environment for the project usi

## Prerequisites

- Docker installed on your machine (v19.03+ recommended).
- Docker Compose installed (v1.27+ recommended).
- Docker installed on your machine (2.10+ recommended).
- Docker Compose installed (v2.0+ recommended).
- Ensure port **5433** is available for the PostgreSQL container.

### Version Requirements

1. **Check Docker version:**
```sh
docker --version
# Should output something like: Docker version 24.0.7, build afdd53b
```
If your version is below 20.10.0, please update Docker following the [official upgrade guide](https://docs.docker.com/engine/install/).

2. **Check Docker Compose version:**
```sh
# For Docker Compose V2
docker compose version
# Should output something like: Docker Compose version v2.21.0
```

If you get a "command not found" error, you might have the older version. Check with:
```sh
docker-compose version
```

### Installing/Updating Docker

1. **For Ubuntu/Debian:**
```sh
# Remove old versions
sudo apt-get remove docker docker-engine docker.io containerd runc

# Install latest version
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
```

2. **For Windows/Mac:**
- Download and install [Docker Desktop](https://www.docker.com/products/docker-desktop/)

3. **For other systems:**
- Follow the [official Docker installation guide](https://docs.docker.com/engine/install/)

## Starting the Development Environment

1. **Clone the Repository**
Expand All @@ -38,13 +77,13 @@ This guide explains how to start the development environment for the project usi
To build and run the entire development environment, use the following command:

```sh
docker-compose -f docker-compose.dev.yaml up --build
docker compose -f devops/docker-compose.dev.yaml up --build
```

For Windows users, use this command to build and start the development environment:

```sh
docker-compose -f docker-compose.dev-windows.yaml up --build
docker compose -f devops/docker-compose.dev-windows.yaml up --build
```

This command will:
Expand Down Expand Up @@ -110,13 +149,13 @@ To simplify repetitive tasks and ensure consistency, a `Makefile` is included in
- **Docker Build Issues**: If changes in dependencies are not reflected, you may need to clear Docker's cache:
```sh
docker-compose -f docker-compose.dev.yaml build --no-cache
docker compose -f devops/docker-compose.dev.yaml build --no-cache
```
Windows users:
```sh
docker-compose -f docker-compose.dev-windows.yaml build --no-cache
docker compose -f devops/docker-compose.dev-windows.yaml build --no-cache
```
## How to run test cases
Expand Down Expand Up @@ -144,13 +183,13 @@ poetry run pytest
To stop the environment and remove containers, use:
```sh
docker-compose -f docker-compose.dev.yaml down
docker compose -f devops/docker-compose.dev.yaml down
```
windows users:
```sh
docker-compose -f docker-compose.dev-windows.yaml down
docker compose -f devops/docker-compose.dev-windows.yaml down
```
This command stops all running containers and removes them, but the data volumes will persist.
Expand All @@ -160,13 +199,13 @@ This command stops all running containers and removes them, but the data volumes
If you have made changes to the code or Docker configuration, rebuild the containers:
```sh
docker-compose -f docker-compose.dev.yaml up --build
docker compose -f devops/docker-compose.dev.yaml up --build
```
windows users:
```sh
docker-compose -f docker-compose.dev-windows.yaml up --build
docker compose -f devops/docker-compose.dev-windows.yaml up --build
```
## About Celery
Expand All @@ -184,7 +223,7 @@ This project utilizes Celery to handle asynchronous tasks. The Celery workers an
To start the Celery worker and Celery Beat services, use the following command in the terminal within your project directory:
```bash
docker-compose up -d celery celery_beat
docker compose up -d celery celery_beat
```
### Stopping Celery
Expand All @@ -200,21 +239,21 @@ docker-compose stop celery celery_beat
If you want to purge all tasks from the Celery queue, you can do this by executing
```bash
docker-compose run --rm celery celery -A spotnet_tracker.celery_config purge
docker compose run --rm celery celery -A spotnet_tracker.celery_config purge
```
## How to add test data
1. Run dev container
```
docker-compose -f docker-compose.dev.yaml up --build
docker compose -f devops/docker-compose.dev.yaml up --build
```
windows only:
```
docker-compose -f docker-compose.dev-windows.yaml up --build
docker compose -f devops/docker-compose.dev-windows.yaml up --build
```
2. In new terminal window run command to populate db
Expand All @@ -228,13 +267,13 @@ docker exec -ti backend_dev python -m web_app.db.seed_data
Run up docker containers
```bash
docker-compose -f docker-compose.dev.yaml up --build
docker compose -f docker-compose.dev.yaml up --build
```
Windows users:
```bash
docker-compose -f docker-compose.dev-windows.yaml up --build
docker compose -f devops/docker-compose.dev-windows.yaml up --build
```
Go to backend container in new terminal window
Expand Down
10 changes: 5 additions & 5 deletions docker-compose.back.yaml → devops/docker-compose.back.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ networks:

services:
backend:
build: .
build: ..
command: bash /app/entrypoint.sh
container_name: backend_dev
volumes:
- ./entrypoint.sh:/app/entrypoint.sh
- .:/app
- ../entrypoint.sh:/app/entrypoint.sh
- ..:/app
env_file:
- .env.dev
- ../.env.dev
expose:
- "8000"
ports:
Expand All @@ -38,7 +38,7 @@ services:
POSTGRES_PASSWORD: password
volumes:
- postgres_data_dev:/var/lib/postgresql/data
- ./init-db:/docker-entrypoint-initdb.d
- ../init-db:/docker-entrypoint-initdb.d
networks:
- app_network
ports:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ networks:
services:
backend:
build:
context: .
context: ..
dockerfile: Dockerfile.windows
command: ["/bin/bash", "-c", "chmod +x /app/entrypoint.sh && /app/entrypoint.sh"]
container_name: backend_dev
volumes:
- .:/app
- ..:/app
env_file:
- .env.dev
- ../.env.dev
ports:
- "8000:8000"
networks:
Expand All @@ -38,7 +38,7 @@ services:
POSTGRES_PASSWORD: password
volumes:
- postgres_data_dev:/var/lib/postgresql/data
- ./init-db:/docker-entrypoint-initdb.d
- ../init-db:/docker-entrypoint-initdb.d
networks:
- app_network
ports:
Expand All @@ -51,11 +51,11 @@ services:

frontend:
build:
context: ./frontend
context: ../frontend
dockerfile: Dockerfile.dev
container_name: frontend_dev
volumes:
- ./frontend:/app
- ../frontend:/app
ports:
- "3000:80"
networks:
Expand Down
16 changes: 8 additions & 8 deletions docker-compose.dev.yaml → devops/docker-compose.dev.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
version: '3.8'
version: "3.8"

networks:
app_network:
driver: bridge

services:
backend:
build: .
build: ..
command: ["/app/entrypoint.sh"]
container_name: backend_dev
volumes:
- ./entrypoint.sh:/app/entrypoint.sh
- .:/app
- ../entrypoint.sh:/app/entrypoint.sh
- ..:/app
env_file:
- .env.dev
- ../.env.dev
ports:
- "8000:8000"
networks:
Expand All @@ -36,7 +36,7 @@ services:
POSTGRES_PASSWORD: password
volumes:
- postgres_data_dev:/var/lib/postgresql/data
- ./init-db:/docker-entrypoint-initdb.d
- ../init-db:/docker-entrypoint-initdb.d
networks:
- app_network
ports:
Expand All @@ -49,11 +49,11 @@ services:

frontend:
build:
context: ./frontend
context: ../frontend
dockerfile: Dockerfile.dev
container_name: frontend_dev
volumes:
- ./frontend:/app
- ../frontend:/app
ports:
- "3000:80"
networks:
Expand Down
Loading

0 comments on commit f8fb02e

Please sign in to comment.