Skip to content

Commit 308b983

Browse files
committed
FreightSense initial commit
0 parents  commit 308b983

45 files changed

Lines changed: 6207 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# --- Python ---
2+
__pycache__/
3+
*.py[cod]
4+
*.pyo
5+
*.pyd
6+
*.egg-info/
7+
.eggs/
8+
dist/
9+
build/
10+
11+
# --- Virtual env ---
12+
.venv/
13+
venv/
14+
env/
15+
16+
# --- Secrets / local config ---
17+
.env
18+
*.env
19+
20+
# --- Dev / test ---
21+
scripts/
22+
*.db
23+
*.sqlite
24+
*.sqlite3
25+
26+
# --- Large data files (benchmarks.json is KEPT — needed at startup) ---
27+
data/DataCoSupplyChainDataset.csv
28+
data/DescriptionDataCoSupplyChain.csv
29+
data/tokenized_access_logs.csv
30+
31+
# --- Version control ---
32+
.git/
33+
.gitignore
34+
.gitattributes
35+
36+
# --- Editor ---
37+
.vscode/
38+
.idea/
39+
*.swp
40+
*.swo
41+
42+
# --- OS ---
43+
.DS_Store
44+
Thumbs.db
45+
46+
# --- CI / docs ---
47+
*.md

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
GROQ_API_KEY=gsk_your_key_here
2+
GROQ_MODEL=llama-3.3-70b-versatile
3+
DATABASE_URL=shipment_audit.db

.github/workflows/deploy.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Deploy to Cloud Run
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
workflow_dispatch: # allow manual trigger from GitHub UI
7+
8+
env:
9+
PROJECT_ID: ${{ vars.GCP_PROJECT_ID }}
10+
REGION: us-central1
11+
SERVICE: shipment-ai
12+
REPO: shipment-ai
13+
IMAGE: app
14+
15+
jobs:
16+
deploy:
17+
name: Build & Deploy
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
id-token: write # required for Workload Identity Federation
22+
23+
steps:
24+
# ── 1. Checkout ──────────────────────────────────────────────────────
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
# ── 2. Authenticate to GCP via Workload Identity Federation ──────────
29+
# No long-lived service account key needed — uses OIDC token.
30+
# Set GCP_WORKLOAD_IDENTITY_PROVIDER and GCP_SERVICE_ACCOUNT in
31+
# GitHub repo → Settings → Secrets and variables → Actions → Variables.
32+
- name: Authenticate to Google Cloud
33+
uses: google-github-actions/auth@v2
34+
with:
35+
workload_identity_provider: ${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER }}
36+
service_account: ${{ vars.GCP_SERVICE_ACCOUNT }}
37+
38+
# ── 3. Set up Cloud SDK ───────────────────────────────────────────────
39+
- name: Set up Cloud SDK
40+
uses: google-github-actions/setup-gcloud@v2
41+
42+
# ── 4. Configure Docker auth for Artifact Registry ───────────────────
43+
- name: Configure Docker for Artifact Registry
44+
run: gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet
45+
46+
# ── 5. Build and push container image ────────────────────────────────
47+
- name: Build and push image
48+
run: |
49+
IMAGE_URI="${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPO }}/${{ env.IMAGE }}"
50+
docker build \
51+
-t "${IMAGE_URI}:${{ github.sha }}" \
52+
-t "${IMAGE_URI}:latest" \
53+
.
54+
docker push --all-tags "${IMAGE_URI}"
55+
56+
# ── 6. Deploy to Cloud Run ────────────────────────────────────────────
57+
# Stamps the commit SHA into service.yaml before deploying so each
58+
# rollout is pinned to an immutable image tag.
59+
- name: Deploy to Cloud Run
60+
run: |
61+
IMAGE_URI="${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPO }}/${{ env.IMAGE }}:${{ github.sha }}"
62+
sed "s|:latest|:${{ github.sha }}|g" service.yaml \
63+
| sed "s|YOUR_PROJECT_ID|${{ env.PROJECT_ID }}|g" \
64+
> /tmp/service_deploy.yaml
65+
gcloud run services replace /tmp/service_deploy.yaml \
66+
--region ${{ env.REGION }} \
67+
--project ${{ env.PROJECT_ID }}
68+
69+
# ── 7. Print live URL ─────────────────────────────────────────────────
70+
- name: Get service URL
71+
run: |
72+
URL=$(gcloud run services describe ${{ env.SERVICE }} \
73+
--region ${{ env.REGION }} \
74+
--project ${{ env.PROJECT_ID }} \
75+
--format='value(status.url)')
76+
echo "Deployed to: $URL"
77+
echo "url=$URL" >> $GITHUB_OUTPUT

.gitignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Environment variables (never commit secrets)
2+
.env
3+
.env.*
4+
!.env.example
5+
6+
# Large data files (too large for GitHub without LFS)
7+
data/DataCoSupplyChainDataset.csv
8+
data/tokenized_access_logs.csv
9+
10+
# Python
11+
__pycache__/
12+
*.py[cod]
13+
*.egg-info/
14+
.venv/
15+
venv/
16+
dist/
17+
build/
18+
19+
# IDE
20+
.vscode/
21+
.idea/
22+
23+
# OS
24+
.DS_Store
25+
Thumbs.db

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.14

Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# ── Build stage ──────────────────────────────────────────────────────────────
2+
FROM python:3.12-slim AS builder
3+
4+
WORKDIR /build
5+
6+
# Install deps into an isolated prefix so we can copy them clean
7+
COPY requirements.txt .
8+
RUN pip install --upgrade pip --quiet \
9+
&& pip install --prefix=/install --quiet -r requirements.txt
10+
11+
# ── Runtime stage ─────────────────────────────────────────────────────────────
12+
FROM python:3.12-slim
13+
14+
WORKDIR /app
15+
16+
# Copy installed packages from builder
17+
COPY --from=builder /install /usr/local
18+
19+
# Copy application source (respects .dockerignore)
20+
COPY . .
21+
22+
# Cloud Run injects PORT at runtime; default to 8080 for local docker run
23+
ENV PORT=8080
24+
25+
# Non-root user for security
26+
RUN adduser --disabled-password --gecos "" appuser \
27+
&& chown -R appuser:appuser /app
28+
USER appuser
29+
30+
EXPOSE 8080
31+
32+
CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port ${PORT}"]

0 commit comments

Comments
 (0)