Skip to content

Commit c2fed7f

Browse files
committed
First commit
1 parent 148b984 commit c2fed7f

File tree

13 files changed

+1523
-0
lines changed

13 files changed

+1523
-0
lines changed

.github/workflows/CI-CD.yaml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
on:
2+
push:
3+
branches: [ "main", "dev" ]
4+
# Publish semver tags as releases.
5+
tags: [ 'v*.*.*' ]
6+
pull_request:
7+
branches: ["dev"]
8+
9+
env:
10+
REGISTRY: ghcr.io
11+
IMAGE_NAME: ${{ github.repository }}
12+
13+
jobs:
14+
tests:
15+
name: Run tests
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Setup PDM
20+
uses: pdm-project/setup-pdm@v4
21+
- name: Install dependencies
22+
run: pdm install -d
23+
- name: Run linting check
24+
run: pdm run lint --check
25+
- name: Run tests
26+
run: pdm run tests
27+
- name: Export requirements
28+
run: pdm run export
29+
- name: Check for changes
30+
run: git diff --exit-code HEAD requirements.txt
31+
docker:
32+
needs: tests
33+
runs-on: ubuntu-latest
34+
permissions:
35+
contents: read
36+
packages: write
37+
id-token: write
38+
steps:
39+
- name: Checkout repository
40+
uses: actions/checkout@v4
41+
42+
- name: Set up Docker Buildx
43+
uses: docker/setup-buildx-action@v3.3.0
44+
45+
- name: Log into registry ${{ env.REGISTRY }}
46+
uses: docker/login-action@v3.2.0
47+
with:
48+
registry: ${{ env.REGISTRY }}
49+
username: ${{ github.actor }}
50+
password: ${{ secrets.GITHUB_TOKEN }}
51+
52+
- name: Extract Docker metadata for
53+
id: meta
54+
uses: docker/metadata-action@v5.5.1
55+
with:
56+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
57+
tags: |
58+
type=ref,event=branch
59+
type=ref,event=pr
60+
type=ref,event=tag
61+
type=sha
62+
63+
- name: Build and push Docker image
64+
uses: docker/build-push-action@v5.3.0
65+
with:
66+
context: .
67+
push: true
68+
tags: ${{ steps.meta.outputs.tags }}
69+
labels: ${{ steps.meta.outputs.labels }}
70+
cache-from: type=gha
71+
cache-to: type=gha,mode=max
72+
deploy:
73+
needs: docker
74+
runs-on: ubuntu-latest
75+
# if: github.event_name == 'push' && github.ref == 'refs/heads/main'
76+
if: false # Disable deployment for now
77+
steps:
78+
- name: Update portainer
79+
run: |
80+
curl -X POST ${{ secrets.UPDATE_FRONT_WEBHOOK }}

.idea/.gitignore

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/discord.xml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/profiles_settings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/message_classifier.iml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
FROM python:3.11-slim-bookworm
2+
3+
# Keeps Python from generating .pyc files in the container
4+
ENV PYTHONDONTWRITEBYTECODE=1
5+
6+
# Turns off buffering for easier container logging
7+
ENV PYTHONUNBUFFERED=1
8+
9+
# we move to the app folder and run the pip install command
10+
WORKDIR /app
11+
12+
# Install system dependencies
13+
RUN apt-get update && \
14+
apt-get install -y \
15+
curl \
16+
build-essential
17+
18+
ENV PYTHONUNBUFFERED 1
19+
ENV PYTHONDONTWRITEBYTECODE 1
20+
21+
COPY requirements.txt .
22+
23+
COPY app.py /app/app.py
24+
COPY ./src /app/src
25+
26+
HEALTHCHECK CMD curl --fail http://localhost:8000/v1/health || exit 1
27+
# We run the application
28+
29+
RUN pip install -r requirements.txt
30+
31+
RUN adduser -u 9263 --disabled-password --gecos "" appuser && chown -R appuser /app
32+
USER appuser
33+
CMD ["fastapi", "run"]

0 commit comments

Comments
 (0)