Skip to content
Open
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
18 changes: 18 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
BACKEND_PORT=8000
FRONTEND_PORT=4200
IPFS_API_PORT=5001
IPFS_GATEWAY_PORT=8080
IPFS_SWARM_PORT=4001


# 🛠️ PostgreSQL DB
POSTGRES_USER=blockuser
POSTGRES_PASSWORD=blockpass
POSTGRES_DB=blocktrack_db
POSTGRES_PORT=15433

# 🧪 Adminer UI
ADMINER_PORT=8081

# Kafka
KAFKA_BROKER_URL=kafka:9092
19 changes: 19 additions & 0 deletions blocktrack_backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM python:3.11-slim

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

WORKDIR /app

RUN apt-get update && apt-get install -y \
build-essential \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

# Use environment variable PORT or default to 8000
CMD ["sh", "-c", "python manage.py migrate && python manage.py runserver 0.0.0.0:${BACKEND_PORT:-8000}"]
8 changes: 7 additions & 1 deletion blocktrack_backend/blocktrack_backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import os
from dotenv import load_dotenv
load_dotenv()

import dj_database_url

from pathlib import Path

Expand Down Expand Up @@ -95,6 +95,12 @@
'PORT': os.getenv('DB_PORT'),
}
}

DATABASES = {
'default': dj_database_url.config(
default=f"postgresql://{os.getenv('POSTGRES_USER')}:{os.getenv('POSTGRES_PASSWORD')}@blocktrack_postgres:5432/{os.getenv('POSTGRES_DB')}"
)
}
REST_FRAMEWORK = {
'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend']
}
Expand Down
3 changes: 2 additions & 1 deletion blocktrack_backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ psycopg2-binary
python-dotenv
kafka-python
django-cors-headers
drf_yasg
drf_yasg
dj-database-url
98 changes: 98 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
version: '3.9'

services:
# 🔗 Django backend
backend:
build:
context: ./blocktrack_backend
container_name: blocktrack_backend
volumes:
- ./blocktrack_backend:/app
ports:
- "${BACKEND_PORT:-8000}:8000"
depends_on:
- blocktrack_postgres
- ipfs
env_file:
- .env
environment:
- PYTHONUNBUFFERED=1

# 🌐 Angular frontend
frontend:
build:
context: ./frontend
container_name: frontend
volumes:
- ./frontend:/app
ports:
- "${FRONTEND_PORT:-4200}:4200"
env_file:
- .env
environment:
- NODE_ENV=development

# 🗃️ PostgreSQL database
blocktrack_postgres:
image: postgres:15
container_name: blocktrack_postgres
restart: always
environment:
POSTGRES_USER: ${POSTGRES_USER:-blockuser}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-blockpass}
POSTGRES_DB: ${POSTGRES_DB:-blocktrack_db}
ports:
- "${POSTGRES_PORT:-15433}:5432"
volumes:
- postgres_data:/var/lib/postgresql/data

# 🧪 Adminer UI
adminer:
image: adminer
container_name: blocktrack_adminer
restart: always
ports:
- "${ADMINER_PORT:-8081}:8080"
depends_on:
- blocktrack_postgres

# 🧿 IPFS node
ipfs:
image: ipfs/go-ipfs:latest
Copy link

Copilot AI May 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider pinning a specific version for the ipfs/go-ipfs image rather than using ':latest' to improve reproducibility and stability.

Suggested change
image: ipfs/go-ipfs:latest
image: ipfs/go-ipfs:v0.18.1

Copilot uses AI. Check for mistakes.
container_name: ipfs_node
ports:
- "${IPFS_API_PORT:-5001}:5001"
- "${IPFS_GATEWAY_PORT:-8080}:8080"
- "${IPFS_SWARM_PORT:-4001}:4001"
volumes:
- ipfs_staging:/export
- ipfs_data:/data/ipfs

kafka_broker:
image: bitnami/kafka:3.5
container_name: kafka_broker
ports:
- "9092:9092"
environment:
- KAFKA_BROKER_ID=1
- KAFKA_CFG_LISTENERS=PLAINTEXT://:9092
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka_broker:9092
- KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=PLAINTEXT:PLAINTEXT
- KAFKA_CFG_ZOOKEEPER_CONNECT=kafka_zookeeper:2181
- ALLOW_PLAINTEXT_LISTENER=yes
depends_on:
- kafka_zookeeper

kafka_zookeeper:
image: bitnami/zookeeper:latest
Copy link

Copilot AI May 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] It is advisable to specify a fixed version for bitnami/zookeeper instead of using ':latest' to avoid unexpected changes from future updates.

Suggested change
image: bitnami/zookeeper:latest
image: bitnami/zookeeper:3.8.0

Copilot uses AI. Check for mistakes.
container_name: kafka_zookeeper
ports:
- "2181:2181"
environment:
- ALLOW_ANONYMOUS_LOGIN=yes


volumes:
postgres_data:
ipfs_data:
ipfs_staging:
13 changes: 13 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:18

WORKDIR /app

# Copy dependency files first and install
COPY package*.json ./
RUN npm install

# Copy the rest of the Angular app
COPY . .

# Serve the app
CMD ["sh", "-c", "npx ng serve --host 0.0.0.0 --port ${FRONTEND_PORT:-4200}"]