Skip to content

Commit

Permalink
update files structure for docker compose
Browse files Browse the repository at this point in the history
  • Loading branch information
kayceeDev committed Jan 22, 2025
1 parent 528d505 commit 14af8a4
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 50 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
"
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ 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: |
Expand Down
12 changes: 6 additions & 6 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,19 +65,19 @@ 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
}
Expand All @@ -88,8 +88,8 @@ jobs:
- 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
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,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 +110,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 +144,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 +160,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 +184,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 @@ -208,13 +208,13 @@ docker-compose run --rm celery celery -A spotnet_tracker.celery_config purge
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 +228,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
12 changes: 6 additions & 6 deletions docker-compose.yaml → devops/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ networks:

services:
nginx:
build: ./frontend
build: ../frontend
container_name: nginx
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- ./certs/spotnet.xyz.chain.crt:/etc/nginx/spotnet.xyz.chain.crt:ro
- ./certs/spotnet.xyz.key:/etc/nginx/spotnet.xyz.key:ro
- ../certs/spotnet.xyz.chain.crt:/etc/nginx/spotnet.xyz.chain.crt:ro
- ../certs/spotnet.xyz.key:/etc/nginx/spotnet.xyz.key:ro
depends_on:
- backend
networks:
- app_network
backend:
build: .
build: ..
command: ["bash", "/app/entrypoint.sh"]
restart: always
volumes:
- ./entrypoint.sh:/app/entrypoint.sh
- ../entrypoint.sh:/app/entrypoint.sh
env_file:
- .env
- ../.env
depends_on:
- db
expose:
Expand Down

0 comments on commit 14af8a4

Please sign in to comment.