Skip to content

Commit

Permalink
Merge pull request #1 from c3sr/python_api
Browse files Browse the repository at this point in the history
Add Python API
  • Loading branch information
amirnd51 authored Jul 24, 2024
2 parents 5e91573 + 7509b1b commit db26d36
Show file tree
Hide file tree
Showing 12 changed files with 975 additions and 18 deletions.
17 changes: 0 additions & 17 deletions .env

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/build-and-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: actions/checkout@v3

- name: Build Image
run: ./scripts/build-container.sh api ${IMAGE_TAGS} ${IMAGE_REGISTRY}
run: ./scripts/build-container.sh python_api ${IMAGE_TAGS} ${IMAGE_REGISTRY}

- name: Push to GHCR
id: push-to-ghcr
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
.carml_config.yml
*.out
.env.companion
*pycache/
.env*
__pycache__/
*tmp*
4 changes: 4 additions & 0 deletions api/db/models/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ type Framework struct {
Version string `json:"version"`
Architectures []Architecture `json:"architectures"`
}
type User struct {
gorm.Model
ID string `gorm:"primaryKey" json:"id"`
}
21 changes: 21 additions & 0 deletions docker/Dockerfile.python_api
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Use the official Python image from the Docker Hub
FROM python:3.11-slim

# Set the working directory in the container
WORKDIR /app

# Copy the requirements.txt file into the container
COPY requirements.txt .

# Install the dependencies specified in the requirements.txt file
RUN pip install --no-cache-dir -r requirements.txt

# Copy the rest of the application code into the container
COPY . .

# Expose the port that the FastAPI app runs on
EXPOSE 8000

# Command to run the FastAPI application with --reload for development
CMD ["uvicorn", "api:app", "--host", "0.0.0.0", "--port", "8000"]

20 changes: 20 additions & 0 deletions python_api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use the official Python image from the Docker Hub
FROM python:3.11-slim

# Set the working directory in the container
WORKDIR /app

# Copy the requirements.txt file into the container
COPY python_api/requirements.txt .

# Install the dependencies specified in the requirements.txt file
RUN pip install --no-cache-dir -r requirements.txt

# Copy the rest of the application code into the container
COPY python_api/ .

# Expose the port that the FastAPI app runs on
EXPOSE 8000

# Command to run the FastAPI application with --reload for development
CMD ["uvicorn", "api:app", "--host", "0.0.0.0", "--port", "8000"]
6 changes: 6 additions & 0 deletions python_api/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Installation
```pip install -r req.txt```

# Running

```fastapi run api.py --reload```
Loading

0 comments on commit db26d36

Please sign in to comment.