Skip to content

Commit

Permalink
add embedded data storage package
Browse files Browse the repository at this point in the history
  • Loading branch information
paraleipsis committed Aug 24, 2023
1 parent 1e9135a commit b606dbf
Show file tree
Hide file tree
Showing 12 changed files with 612 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
__pycache__
*.pyc
*.pyo
*.pyd
.Python
pip-log.txt
pip-delete-this-directory.txt
.tox
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.log
.mypy_cache
.pytest_cache
.hypothesis
.git/
.idea/
venv/
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.idea
.ipynb_checkpoints
.mypy_cache
.vscode
__pycache__
.pytest_cache
htmlcov
dist
site
.coverage
coverage.xml
.netlify
test.db
log.txt
*.log
Pipfile.lock
env3.*
env
.env
docs_build
venv/
docs.zip
archive.zip
migrations/versions/*
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM python:3.11-alpine

ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1

WORKDIR /phonebook-app

RUN apk update
RUN pip install --upgrade pip

COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade -r /phonebook-app/requirements.txt

COPY . .

ENV PYTHONPATH="${PYTHONPATH}:/phonebook-app/src"

LABEL maintainer="paralepsis <[email protected]>"
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3.3'

services:
api:
build: .
container_name: phonebook-api
command: python3 src/core/main.py
restart: unless-stopped
ports:
- "8001:8001"
volumes:
- .:/phonebook-app

networks:
phonebook-app:
7 changes: 7 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
python-dotenv==1.0.0
pydantic==1.10.7
aiofiles==23.2.1
aiohttp==3.8.5
typer[all]==0.9.0
tabulate==0.9.0
PyYAML==6.0.1
7 changes: 7 additions & 0 deletions src/conf/.env-example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Name of database (JSON file) to create and use as phonebook.
# Don't specify the path, just specify the name, the path will be formed automatically.
DB_NAME=phonebook.json

# Host and port for aiohttp REST API server.
HOST=127.0.0.1
PORT=8001
15 changes: 15 additions & 0 deletions src/conf/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import os
from pathlib import Path
from dotenv import load_dotenv

load_dotenv(dotenv_path='.env-example')

# The root directory of the project from which all paths will be formed.
BASE_DIR: Path = Path(__file__).resolve().parent.parent

DB_NAME: str = os.environ.get("DB_NAME")
DB_LOCATION: Path = BASE_DIR / "db/data" / DB_NAME

HOST: str = os.environ.get("HOST")
PORT: int | str = os.environ.get("PORT")
SERVER_URL: str = f'http://{HOST}:{PORT}'
Loading

0 comments on commit b606dbf

Please sign in to comment.