Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
__pycache__
*.pyc
*.pyo
*.pyd
.Python
.env
.git
.gitignore
Dockerfile
docker-compose.yml
*.md
assets
tests
.pytest_cache
66 changes: 66 additions & 0 deletions .github/workflows/prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: CI/CD PROD

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
build:
timeout-minutes: 3
name: build
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
actions: read
checks: write
steps:
- name: Checkout code
uses: actions/checkout@main

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using a version tag (e.g., @v4) instead of @main for actions/checkout to prevent breaking changes from being automatically pulled.


- name: Config QEMU
uses: docker/setup-qemu-action@v3.2.0
with:
platforms: linux/amd64

- name: Config Docker Buildx
uses: docker/setup-buildx-action@v3.7.1
with:
platforms: linux/amd64

- name: Login to Docker Hub
uses: docker/login-action@v3.3.0
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: Build and Publish Image to Docker Hub
run: |
docker build -t r4deu51/api-b3:${{ github.ref_name }} .
docker tag r4deu51/api-b3:${{ github.ref_name }} docker.io/r4deu51/api-b3:${{ github.ref_name }}
docker push docker.io/r4deu51/api-b3:${{ github.ref_name }}

# ============================================
# DEPLOY
# ============================================
deploy:
timeout-minutes: 1
needs: build
name: deploy
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: read
actions: read
checks: write
steps:
- name: Checkout code
uses: actions/checkout@main

- name: Deploy Image
uses: ramonpaolo/action-zenifra@main

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using floating branch reference '@main' for custom action is a security risk. If the main branch is compromised or changed, deployments could execute arbitrary code. Consider pinning to a specific commit hash for supply chain security.

with:
PROJECT_ID: ${{ secrets.ZENIFRA_PROJECT_ID_PROD }}
API_KEY: ${{ secrets.ZENIFRA_API_KEY_PROD }}
IMAGE: docker.io/r4deu51/api-b3:${{ github.ref_name }}
67 changes: 67 additions & 0 deletions .github/workflows/stg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: CI/CD STG

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
build:
timeout-minutes: 3
name: build
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
actions: read
checks: write
steps:
- name: Checkout code
uses: actions/checkout@main

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using a version tag (e.g., @v4) instead of @main for actions/checkout to prevent breaking changes from being automatically pulled.


- name: Config QEMU
uses: docker/setup-qemu-action@v3.2.0
with:
platforms: linux/amd64

- name: Config Docker Buildx
uses: docker/setup-buildx-action@v3.7.1
with:
platforms: linux/amd64

- name: Login to Docker Hub
uses: docker/login-action@v3.3.0
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: Build and Publish Image to Docker Hub
run: |
docker build -t r4deu51/api-b3:${{ github.sha }} .
docker tag r4deu51/api-b3:${{ github.sha }} docker.io/r4deu51/api-b3:${{ github.sha }}
docker push docker.io/r4deu51/api-b3:${{ github.sha }}

# ============================================
# DEPLOY
# ============================================
deploy:
timeout-minutes: 1
needs: build
name: deploy
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: read
actions: read
checks: write
steps:
- name: Checkout code
uses: actions/checkout@main

- name: Deploy Image
uses: ramonpaolo/action-zenifra@main

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using floating branch reference '@main' for custom action is a security risk. If the main branch is compromised or changed, deployments could execute arbitrary code. Consider pinning to a specific commit hash for supply chain security.

with:
PROJECT_ID: ${{ secrets.ZENIFRA_PROJECT_ID_STG }}
API_KEY: ${{ secrets.ZENIFRA_API_KEY_STG }}
IMAGE: docker.io/r4deu51/api-b3:${{ github.sha }}
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM python:3.13-slim

WORKDIR /app

RUN apt-get update && rm -rf /var/lib/apt/lists/*

COPY requirements.txt .

RUN pip install --no-cache-dir -r requirements.txt

COPY ./ ./

EXPOSE 8000

RUN addgroup -S appgroup && adduser -S appuser -G appgroup

USER appuser

CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
1 change: 0 additions & 1 deletion Procfile

This file was deleted.

Loading