Skip to content

Commit

Permalink
Dockerized
Browse files Browse the repository at this point in the history
  • Loading branch information
iamrobins committed Aug 9, 2024
1 parent 81baa0c commit 4a21109
Show file tree
Hide file tree
Showing 14 changed files with 359 additions and 15 deletions.
99 changes: 99 additions & 0 deletions docker-compose-local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
version: "3.9"
services:
mongo:
image: mongo
restart: always
network_mode: "host"
ports:
- '27017:27017'
volumes:
- ~/Desktop/map_insight/mapinsight_server/mongo/data:/data/db
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: password

rabbitmq:
image: rabbitmq:3-management-alpine
container_name: 'rabbitmq'
network_mode: "host"
ports:
- 5672:5672
- 15672:15672
volumes:
- ~/Desktop/map_insight/mapinsight_server/rabbitmq/data/:/var/lib/rabbitmq/
- ~/Desktop/map_insight/mapinsight_server/rabbitmq/log/:/var/log/rabbitmq
healthcheck:
test: ["CMD", "rabbitmqctl", "status"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s

gateway:
build:
context: ./gateway
network_mode: "host"
volumes:
- ~/Desktop/map_insight/mapinsight_server/gateway/:/app
environment:
PORT: 80
SEARCH_SERVICE_URI: http://search:8000
NOTIFICATION_SERVICE_URI: http://notifications:8001
depends_on:
rabbitmq:
condition: service_healthy


ports:
- '80:80'

search:
build:
context: ./search
network_mode: "host"
volumes:
- ~/Desktop/map_insight/mapinsight_server/search/:/app
environment:
PORT: 8000
MAP_INSIGHT_GCP_KEY: AIzaSyCMcayRBlOcBA6dJZF8lz6EIUR_mb8dWak
MONGO_URI: mongodb+srv://admin:[email protected]/?retryWrites=true&w=majority&appName=mapinsight-dev
RABBIT_MQ_URI: amqps://vgaivrln:[email protected]/vgaivrln
ports:
- '8000:8000'
depends_on:
rabbitmq:
condition: service_healthy


insights:
build:
context: ./insights
network_mode: "host"
volumes:
- ~/Desktop/map_insight/mapinsight_server/insights/:/app
environment:
NOTIFICATION_URL: http://notifications:8001
RABBIT_MQ_URI: amqps://vgaivrln:[email protected]/vgaivrln
OPENAI_API_KEY: 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
MONGO_URI: mongodb+srv://admin:[email protected]/?retryWrites=true&w=majority&appName=mapinsight-dev
depends_on:
rabbitmq:
condition: service_healthy


notifications:
build:
context: ./notifications
network_mode: "host"
volumes:
- ~/Desktop/map_insight/mapinsight_server/notifications/:/app
environment:
PORT: 8001
RABBIT_MQ_URI: amqps://vgaivrln:[email protected]/vgaivrln
depends_on:
rabbitmq:
condition: service_healthy


ports:
- '8001:8001'
41 changes: 41 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
version: "3.9"
services:
gateway:
build:
context: ./gateway
dockerfile: Dockerfile.dev
volumes:
- ~/Desktop/map_insight/mapinsight_server/gateway/:/app
env_file:
- ./gateway/.env.dev
ports:
- '80:80'

search:
build:
context: ./search
dockerfile: Dockerfile.dev
volumes:
- ~/Desktop/map_insight/mapinsight_server/search/:/app
env_file:
- ./search/.env.dev


insights:
build:
context: ./insights
dockerfile: Dockerfile.dev
volumes:
- ~/Desktop/map_insight/mapinsight_server/insights/:/app
env_file:
- ./insights/.env.dev


notifications:
build:
context: ./notifications
dockerfile: Dockerfile.dev
volumes:
- ~/Desktop/map_insight/mapinsight_server/notifications/:/app
env_file:
- ./notifications/.env.dev
5 changes: 5 additions & 0 deletions gateway/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.git
.gitignore
*Dockerfile*
*docker-compose*
node_modules
20 changes: 20 additions & 0 deletions gateway/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use the official Node.js image as the base image
FROM node:20-alpine

# Set the working directory
WORKDIR /app

# Copy the package.json and package-lock.json
COPY package*.json ./

# Install the dependencies
RUN npm install

# Copy the rest of the application code
COPY . .

# Expose the port the app runs on
EXPOSE 80

# Start the application
CMD ["npm", "run", "dev"]
89 changes: 89 additions & 0 deletions insights/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Git
.git
.gitignore
.gitattributes


# CI
.codeclimate.yml
.travis.yml
.taskcluster.yml

# Docker
docker-compose.yml
Dockerfile
.docker
.dockerignore

# Byte-compiled / optimized / DLL files
**/__pycache__/
**/*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Virtual environment
.env
.venv/
venv/

# PyCharm
.idea

# Python mode for VIM
.ropeproject
**/.ropeproject

# Vim swap files
**/*.swp

# VS Code
.vscode/
8 changes: 4 additions & 4 deletions insights/.env.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RABBIT_MQ=amqp://guest:guest@localhost:5672
NOTIFICATION_URL=localhost:8001
OPENAI_API_KEY=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
MONGO_URI=mongodb://localhost:27017/
NOTIFICATION_URL=http://notifications:8001
RABBIT_MQ_URI=amqps://vgaivrln:[email protected]/vgaivrln
OPENAI_API_KEY=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
MONGO_URI=mongodb+srv://admin:[email protected]/?retryWrites=true&w=majority&appName=mapinsight-dev
25 changes: 25 additions & 0 deletions insights/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM python:3.12-alpine

# Set up environment variables for Python
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# Create and set the working directory
WORKDIR /app

# Copy only the requirements file first to leverage Docker caching
COPY requirements.txt .

# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy the entire application code
COPY . .

# Expose the port your application will run on
EXPOSE 8080

RUN chmod +x ./run.sh

# Specify the command to run on container start
CMD ["./run.sh", "start"]
2 changes: 1 addition & 1 deletion insights/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from convert import to_insight

def main():
params = pika.URLParameters(os.getenv('RABBIT_MQ'))
params = pika.URLParameters(os.getenv('RABBIT_MQ_URI'))
params.socket_timeout = 5
connection = pika.BlockingConnection(params)
channel = connection.channel()
Expand Down
20 changes: 20 additions & 0 deletions insights/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
annotated-types==0.7.0
anyio==4.4.0
certifi==2024.7.4
charset-normalizer==3.3.2
distro==1.9.0
dnspython==2.6.1
h11==0.14.0
httpcore==1.0.5
httpx==0.27.0
idna==3.7
openai==1.38.0
pika==1.3.2
pydantic==2.8.2
pydantic_core==2.20.1
pymongo==4.8.0
python-dotenv==1.0.1
sniffio==1.3.1
tqdm==4.66.4
typing_extensions==4.12.2
urllib3==2.2.2
5 changes: 5 additions & 0 deletions notifications/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.git
.gitignore
*Dockerfile*
*docker-compose*
node_modules
20 changes: 20 additions & 0 deletions notifications/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use the official Node.js image as the base image
FROM node:20-alpine

# Set the working directory
WORKDIR /app

# Copy the package.json and package-lock.json
COPY package*.json ./

# Install the dependencies
RUN npm install

# Copy the rest of the application code
COPY . .

# Expose the port the app runs on
EXPOSE 80

# Start the application
CMD ["npm", "run", "dev"]
5 changes: 5 additions & 0 deletions search/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.git
.gitignore
*Dockerfile*
*docker-compose*
node_modules
20 changes: 20 additions & 0 deletions search/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use the official Node.js image as the base image
FROM node:20-alpine

# Set the working directory
WORKDIR /app

# Copy the package.json and package-lock.json
COPY package*.json ./

# Install the dependencies
RUN npm install

# Copy the rest of the application code
COPY . .

# Expose the port the app runs on
EXPOSE 80

# Start the application
CMD ["npm", "run", "dev"]
Loading

0 comments on commit 4a21109

Please sign in to comment.