db_mongo_poetry
Makefile
WORK_DIR := /root/project
CACHE_DIR := /root/.cache
IMAGE_TAG := ubt_py37
DOCKER_RUN := docker run \
--rm -it \
-v $(PWD):$(WORK_DIR) \
-v $(PWD)/cache:$(CACHE_DIR) \
-w $(WORK_DIR) \
$(IMAGE_TAG)
GEN_KEY := openssl req -new -newkey rsa:4096 -days 3650 -nodes -x509 -subj "/C=US/ST=WO/L=Stan/O=microsoft.com/CN=ms"
build:
docker build . -t $(IMAGE_TAG)
init:
$(DOCKER_RUN) poetry init
install:
$(DOCKER_RUN) poetry install
add:
$(DOCKER_RUN) poetry add $(name)
remove:
$(DOCKER_RUN) poetry remove $(name)
run:
$(DOCKER_RUN) poetry run python $(name)
genkey:
$(GEN_KEY) -keyout ./cert/b.key -out ./cert/a.crt
Dockerfile
FROM ubuntu:22.04
# RUN sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
RUN apt update
RUN apt-get install -y software-properties-common
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt update
RUN apt install -y libpq-dev
RUN apt install -y python3.7 python3-pip python3.7-dev python3.7-distutils
RUN apt install -y make
RUN apt install -y build-essential libssl-dev libffi-dev
RUN DEBIAN_FRONTEND=noninteractive TZ=Asia/Shanghai apt-get -y install tzdata
ENV TZ=Asia/Shanghai
# RUN python3.7 -m pip install poetry -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN python3.7 -m pip install poetry
RUN ln -s /usr/bin/python3 /usr/bin/python
# custom
RUN apt install -y supervisor socat
RUN apt install -y npm
RUN npm install -g js-obfuscator
.yml
version: '3'
services:
mongodb:
image: mongo
volumes:
- TZ=Aisa/Shanghai
- ./mongo/data:/data/db
restart: always
ports:
- "127.0.0.1:27017:27017"
web_control:
build: .
image: ubt_py37
restart: always
volumes:
- .:/root/project
- ./cache:/root/.cache/
working_dir: /root/project
command: poetry run python ctrl.py
network_mode: host # port 8080
depends_on:
- "mongodb"
web_script:
build: .
image: ubt_py37
restart: always
volumes:
- .:/root/project
- ./cache:/root/.cache/
working_dir: /root/project
command: poetry run python script.py
network_mode: host # port 80
depends_on:
- "web_control"
web_websocket:
build: .
image: ubt_py37
restart: always
volumes:
- .:/root/project
- ./cache:/root/.cache/
working_dir: /root/project
command: poetry run python ws.py
network_mode: host # port 2086
depends_on:
- "web_script"
web_socat_1:
build: .
image: ubt_py37
restart: always
volumes:
- .:/root/project
working_dir: /root/project
command: socat ssl-l:8443,reuseaddr,fork,cert=cert/a.crt,key=cert/b.key,verify=0 tcp:127.0.0.1:8080
network_mode: host
depends_on:
- "web_websocket"
web_socat_2:
build: .
image: ubt_py37
restart: always
volumes:
- .:/root/project
working_dir: /root/project
command: socat ssl-l:2087,reuseaddr,fork,cert=cert/a.crt,key=cert/b.key,verify=0 tcp:127.0.0.1:2086
network_mode: host
depends_on:
- "web_websocket"