Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
Init ai-api
Browse files Browse the repository at this point in the history
  • Loading branch information
ashpreetbedi committed Jan 15, 2024
0 parents commit 134b819
Show file tree
Hide file tree
Showing 66 changed files with 2,458 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.DS_Store

docs
.git
config.json
Pipfile
Pipfile.lock

# Cache
.mypy_cache
.ruff_cache
.pytest_cache
*__pycache__*
*.egg-info
*.pyc

# Machine specific
.idea
.vscode

# Ignore .env files
.env
.envrc

# ignore virtualenvs
.venv
venv*
aienv*
apienv*
appenv*
llmenv*

.ipynb_checkpoints
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_size = 2
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.py]
indent_size = 4
33 changes: 33 additions & 0 deletions .github/workflows/docker-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build Docker Images

on:
release:
types: [published]

permissions:
contents: read

jobs:
build-api-image:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker Login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ secrets.DOCKERHUB_REPO }}/ai-api:dev, ${{ secrets.DOCKERHUB_REPO }}/ai-api:prd
44 changes: 44 additions & 0 deletions .github/workflows/ecr-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build ECR Images

on: workflow_dispatch

permissions:
# For AWS OIDC Token access as per https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services#updating-your-github-actions-workflow
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout

env:
ECR_REPO: YOUR ECR REPO
# Create role using https://aws.amazon.com/blogs/security/use-iam-roles-to-connect-github-actions-to-actions-in-aws/
AWS_ROLE: YOUR_ROLE_ARN
AWS_REGION: us-east-1

jobs:
build-api-image:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# https://github.com/marketplace/actions/configure-aws-credentials-action-for-github-actions
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.AWS_ROLE }}
aws-region: ${{ env.AWS_REGION }}
# https://github.com/marketplace/actions/amazon-ecr-login-action-for-github-actions
- name: ECR Login
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build, tag, and push docker image to Amazon ECR
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.ECR_REPO }}/ai-api:dev, ${{ env.ECR_REPO }}/ai-api:prd
43 changes: 43 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Validate

on:
pull_request:
types:
- opened
- edited
- reopened
branches:
- "main"

jobs:
validate:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install dependencies
run: |
python -m pip install -U \
pip setuptools wheel \
mypy pytest ruff
pip install --no-deps -r requirements.txt
- name: Format with ruff
run: |
ruff format .
- name: Lint with ruff
run: |
ruff check .
- name: Type-check with mypy
run: |
mypy .
- name: Test with pytest
run: |
pytest .
42 changes: 42 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

.DS_Store

# Python cache
.mypy_cache
*__pycache__*
*.egg-info
*.pyc
*.pytest_cache
*.ruff_cache
*.cache*
*.config*

# Machine specific
.idea
.vscode

# Ignore .env files
.env
.envrc

# ignore storage dir
storage

# ignore .local dir
.local

# ignore dist dir
dist

# ignore virtualenvs
.venv
venv*
aienv*
apienv*
appenv*
llmenv*

# ignore jupyter checkpoints
.ipynb_checkpoints
.Trash*
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM phidata/python:3.11.5

ARG USER=app
ARG APP_DIR=${USER_LOCAL_DIR}/${USER}
ENV APP_DIR=${APP_DIR}
# Add APP_DIR to PYTHONPATH
ENV PYTHONPATH="${APP_DIR}:${PYTHONPATH}"

# Create user and home directory
RUN groupadd -g 61000 ${USER} \
&& useradd -g 61000 -u 61000 -ms /bin/bash -d ${APP_DIR} ${USER}

WORKDIR ${APP_DIR}

# Update pip
RUN pip install --upgrade pip
# Copy pinned requirements
COPY requirements.txt .
# Install pinned requirements
RUN pip install -r requirements.txt

# Copy project files
COPY . .

COPY scripts /scripts
ENTRYPOINT ["/scripts/entrypoint.sh"]
CMD ["chill"]
Loading

0 comments on commit 134b819

Please sign in to comment.