Skip to content

Commit

Permalink
Merge pull request #1 from moevm/hello_world
Browse files Browse the repository at this point in the history
№1: Added hello world example
  • Loading branch information
Fayzak authored Sep 14, 2024
2 parents aace5f6 + 5295eda commit 7b6c400
Show file tree
Hide file tree
Showing 8 changed files with 384 additions and 0 deletions.
13 changes: 13 additions & 0 deletions hello_world/gighunt/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Dockerfile

FROM python:3.12-slim

WORKDIR /app

COPY pyproject.toml poetry.lock ./

RUN pip install poetry && poetry install --no-root

Check failure on line 9 in hello_world/gighunt/Dockerfile

View workflow job for this annotation

GitHub Actions / Проверка наличия тега 0.8 и работоспособности docker-compose

DL3013 warning: Pin versions in pip. Instead of `pip install <package>` use `pip install <package>==<version>` or `pip install --requirement <requirements file>`

Check failure on line 9 in hello_world/gighunt/Dockerfile

View workflow job for this annotation

GitHub Actions / Проверка наличия тега 0.8 и работоспособности docker-compose

DL3042 warning: Avoid use of cache directory with pip. Use `pip install --no-cache-dir <package>`

COPY . .

CMD ["poetry", "run", "python", "gighunt/app.py"]
Empty file added hello_world/gighunt/README.md
Empty file.
25 changes: 25 additions & 0 deletions hello_world/gighunt/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: '3.8'

services:
arangodb:
image: arangodb:3.10
environment:
- ARANGO_ROOT_PASSWORD=password
ports:
- "8529:8529"
volumes:
- arango_data:/var/lib/arangodb3

python-app:
build: .
depends_on:
- arangodb
environment:
- ARANGO_HOST=arangodb
- ARANGO_PORT=8529
volumes:
- .:/app
command: poetry run python gighunt/app.py

volumes:
arango_data:
Empty file.
36 changes: 36 additions & 0 deletions hello_world/gighunt/gighunt/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from arango import ArangoClient


def main():
# Подключаемся к ArangoDB
client = ArangoClient(hosts='http://arangodb:8529')

# Логинимся
sys_db = client.db('_system', username='root', password='password')

# Проверяем, существует ли база данных
if not sys_db.has_database('test_db'):
sys_db.create_database('test_db')

# Подключаемся к базе данных
db = client.db('test_db', username='root', password='password')

# Проверяем, существует ли коллекция
if not db.has_collection('test_collection'):
collection = db.create_collection('test_collection')
else:
collection = db.collection('test_collection')

# Вставляем данные
doc = {'name': 'Alice', 'age': 25}
collection.insert(doc)
print('Document inserted:', doc)

# Читаем данные
cursor = collection.all()
for document in cursor:
print('Document found:', document)


if __name__ == "__main__":
main()
295 changes: 295 additions & 0 deletions hello_world/gighunt/poetry.lock

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions hello_world/gighunt/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[tool.poetry]
name = "gighunt"
version = "0.1.0"
description = ""
authors = ["Fayzak <gildem19@yandex.ru>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.10"
python-arango = "^8.1.1"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Empty file.

0 comments on commit 7b6c400

Please sign in to comment.