docker
This commit is contained in:
parent
9a60c514c5
commit
3eb5d6aa25
15
Dockerfile
Normal file
15
Dockerfile
Normal 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
|
@ -1,10 +1,14 @@
|
||||
# Niming Backend
|
||||
|
||||
## 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
|
||||
```
|
||||
|
||||
|
27
docker-compose.yml
Normal file
27
docker-compose.yml
Normal 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
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user