Skip to content

Commit

Permalink
Removed unnecessary packages from the requirements for RabbitMQ and a…
Browse files Browse the repository at this point in the history
…dded logging settings to the User-service and Token-service. Also removed RabbitMQ consumers and utility files from all services. Updated views files and removed all functions related to RabbitMQ. Changed all communication between microservices to direct communication. Added `gen-tokens`, `invalidate-tokens`, and `validate-token` endpoints to token_service urls.py
  • Loading branch information
abbastoof committed Aug 13, 2024
1 parent a379514 commit c22c9ff
Show file tree
Hide file tree
Showing 26 changed files with 233 additions and 592 deletions.
19 changes: 6 additions & 13 deletions Backend/token_service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ENV LANG=C.UTF-8
# Update and install dependencies
# trunk-ignore(hadolint/DL3018)
RUN apk add --no-cache postgresql16-client \
bash supervisor curl openssl \
bash curl openssl \
build-base libffi-dev python3-dev
# Set work directory
RUN mkdir /app && chown -R postgres:postgres /app
Expand All @@ -15,28 +15,21 @@ WORKDIR /app/

# Install Python virtual environment
RUN python3 -m venv venv && chown -R postgres:postgres venv

RUN touch /var/log/django_debug.log && chown -R postgres:postgres /var/log/django_debug.log
RUN touch /var/log/django_error.log && chown -R postgres:postgres /var/log/django_error.log
# Copy application code and adjust permissions
COPY --chown=postgres:postgres ./Backend/token_service/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY --chown=postgres:postgres ./Backend/token_service/requirements.txt /app/
COPY --chown=postgres:postgres ./Backend/token_service/token_service /app/token_service
COPY --chown=postgres:postgres ./Backend/token_service/tools.sh /app
COPY --chown=postgres:postgres ./Backend/token_service/run_consumer.sh /app
COPY --chown=postgres:postgres ./Backend/token_service/run_consumer2.sh /app
COPY --chown=postgres:postgres ./Backend/token_service/run_consumer3.sh /app

# Ensure supervisord and scripts are executable and owned by postgres
RUN chown -R postgres:postgres /etc/supervisor && \
chown -R postgres:postgres /usr/bin/supervisord && \
chown -R postgres:postgres /etc/supervisor/conf.d/supervisord.conf && \
chown -R postgres:postgres /app && \
RUN chown -R postgres:postgres /app && \
chown -R postgres:postgres /var/log && \
chown -R postgres:postgres /app/venv && \
chown -R postgres:postgres /app/token_service && \
chmod +x /usr/bin/supervisord
chown -R postgres:postgres /app/token_service

USER postgres

HEALTHCHECK --interval=30s --timeout=2s --start-period=5s --retries=3 CMD curl --fail --silent --write-out http://127.0.0.1:8000/ > /dev/null && echo "success" || echo "failure"

ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
ENTRYPOINT ["sh", "/app/tools.sh"]
4 changes: 1 addition & 3 deletions Backend/token_service/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
aio-pika==9.4.2
aiormq==6.8.0
anyio==4.4.0
asgiref==3.8.1
attrs==24.2.0
Expand Down Expand Up @@ -65,4 +63,4 @@ uvloop==0.19.0
watchfiles==0.23.0
websockets==12.0
yarl==1.9.4
zope.interface==7.0.1
zope.interface==7.0.1
16 changes: 0 additions & 16 deletions Backend/token_service/run_consumer.sh

This file was deleted.

16 changes: 0 additions & 16 deletions Backend/token_service/run_consumer2.sh

This file was deleted.

16 changes: 0 additions & 16 deletions Backend/token_service/run_consumer3.sh

This file was deleted.

30 changes: 0 additions & 30 deletions Backend/token_service/supervisord.conf

This file was deleted.

19 changes: 0 additions & 19 deletions Backend/token_service/token_service/consumer.py

This file was deleted.

16 changes: 0 additions & 16 deletions Backend/token_service/token_service/consumer2.py

This file was deleted.

16 changes: 0 additions & 16 deletions Backend/token_service/token_service/consumer3.py

This file was deleted.

74 changes: 0 additions & 74 deletions Backend/token_service/token_service/token_app/rabbitmq_utils.py

This file was deleted.

7 changes: 5 additions & 2 deletions Backend/token_service/token_service/token_app/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# from django.contrib import admin
from django.urls import path
from token_app.views import CustomTokenRefreshView
from token_app.views import CustomTokenRefreshView, CustomTokenObtainPairView, InvalidateToken, ValidateToken

urlpatterns = [
path("token/refresh/", CustomTokenRefreshView.as_view(), name="token_refresh"),
path("token/refresh/", CustomTokenRefreshView.as_view(), name="token_refresh",),
path("token/gen-tokens/", CustomTokenObtainPairView.as_view({"post": "create_token_for_user",}), name="generate_tokens",),
path("token/invalidate-tokens/", InvalidateToken.as_view({"post": "invalidate_token_for_user",}), name="invalidate_tokens",),
path("token/validate-token/", ValidateToken.as_view({"post": "validate_token_for_user",}), name="validate_token",),
]
Loading

0 comments on commit c22c9ff

Please sign in to comment.