From dbe9c85e1e751eed7fd5c37d027e176de13f1fe8 Mon Sep 17 00:00:00 2001 From: sinead-obeng <sinead.obeng@gmail.com> Date: Fri, 21 Mar 2025 15:03:14 +0000 Subject: [PATCH] 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 --- .../analytics-service/Dockerfile | 17 ++++- .../analytics-service/{ => app}/app.py | 0 financial-tracker/api-gateway/Dockerfile | 19 +++++- .../api-gateway/{ => app}/app.py | Bin financial-tracker/budget-service/Dockerfile | 17 ++++- financial-tracker/budget-service/app.py | Bin 530 -> 0 bytes financial-tracker/budget-service/app/app.py | 10 +++ financial-tracker/docker-compose.yml | 58 ++++++++++++++++++ financial-tracker/frontend/Dockerfile | 17 +++++ .../notification-service/Dockerfile | 17 ++++- financial-tracker/notification-service/app.py | Bin 548 -> 0 bytes .../notification-service/app/app.py | 10 +++ financial-tracker/requirements.txt | Bin 0 -> 268 bytes .../transaction-service/Dockerfile | 17 ++++- financial-tracker/transaction-service/app.py | Bin 560 -> 0 bytes .../transaction-service/app/app.py | 10 +++ financial-tracker/user-service/Dockerfile | 17 ++++- financial-tracker/user-service/app.py | Bin 518 -> 0 bytes financial-tracker/user-service/app/app.py | 10 +++ 19 files changed, 213 insertions(+), 6 deletions(-) rename financial-tracker/analytics-service/{ => app}/app.py (100%) rename financial-tracker/api-gateway/{ => app}/app.py (100%) delete mode 100644 financial-tracker/budget-service/app.py create mode 100644 financial-tracker/budget-service/app/app.py create mode 100644 financial-tracker/frontend/Dockerfile delete mode 100644 financial-tracker/notification-service/app.py create mode 100644 financial-tracker/notification-service/app/app.py create mode 100644 financial-tracker/requirements.txt delete mode 100644 financial-tracker/transaction-service/app.py create mode 100644 financial-tracker/transaction-service/app/app.py delete mode 100644 financial-tracker/user-service/app.py create mode 100644 financial-tracker/user-service/app/app.py diff --git a/financial-tracker/analytics-service/Dockerfile b/financial-tracker/analytics-service/Dockerfile index 46b134b..4f670aa 100644 --- a/financial-tracker/analytics-service/Dockerfile +++ b/financial-tracker/analytics-service/Dockerfile @@ -1 +1,16 @@ -яю \ No newline at end of file +FROM python:3.12 + +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"] diff --git a/financial-tracker/analytics-service/app.py b/financial-tracker/analytics-service/app/app.py similarity index 100% rename from financial-tracker/analytics-service/app.py rename to financial-tracker/analytics-service/app/app.py diff --git a/financial-tracker/api-gateway/Dockerfile b/financial-tracker/api-gateway/Dockerfile index 46b134b..36bf6f5 100644 --- a/financial-tracker/api-gateway/Dockerfile +++ b/financial-tracker/api-gateway/Dockerfile @@ -1 +1,18 @@ -яю \ No newline at end of file +FROM python:3.12 + +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"] diff --git a/financial-tracker/api-gateway/app.py b/financial-tracker/api-gateway/app/app.py similarity index 100% rename from financial-tracker/api-gateway/app.py rename to financial-tracker/api-gateway/app/app.py diff --git a/financial-tracker/budget-service/Dockerfile b/financial-tracker/budget-service/Dockerfile index 46b134b..27fbb9d 100644 --- a/financial-tracker/budget-service/Dockerfile +++ b/financial-tracker/budget-service/Dockerfile @@ -1 +1,16 @@ -яю \ No newline at end of file +FROM python:3.12 + +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"] diff --git a/financial-tracker/budget-service/app.py b/financial-tracker/budget-service/app.py deleted file mode 100644 index 4a88b738dd6db98053b135b36645d060cc689f14..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 530 zcmZXR-AcqT6oltm@EyY5G=k`&cq0@<P+!11k)>{1t=iqSKZ1y_u72n2pIZrOlao0! zlgZC_sYY|v3M%!gOs!s6S5y|%8+GiiHz$Yep25sD15@flR%uk|O+DWh{J!>lW-u%` zO?McgCX5+MHF#SeY&tHeTF;St>ftIBmFQRxu;+SY-=UGXs`Ynz!b?sq)gAR4UFnwp z{fadQQ=-4@oD6s(sB>2jU~Je;I<y)b4sROusgb*G(aW53M1P=q`Nv=2w1DBAgr=+l z*eR?Pl>+P+s+QV`#*B4ZmS*^ujiqP#C4N%FRN>50O9sxj$@L(j=VGssf*h0Rb}rLf Nziz5C_i?&P>=(xfQ=R|- diff --git a/financial-tracker/budget-service/app/app.py b/financial-tracker/budget-service/app/app.py new file mode 100644 index 0000000..94dd4d9 --- /dev/null +++ b/financial-tracker/budget-service/app/app.py @@ -0,0 +1,10 @@ +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) diff --git a/financial-tracker/docker-compose.yml b/financial-tracker/docker-compose.yml index e69de29..4263425 100644 --- a/financial-tracker/docker-compose.yml +++ b/financial-tracker/docker-compose.yml @@ -0,0 +1,58 @@ +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 diff --git a/financial-tracker/frontend/Dockerfile b/financial-tracker/frontend/Dockerfile new file mode 100644 index 0000000..d03806e --- /dev/null +++ b/financial-tracker/frontend/Dockerfile @@ -0,0 +1,17 @@ +# 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"] diff --git a/financial-tracker/notification-service/Dockerfile b/financial-tracker/notification-service/Dockerfile index 46b134b..1d43ede 100644 --- a/financial-tracker/notification-service/Dockerfile +++ b/financial-tracker/notification-service/Dockerfile @@ -1 +1,16 @@ -яю \ No newline at end of file +FROM python:3.12 + +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"] diff --git a/financial-tracker/notification-service/app.py b/financial-tracker/notification-service/app.py deleted file mode 100644 index c7e58b182bc794d05bf7d63bd32ce986e39be171..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 548 zcmZ{hK}*9x5QX1a@INfMWCf|E(2Ef8qTYJ)CL*CtG-{HPGzAg=y86x3wp1z0lASki zX5PGff0gRgs#Z{`H|6T}%DVztf_GXG-Rv^wL@#h!HE>G3>r^LxbNEZL*#ST5k<-w( zR^jinUBwls)r?%hz@$P^sV?BRMApC39G1OpVo%l-Sg)0y!4_bd?!j+$tvkLC+Dur$ zDd9dj*EAgK8L7B*RRO-8&T9s~4bkDgQ6EZNLC@^m`zO=~(Akk00cJtBweM5F&DqPg zT7xJ0M1k!!(U`M!)b<bm{4<Bm<J2=XohnqC%jusj_U;ZaqWje|HG?_E_5Izry8Yjo Krmkc9>*NnnR#)!; diff --git a/financial-tracker/notification-service/app/app.py b/financial-tracker/notification-service/app/app.py new file mode 100644 index 0000000..408c317 --- /dev/null +++ b/financial-tracker/notification-service/app/app.py @@ -0,0 +1,10 @@ +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) diff --git a/financial-tracker/requirements.txt b/financial-tracker/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..78ca6876d16a7bf17ae773396e67e2a24ce35302 GIT binary patch literal 268 zcmXw!JrBY#3`B26;;*2RB2)%e1|%j1=2AXX3Joe`;l~5dZmY;j<afSve&3_+s@1B| zS)JCLxn^2XnWmbka$doW74(f41B=keT&V|TiVV7-maf>qOTC8ae3<T?YrP>Sc&n?Y zM<qJu5>Q(8%B^pBLm8ZoK7GcHen&#mQ+wVQyv)N?woUL&4xZ5H!=1<*751Cl6@SB% BCe8o= literal 0 HcmV?d00001 diff --git a/financial-tracker/transaction-service/Dockerfile b/financial-tracker/transaction-service/Dockerfile index 46b134b..ef5a3f2 100644 --- a/financial-tracker/transaction-service/Dockerfile +++ b/financial-tracker/transaction-service/Dockerfile @@ -1 +1,16 @@ -яю \ No newline at end of file +FROM python:3.12 + +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"] diff --git a/financial-tracker/transaction-service/app.py b/financial-tracker/transaction-service/app.py deleted file mode 100644 index b2bbb1625fe06b3cac8cb5d53385fccf20261034..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 560 zcmZ{h-Acni5QWdR;5#h6$qJ&S;EfRQMty<aiImVL8Z~LnPeH_2SHBtC6su*~-PxHl zXJ*cReHLo8RHdLoFUr*F8N0-@!r!Rlbu&axc|Czyss>Z&P3CEo>s38x3;tL~zB3qB zMAKgkQ8QLer3$>+Cqu>+UduW2o_e@)MI}1NYKYbFXPWaWy@QsR)i<V2kN6fKQr+Rd z)wQPF_Z$8Nm;&sBV`m2$Blt`2D1f$Q({)VOP=9~=sCSLLe(Sv%`-uF&IsLci04^u8 zW`;Rd7$#bK?g#a4risR^t(K;B_@kU@Yw9K*sbDJU(KJo=X4vW4gNUw`{Z$HbjNZHb Pqv-bUQ(br;lZ}esNzGaw diff --git a/financial-tracker/transaction-service/app/app.py b/financial-tracker/transaction-service/app/app.py new file mode 100644 index 0000000..8b37a7f --- /dev/null +++ b/financial-tracker/transaction-service/app/app.py @@ -0,0 +1,10 @@ +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) diff --git a/financial-tracker/user-service/Dockerfile b/financial-tracker/user-service/Dockerfile index 46b134b..7ad94b5 100644 --- a/financial-tracker/user-service/Dockerfile +++ b/financial-tracker/user-service/Dockerfile @@ -1 +1,16 @@ -яю \ No newline at end of file +FROM python:3.12 + +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"] diff --git a/financial-tracker/user-service/app.py b/financial-tracker/user-service/app.py deleted file mode 100644 index ac81c7554bb0799f4bbda4996f3fa6aa7e21fc63..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 518 zcmZXR-Acni5QWdR;5#h2$qJ%X@J0xDqrQM%iImVb8Z~X*Bn1&)UHxWETdgenH*@C9 z*|T4tm68@}6jbR&rCL36u8Ay(Cw1JeHkm_iPhb|BgQ@f;izLnTs-Cq4zpp)?B@9cl z#UF;KF=I}r2E3gQHWe2{t>(xz^>ED;mFpPpmUCjwy`$B3dPK*RSfM-O*SgdV`~AQ; z1yj-c!Lj3C91+C1cMari*b6!k31z!4jCxn*YFm1h&X-Xih~5sm!mzJ!Wdc_KH-WL% zid&`+I+|0b8Zp)mnS<e<ALf{OmV2gwsYaDKmG7wDy48b-?uY$A0dj<k+xg?#`bP_$ JxsH>;sc&k|QD^`F diff --git a/financial-tracker/user-service/app/app.py b/financial-tracker/user-service/app/app.py new file mode 100644 index 0000000..8cd3d9e --- /dev/null +++ b/financial-tracker/user-service/app/app.py @@ -0,0 +1,10 @@ +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) -- GitLab