Skip to content
Snippets Groups Projects
Commit dbe9c85e authored by Sinèad Mariè's avatar Sinèad Mariè
Browse files

Set up Dockerfiles for API Gateway and Microservices

- Set up Dockerfile for API Gateway
- Set up Dockerfile for User Service
- Set up Dockerfile for Transaction Service
- Set up Dockerfile for Budget Service
- Set up Dockerfile for Analytics Service
- Set up Dockerfile for Notification Service
- Ensured compatibility with docker-compose.yml for service orchestration
parent 273da941
Branches 1-set-up-dockerfiles-for-api-gateway-and-microservices
No related tags found
1 merge request!1Set up Dockerfiles for API Gateway and Microservices
Showing
with 213 additions and 6 deletions
 FROM python:3.12
\ No newline at end of file
WORKDIR /app
# Copy requirements.txt from the root context (now accessible)
COPY requirements.txt .
# Install dependencies globally
RUN pip install --no-cache-dir -r requirements.txt
# Copy only the current service's code
COPY ./analytics-service/app /app
EXPOSE 5004
CMD ["python", "app.py"]
 FROM python:3.12
\ No newline at end of file
WORKDIR /app
# Copy requirements.txt from the root directory
COPY requirements.txt .
# Install dependencies globally (no need for venv inside Docker)
RUN pip install --no-cache-dir -r requirements.txt
# Copy only the necessary files
COPY ./api-gateway/app /app
# Expose API Gateway port
EXPOSE 8000
# Run the API Gateway
CMD ["python", "app.py"]
 FROM python:3.12
\ No newline at end of file
WORKDIR /app
# Copy requirements.txt from the root context (now accessible)
COPY requirements.txt .
# Install dependencies globally
RUN pip install --no-cache-dir -r requirements.txt
# Copy only the current service's code
COPY ./budget-service/app /app
EXPOSE 5003
CMD ["python", "app.py"]
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
from flask import Flask, jsonify, request
app = Flask(__name__)
@app.route('/budgets', methods=['GET'])
def get_budgets():
return jsonify({"message": "Budget service active"}), 200
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5003)
version: '3.8'
services:
api-gateway:
build:
context: .
dockerfile: api-gateway/Dockerfile
ports:
- "8000:8000"
depends_on:
- user-service
- transaction-service
- budget-service
- analytics-service
- notification-service
user-service:
build:
context: .
dockerfile: user-service/Dockerfile
ports:
- "5001:5001"
transaction-service:
build:
context: .
dockerfile: transaction-service/Dockerfile
ports:
- "5002:5002"
budget-service:
build:
context: .
dockerfile: budget-service/Dockerfile
ports:
- "5003:5003"
analytics-service:
build:
context: .
dockerfile: analytics-service/Dockerfile
ports:
- "5004:5004"
notification-service:
build:
context: .
dockerfile: notification-service/Dockerfile
ports:
- "5005:5005"
frontend:
build:
context: ./frontend
ports:
- "3000:3000"
depends_on:
- api-gateway
# Use Node.js as base image
FROM node:20
WORKDIR /app
# Copy package.json and install dependencies
COPY package*.json ./
RUN npm install
# Copy all frontend code
COPY . .
# Expose frontend port
EXPOSE 3000
# Start the React app
CMD ["npm", "start"]
 FROM python:3.12
\ No newline at end of file
WORKDIR /app
# Copy requirements.txt from the root context (now accessible)
COPY requirements.txt .
# Install dependencies globally
RUN pip install --no-cache-dir -r requirements.txt
# Copy only the current service's code
COPY ./notification-service/app /app
EXPOSE 5005
CMD ["python", "app.py"]
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
from flask import Flask, jsonify
app = Flask(__name__)
@app.route('/notifications', methods=['GET'])
def get_notifications():
return jsonify({"message": "Notification service active"}), 200
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5005)
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
 FROM python:3.12
\ No newline at end of file
WORKDIR /app
# Copy requirements.txt from the root context (now accessible)
COPY requirements.txt .
# Install dependencies globally
RUN pip install --no-cache-dir -r requirements.txt
# Copy only the current service's code
COPY ./transaction-service/app /app
EXPOSE 5002
CMD ["python", "app.py"]
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
from flask import Flask, jsonify, request
app = Flask(__name__)
@app.route('/transactions', methods=['GET'])
def get_transactions():
return jsonify({"message": "Transaction service active"}), 200
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5002)
 FROM python:3.12
\ No newline at end of file
WORKDIR /app
# Copy requirements.txt from the root context (now accessible)
COPY requirements.txt .
# Install dependencies globally
RUN pip install --no-cache-dir -r requirements.txt
# Copy all service files from the app directory
COPY ./user-service/app /app
EXPOSE 5001
CMD ["python", "app.py"]
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
from flask import Flask, jsonify, request
app = Flask(__name__)
@app.route('/users', methods=['GET'])
def get_users():
return jsonify({"message": "User service active"}), 200
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5001)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment