Skip to content

Commit

Permalink
Merge branch 'main' into suggestion-feature
Browse files Browse the repository at this point in the history
  • Loading branch information
tsu-ki authored Jan 2, 2025
2 parents d00cd74 + b36c568 commit 532ced8
Show file tree
Hide file tree
Showing 33 changed files with 5,821 additions and 1,295 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,34 @@ jobs:
- run: poetry run python manage.py collectstatic --noinput
- name: Run tests
run: poetry run xvfb-run --auto-servernum python manage.py test -v 3 --failfast

docker-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Docker
run: |
docker --version
# Install docker-compose
curl -sSL https://github.com/docker/compose/releases/download/v2.17.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version
- name: Build Docker image
run: |
docker build -t my-app .
- name: Run Docker container
run: |
docker run -d --name my-container my-app
- run: docker exec my-container pip install poetry
- run: docker exec my-container poetry lock --no-update
- run: docker exec my-container poetry install --no-dev --no-interaction

- name: Clean up
run: |
docker stop my-container
docker rm my-container
1 change: 1 addition & 0 deletions Aptfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
git
23 changes: 22 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,29 @@ RUN apt-get update && \
dos2unix && \
rm -rf /var/lib/apt/lists/*

# # Install Chrome WebDriver
# RUN CHROMEDRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE` && \
# mkdir -p /opt/chromedriver-$CHROMEDRIVER_VERSION && \
# curl -sS -o /tmp/chromedriver_linux64.zip http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip && \
# unzip -qq /tmp/chromedriver_linux64.zip -d /opt/chromedriver-$CHROMEDRIVER_VERSION && \
# rm /tmp/chromedriver_linux64.zip && \
# chmod +x /opt/chromedriver-$CHROMEDRIVER_VERSION/chromedriver && \
# ln -fs /opt/chromedriver-$CHROMEDRIVER_VERSION/chromedriver /usr/local/bin/chromedriver

# Install Google Chrome
RUN curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list && \
apt-get -yqq update && \
apt-get -yqq install google-chrome-stable && \
rm -rf /var/lib/apt/lists/*

RUN ln -s /usr/bin/google-chrome-stable /usr/local/bin/google-chrome

# Install Poetry and dependencies
RUN pip install poetry
RUN poetry config virtualenvs.create false
COPY pyproject.toml poetry.lock* ./
RUN poetry lock --no-update
RUN poetry install

# Install additional Python packages
Expand All @@ -40,7 +59,9 @@ RUN apt-get update && \
COPY . /blt

# Convert line endings and set permissions
RUN dos2unix .env Dockerfile docker-compose.yml entrypoint.sh ./blt/settings.py
RUN dos2unix Dockerfile docker-compose.yml entrypoint.sh ./blt/settings.py
# Check if .env exists and run dos2unix on it, otherwise skip
RUN if [ -f /blt/.env ]; then dos2unix /blt/.env; fi
RUN chmod +x /blt/entrypoint.sh

ENTRYPOINT ["/blt/entrypoint.sh"]
Expand Down
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
release: python manage.py migrate --noinput
web: gunicorn blt.wsgi --log-file - --workers 2 --worker-class gthread --threads 2 --timeout 120
web: newrelic-admin run-program bin/start-pgbouncer uvicorn blt.asgi:application --host 0.0.0.0 --port ${PORT}
31 changes: 31 additions & 0 deletions blt/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# asgi.py

import os
import tracemalloc

import django

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "blt.settings")
django.setup()

from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter, URLRouter
from django.core.asgi import get_asgi_application
from django.urls import path

tracemalloc.start()

from website import consumers # You will define a consumer for handling WebSockets

application = ProtocolTypeRouter(
{
"http": get_asgi_application(),
"websocket": AuthMiddlewareStack(
URLRouter(
[
path("ws/similarity/", consumers.SimilarityConsumer.as_asgi()), # WebSocket URL
]
)
),
}
)
Loading

0 comments on commit 532ced8

Please sign in to comment.