Skip to content

Ozpol env setup #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# -------------------
# FOR CYBERGATOR TEAM:
# Create a '.env' file in /cybergator main directory,
# COPY-PASTE THIS INTO YOUR '.env' FILE EXACTLY AS-IS (Lines 8 to 25 are for CyberGator Developers),
# DO NOT MODIFY ANYTHING, VALUES ARE LOADED FROM GITHUB SECRETS
# DO NOT COMMIT '.env' TO GITHUB
# -------------------
SUPABASE_URL={{ secrets.SUPABASE_URL }}
SUPABASE_KEY={{ secrets.SUPABASE_KEY }}
SUPABASE_SERVICE_ROLE={{ secrets.SUPABASE_SERVICE_ROLE }}
DATABASE_URL={{ secrets.DATABASE_URL }}
DB_USER={{ secrets.DB_USER }}
DB_PASSWORD={{ secrets.DB_PASSWORD }}
DB_HOST={{ secrets.DB_HOST }}
DB_PORT={{ secrets.DB_PORT }}
DB_NAME={{ secrets.DB_NAME }}
NEO4J_URI={{ secrets.NEO4J_URI }}
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD={{ secrets.NEO4J_PASSWORD }}
APP_ENV=development
APP_DEBUG=True
PORT=8000
GITHUB_ACTIONS=true
DEPLOYMENT_KEY={{ secrets.DEPLOYMENT_KEY }}
SECRET_KEY={{ secrets.SECRET_KEY }}
JWT_EXPIRATION=3600
ALLOWED_ORIGINS=http://localhost:3000,http://production-url-when-deployed.com
LOG_LEVEL=info
# -------------------

# -------------------
# FOR OTHERS (Not CyberGator Developers): USE YOUR OWN CREDENTIALS AND VALUES
# -------------------
# Remove comments and replace placeholders with your own values
# -------------------
# Supabase Credentials (Secure This)
# -------------------
SUPABASE_URL=https://your-supabase-project.supabase.co
SUPABASE_KEY=your-supabase-anon-key
SUPABASE_SERVICE_ROLE=your-supabase-service-role-key

# -------------------
# Database Connection
# -------------------
DATABASE_URL=postgresql://your-db-user:your-db-password@your-db-host:your-db-port/your-db-name
DB_USER=your-db-user
DB_PASSWORD=your-db-password
DB_HOST=your-db-host
DB_PORT=5432
DB_NAME=your-db-name

NEO4J_URI={{ secrets.NEO4J_URI }}
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD={{ secrets.NEO4J_PASSWORD }}
# -------------------
# Docker App Settings
# -------------------
APP_ENV=development # Change to 'production' when deploying
APP_DEBUG=True
PORT=8000

# -------------------
# GitHub Actions Secrets (For CI/CD)
# -------------------
GITHUB_ACTIONS=true
DEPLOYMENT_KEY=your-github-deployment-key

# -------------------
# Security Settings
# -------------------
SECRET_KEY=your-random-secret-key
JWT_EXPIRATION=3600 # Set JWT expiration time in seconds
ALLOWED_ORIGINS=http://localhost:3000,http://your-production-url.com # CORS policy

# -------------------
# Other Settings
# -------------------
LOG_LEVEL=info # Change to debug for more logs
52 changes: 52 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Deploy to Docker

on:
push:
branches:
- main
- ozpol*
- jess*
- andrew*
- shayan*
pull_request:
branches:
- main
workflow_dispatch:

jobs:
deploy-to-docker:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set environment variables
run: |
echo "DATABASE_URL=${{ secrets.DATABASE_URL }}" >> $GITHUB_ENV
echo "DB_USER=${{ secrets.DB_USER }}" >> $GITHUB_ENV
echo "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" >> $GITHUB_ENV
echo "DB_HOST=${{ secrets.DB_HOST }}" >> $GITHUB_ENV
echo "DB_PORT=${{ secrets.DB_PORT }}" >> $GITHUB_ENV
echo "DB_NAME=${{ secrets.DB_NAME }}" >> $GITHUB_ENV
echo "SUPABASE_URL=${{ secrets.SUPABASE_URL }}" >> $GITHUB_ENV
echo "SUPABASE_KEY=${{ secrets.SUPABASE_KEY }}" >> $GITHUB_ENV
echo "SUPABASE_SERVICE_ROLE=${{ secrets.SUPABASE_SERVICE_ROLE }}" >> $GITHUB_ENV
echo "NEO4J_USERNAME=${{ secrets.NEO4J_USERNAME }}" >> $GITHUB_ENV
echo "NEO4J_PASSWORD=${{ secrets.NEO4J_PASSWORD }}" >> $GITHUB_ENV

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/cybergator:latest
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Ignore environment files
.env
.env.docker
neo4j_auth.txt

# Ignore Python-related cache & virtual environments
**/__pycache__/
*.pyc
*.pyo
*.pyd
venv/
.envrc

# Ignore Docker build files
*.log
docker-compose.override.yml

# Ignore IDE/project-specific files
.vscode/
.idea/
*.swp
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Use the latest Python image
FROM python:3.12

# Set the working directory inside the container
WORKDIR /app

# Install Poetry
RUN pip install poetry

# Set Poetry to configure virtualenv inside the project
RUN poetry config virtualenvs.create false

# Copy the project metadata for Poetry
COPY pyproject.toml poetry.lock ./

# Install dependencies using Poetry (includes Neo4J driver)
RUN poetry install --no-root --no-interaction

# Copy the rest of the application
COPY . .

# Expose only the app port (Neo4J is handled by `docker-compose.yml`)
EXPOSE 8000

# Command to start the application
CMD ["poetry", "run", "python", "app.py"]
Loading