Skip to content

Commit

Permalink
🍰 [v1.0.1] Integrated docker + github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
areebahmeddd committed Sep 27, 2024
1 parent 778f4e6 commit 86dde59
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 2 deletions.
14 changes: 14 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Python related
.venv/
__pycache__/

# Project-specific files
.env
firebase-adminsdk.json
.github/
tests/
.gitignore
README.md

# Docker-specific files
Dockerfile
19 changes: 19 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Build Python

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Setup Python
uses: actions/[email protected]
with:
python-version: 3.11

- name: Install dependencies
run: pip install -r requirements.txt
25 changes: 25 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Deploy to Docker Hub

on:
workflow_run:
workflows: ["Build Python"]
types:
- completed

jobs:
deploy:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest

steps:
- uses: actions/[email protected]
name: Check out code

- uses: mr-smithers-excellent/docker-build-push@v6
name: Build & push Docker image
with:
image: areebahmeddd/mivro-backend
tags: latest
registry: docker.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM python:3.11-slim

WORKDIR /mivro-backend

COPY requirements.txt .

RUN pip install --no-cache-dir -r requirements.txt

COPY . .

EXPOSE 5000
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
services:
app:
build: .
container_name: mivro_container
command: python server/app.py
ports:
- 5000:5000
volumes:
- .:/mivro-backend
restart: always
3 changes: 2 additions & 1 deletion server/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def signup() -> Response:
)
# Register the user in Firestore database (Workaround for Firebase Auth not supporting direct user data storage in Firestore)
register_user_profile(email, password)
return redirect(url_for('auth.verify_email', email=email)) # Redirect to the email verification route
return jsonify({'message': 'User registration successful.'}) # verify-email route not working :(
# return redirect(url_for('auth.verify_email', email=email)) # Redirect to the email verification route
except Exception as exc:
runtime_error('signup', str(exc), email=email)
return jsonify({'error': str(exc)}), 500
Expand Down
2 changes: 1 addition & 1 deletion server/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def database() -> Response:
return jsonify({'error': 'Email and product keyword are required.'}), 400

# Define the search keys and fetch the product data from Firestore using the keyword (fuzzy matching)
search_keys = ['_keywords', 'brands', 'categories', 'product_name']
search_keys = ['_keywords', 'categories', 'product_name']
product_data = database_search(email, product_keyword, search_keys)

if product_data:
Expand Down
Empty file added tests/test_search.py
Empty file.

0 comments on commit 86dde59

Please sign in to comment.