Skip to content

Commit

Permalink
Merge pull request #5 from VaquitApp/develop
Browse files Browse the repository at this point in the history
Merge develop
  • Loading branch information
MegaRedHand authored May 12, 2024
2 parents df41702 + fb699fb commit 8a31273
Show file tree
Hide file tree
Showing 19 changed files with 1,768 additions and 179 deletions.
17 changes: 17 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.github
.gitignore
.stignore
.vscode
venv
**/__pycache__
.pytest_cache
.mypy_cache

k8s
README.md
okteto.yml
.stignore
pytest.ini

*.db
Makefile
41 changes: 25 additions & 16 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,37 @@ name: Python application

on:
push:
branches: [ "*" ]
branches: ["*"]
pull_request:
branches: [ "main" ]
branches: ["main", "develop"]

permissions:
contents: read

jobs:
build:

ci:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Test with pytest
run: |
pytest
- name: Checkout
uses: actions/checkout@v3

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Install Python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: "poetry"

- name: Install dependencies
run: poetry install --no-interaction --no-root

- name: Run tests
run: make test
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,4 @@ pyrightconfig.json

# End of https://www.toptal.com/developers/gitignore/api/python

sql_app.db
*.db
37 changes: 25 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
# Usa la imagen oficial de Python como base
FROM python:3.10
# https://fastapi.tiangolo.com/deployment/docker/
FROM python:3.11-alpine as requirements-stage

# Variables de entorno
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
WORKDIR /tmp

# Directorio de trabajo
WORKDIR /app
# Instala poetry
RUN pip install poetry
# Copia solo el listado de dependencias
COPY ./pyproject.toml ./poetry.lock* /tmp/

# Copia los archivos de la aplicación
COPY . .
# Compila el requirements.txt
RUN poetry export -f requirements.txt --output requirements.txt --without-hashes

# Instala las dependencias
RUN pip install --no-cache-dir -r requirements.txt

FROM python:3.11 as production-stage

WORKDIR /app

# Variables de entorno
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# Instala las herramientas de PostgreSQL
RUN apt-get update \
&& apt-get install -y --no-install-recommends postgresql-client \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Instala las dependencias
COPY --from=requirements-stage /tmp/requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt

# Copia los archivos de la aplicación
COPY . .

# Puerto expuesto
EXPOSE 8000

# Comando para ejecutar la aplicación
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Vaquitapp

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
all: format lint test

install:
poetry install

format:
poetry run black src

lint:
poetry run flake8 src

test:
rm test.db 2> /dev/null || true
poetry run pytest -sv .

run: install
poetry run uvicorn src.main:app --host localhost --port 8000 --reload
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Vaquitapp backend

[![CI](https://github.com/VaquitApp/backend/actions/workflows/python-app.yml/badge.svg)](https://github.com/VaquitApp/backend/actions/workflows/python-app.yml)

## Dependencies

- make
- python3.11
- poetry

## Installation

After installing dependencies, run:

```bash
make install
```

## How to run

Run app locally with:

```bash
make run
```

***Note**: this will also install dependencies with poetry*

## Development pipeline

This project uses the *pytest* test suite in the CI pipeline.
To run tests locally, use the command `make test`.

To format or lint the project, run `make format` or `make lint` respectively.
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# docker-compose.yml

version: '3'
version: "3"

services:
app:
build: .
ports:
- "8000:8000"
- "8000:8000"
Loading

0 comments on commit 8a31273

Please sign in to comment.