当前位置:网站首页>Docker compose deploy the flask project and build the redis service
Docker compose deploy the flask project and build the redis service
2022-06-29 19:12:00 【Seasonal cloth,】
establish redis Profile directory
(base) [email protected]:~/redis/conf$ pwd
/home/lx/redis/conf
# Modify the permissions
(base) [email protected]:~$ chmod 777 redis/
(base) [email protected]:~$ cd /home/lx/redis/conf
# download redis Configuration file for
(base) [email protected]:~$ wget http://download.redis.io/redis-stable/redis.conf
# Changing configuration files
(base) [email protected]:~$vim redis.conf
Customize redis.conf The configuration file
# Turn on Protection The default is yes You can skip this step
protected-mode yes
# Open remote connection So all of ip You can visit
#bind 127.0.0.1
# Custom password
requirepass 12345678
port 6379
timeout 0
# 900s If at least one write operation is performed in the bgsave Conduct RDB Persistence
save 900 1
save 300 10
save 60 10000
rdbcompression yes
dbfilename dump.rdb
dir /data
appendonly yes
appendfsync everysec
structure Dockerfile
FROM python:3.6
WORKDIR /app
COPY requirements.txt requirements.txt
RUN pip install -U pip -i https://pypi.tuna.tsinghua.edu.cn/simple/
RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
EXPOSE 8000
Use docker-compose establish Redis And manage flask project
# Set up docker compose edition
version: "3.8"
# Set up services , Fixed writing
services:
# flask Project services
duplicate_checking:
# Find from current directory dockerfile Build a mirror image
build: .
# The generated image name and version number
image: duplicate_checking:1.0
# restart docker The container also restarts after the engine
restart: always
# project-dependent redis service
depends_on:
- dupchecking_redis
# Container name after image startup
container_name: "compose-dupchecking"
# take duplicate-checking Projects are mapped to containers /app Under the table of contents ( In this way, there is also a complete project code in the container )
volumes:
- "/home/lx/workshop/duplicate-checking:/app:rw"
# Command executed after container startup
command:
- /bin/sh
- -c
- "cd /app
&& export FLASK_APP=app
&& gunicorn -t 300 -w 4 -b 0.0.0.0:8000 'app:create_app()'"
# Port mapping ( Will host the 8090 Ports are mapped to containers 8000 port , In this case, by accessing the 8090 You can briefly access the 8000 port )
ports:
- "8090:8000"
# Network segment used
networks:
- app_net
# redis service ( And dependencies in projects redis The same name )
dupchecking_redis:
# Pull the latest from the image warehouse redis Mirror image
image: redis:latest
restart: always
container_name: "compose-dupcheckingredis"
ports:
- "6381:6379"
command:
- /bin/bash
- -c
# Start through the configuration file mapped into the container by the host redis service
- "redis-server /etc/redis/redis.conf"
volumes:
- $PWD/data:/data
# Will host the redis.conf The configuration file is mapped to the container
- $PWD/conf/redis.conf:/etc/redis/redis.conf
# The network segment here has the same name as the project network segment above , Indicates that in the same network segment
networks:
- app_net
networks:
app_net:
边栏推荐
- Data warehouse model layered ODS, DWD, DWM practice
- MariaDB的安装与配置
- Flutter 调用百度地图APP实现位置搜索、路线规划
- 76. nearest common ancestor of binary tree
- Why is informatization ≠ digitalization? Finally someone made it clear
- 誰在抖音文玩裏趁亂打劫?
- C#_摄像头图像转换为Bitmap格式及绘制十字线
- Introduction to isalpha () method
- From CIO to Consultant: the transformation of it leaders
- After CDN is added to the website, the Font Icon reports an error access control allow origin
猜你喜欢

TP5 where queries whether a field in the database contains a value. Fuzzy queries are performed without the like method

CAD Assistant - 3D模型格式转换利器

SQL Server Backup and restore command operations

使用 OpenCV 的基于标记的增强现实

Mac: MySQL 66 questions, 20000 words + 50 pictures!

Panda Parkour JS games code

细说GaussDB(DWS)复杂多样的资源负载管理手段

数据基础设施升级窗口下,AI 新引擎的技术方法论

Qui vole dans un jeu d'écriture?

细说GaussDB(DWS)复杂多样的资源负载管理手段
随机推荐
php实现 提取不重复的整数(编程题目能够最快的熟悉函数)
Introduction to isalpha () method
Deep learning --- the weight of the three good students' scores (2)
Apache inlong million billion level data stream processing
产品-Axure9(英文版),中继器(Repeater)实现表格内容的增删查改(CRUD)
Unittest unit test framework
NLP 类问题建模方案探索实践
揭秘!付费会员制下的那些小心机!
4-1端口扫描技术
全局变量和静态变量的初始化
Several code screenshots beautification tools worth collecting by programmers
SQL Server Backup and restore command operations
JS judge whether the array key name exists
TP5 where queries whether a field in the database contains a value. Fuzzy queries are performed without the like method
Win11策略服务被禁用怎么办?Win11策略服务被禁用的解决方法
Qui vole dans un jeu d'écriture?
Fastdfs
PHP 输出两个指定日期之间的所有日期
ovirt数据库修改删除节点
正则表达式系列之手机号码正则