Skip to content

Commit

Permalink
Init agent-app
Browse files Browse the repository at this point in the history
  • Loading branch information
ashpreetbedi committed Oct 14, 2024
0 parents commit f4bf795
Show file tree
Hide file tree
Showing 60 changed files with 2,500 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.DS_Store

docs
.git

# 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*

.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
37 changes: 37 additions & 0 deletions .github/workflows/docker-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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@v4

- 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 }}/agent-app:dev, ${{ secrets.DOCKERHUB_REPO }}/agent-app: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 }}/agent-app:dev, ${{ env.ECR_REPO }}/agent-app:prd
50 changes: 50 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Validate

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

env:
UV_SYSTEM_PYTHON: 1

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

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "requirements**.txt"

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install the project
run: uv pip sync requirements.txt

- name: Format with ruff
run: uv run ruff format .

- name: Lint with ruff
run: uv run ruff check .

- name: Type-check with mypy
run: uv run mypy .

# - name: Run tests
# run: uv run pytest tests
39 changes: 39 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 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*

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

ARG USER=app
ARG APP_DIR=/app
ENV APP_DIR=${APP_DIR}

# 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}

# Copy requirements.txt
COPY requirements.txt ./

# Install requirements
RUN --mount=type=cache,target=/root/.cache/uv \
uv pip sync requirements.txt --system

# Copy project files
COPY . .

# Set permissions for the /app directory
RUN chown -R ${USER}:${USER} ${APP_DIR}

# Switch to non-root user
USER ${USER}

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

0 comments on commit f4bf795

Please sign in to comment.