Skip to content

Commit

Permalink
Merge pull request #11 from renaism/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
renaism authored Dec 19, 2023
2 parents 24f088c + 21dceb2 commit a48e670
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 44 deletions.
37 changes: 1 addition & 36 deletions .github/workflows/cd-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,39 +33,4 @@ jobs:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
deploy:
name: Deploy Package
runs-on: ubuntu-latest
environment: production
needs: build
env:
GITHUB_USERNAME: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
API_KEY_SECRET: ${{ secrets.API_KEY_SECRET }}
DB_HOST: ${{ secrets.DB_HOST }}
DB_NAME: ${{ secrets.DB_NAME }}
DB_USERNAME: ${{ secrets.DB_USERNAME }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
steps:
- name: Deploy package to the remote server
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_VM1_HOST }}
username: ${{ secrets.SSH_VM1_USERNAME }}
key: ${{ secrets.SSH_VM1_KEY }}
port: ${{ secrets.SSH_VM1_PORT }}
envs: GITHUB_USERNAME, GITHUB_TOKEN, API_KEY_SECRET, DB_HOST, DB_NAME, DB_USERNAME, DB_PASSWORD
script: |
docker login ghcr.io -u $GITHUB_USERNAME -p $GITHUB_TOKEN
docker pull ghcr.io/renaism/aeon-api:main
docker image prune -f
docker stop aeon-api
docker rm -fv aeon-api
docker run --name aeon-api -d -p 8080:8080 \
-e API_KEY_SECRET=$API_KEY_SECRET \
-e DB_HOST=$DB_HOST \
-e DB_NAME=$DB_NAME \
-e DB_USERNAME=$DB_USERNAME \
-e DB_PASSWORD=$DB_PASSWORD \
ghcr.io/renaism/aeon-api:main
labels: ${{ steps.meta.outputs.labels }}
10 changes: 2 additions & 8 deletions app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

from app.config import Config
from app.database import init_db
from app.routes.v1.log import router as log_router
from app.routes.v1.monitored_voice_channel import router as monitored_voice_channel_router
Expand All @@ -13,16 +14,9 @@
)

# CORS
origins = [
"http://localhost",
"http://localhost:[0-9]+",
"http://172\.18\.0\.[0-9]+:[0-9]+",
"https://.*aeon.*"
]

app.add_middleware(
CORSMiddleware,
allow_origin_regex="|".join(origins),
allow_origins=Config.CORS_ORIGINS,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
Expand Down
1 change: 1 addition & 0 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

class Config:
API_KEY_SECRET = os.getenv("API_KEY_SECRET")
CORS_ORIGINS = os.getenv("CORS_ORIGINS", default="").split(",")


class DBConfig:
Expand Down

0 comments on commit a48e670

Please sign in to comment.