Compare commits

...

2 Commits

Author SHA1 Message Date
p23
9c26a5610c README.md 2024-12-18 05:02:50 +00:00
p23
3eb5d6aa25 docker 2024-12-18 05:00:33 +00:00
4 changed files with 55 additions and 9 deletions

15
Dockerfile Normal file
View File

@ -0,0 +1,15 @@
FROM python:3.11
WORKDIR /app
# apt install
RUN apt-get update && \
DEBAIN_FRONTEND=noninteractive apt-get install -qy libmagic1 libmagic-dev
# other packages if needed
# git openssh-server vim net-tools iputils-ping btop tmux wget
# pip3 install
COPY ./requirements.txt /app/requirements.txt
RUN pip3 install -r /app/requirements.txt
EXPOSE 5000

View File

@ -1,10 +1,14 @@
# Niming Backend
# Niming Backend Appserver
## build
### with docker-compose
See ``docker-compose.yml`` (It is a template)
### Manual
Prepare:
```
apt update
apt install libmagic1 libmagic-dev -y
pip3 install -r requirements.txt
```
@ -13,4 +17,4 @@ Run:
python3 app.py
```
Shirakami Fubuki is the cutest fox!!!
> Shirakami Fubuki is the cutest fox!!!

27
docker-compose.yml Normal file
View File

@ -0,0 +1,27 @@
version: '3'
# template: docker-compose.yml
services:
niming-backend-appserver:
build: .
container_name: niming-backend-appserver
volumes:
- "appserver_data/:/app"
ports:
- "5000:5000"
environment:
- PG_HOST=postgresql+psycopg2://root:password@ip:port/niming_db
- S3_ENDPOINT=ip:port
- S3_ACCESS_KEY=
- S3_SECRET_KEY=
- S3_BUCKET=nmfs
- IGRPC_HOST=ip:port
- PLATFORM_ROOT_PASSWORD=
- JWT_KEY=
- TIMEZONE=Asia/Taipei
restart: unless-stopped
working_dir: /app
command: python3 /app/app.py
#networks:
# - networkName

View File

@ -6,38 +6,38 @@ import grpc
from protobuf_files import igapi_pb2_grpc
from protobuf_files.igapi_pb2 import Request, Reply
IGAPI_HOST = os.getenv("IGAPI_HOST", None)
IGRPC_HOST = os.getenv("IGRPC_HOST", None)
def request_account_info() -> Tuple[dict, int]:
with grpc.insecure_channel(IGAPI_HOST) as channel:
with grpc.insecure_channel(IGRPC_HOST) as channel:
stub = igapi_pb2_grpc.IGAPIStub(channel)
res = stub.account_info(Request())
return dict(res.result.items()), res.err
def request_login() -> Tuple[dict, int]:
with grpc.insecure_channel(IGAPI_HOST) as channel:
with grpc.insecure_channel(IGRPC_HOST) as channel:
stub = igapi_pb2_grpc.IGAPIStub(channel)
res = stub.login(Request())
return dict(res.result.items()), res.err
def request_queue() -> dict:
with grpc.insecure_channel(IGAPI_HOST) as channel:
with grpc.insecure_channel(IGRPC_HOST) as channel:
stub = igapi_pb2_grpc.IGAPIStub(channel)
res = stub.queue(Request())
return dict(res.result.items())
def request_upload(aid:int) -> Tuple[dict, int]:
with grpc.insecure_channel(IGAPI_HOST) as channel:
with grpc.insecure_channel(IGRPC_HOST) as channel:
stub = igapi_pb2_grpc.IGAPIStub(channel)
res = stub.upload(Request(code=aid))
return dict(res.result.items()), res.err
def request_delete(aid:int, code:str) -> Tuple[dict, int]:
with grpc.insecure_channel(IGAPI_HOST) as channel:
with grpc.insecure_channel(IGRPC_HOST) as channel:
stub = igapi_pb2_grpc.IGAPIStub(channel)
res = stub.delete(Request(code=aid, args=[code]))
return dict(res.result.items()), res.err