【打工日常】Docker部署一款开源和自托管的平铺图像板系统

一、项目介绍

    1.项目简述
    Pinry,一个平铺图像板系统,适用于想要以易于浏览的格式保存、标记和共享图像、视频和网页的用户,并且软件是开源和自托管的。
    
    2.项目特点
    图像提取和在线预览、Pin图标记系统、浏览器扩展、多用户支持、适用于docker、公共和私人板、按标签搜索/搜索带有名称的看板、通过DRF提供完整的API支持、CLI支持、i18n支持(英语、简体中文、Lilian的法语支持)

    3.项目开源地址
    https://github.com/pinry/pinry/
    

----------

二、项目搭建环境

    1. 项目测试环境

    A.项目搭建在腾讯云centos7.6,外网地址为43.138.153.157
    Linux VM-8-12-centos 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

    B.docker版本为26.01,docker-compose版本为v2.26.1
    注意:本次实践部署环境为个人腾讯云的测试环境,若是生产环境请谨慎部署;对应开启了容器的端口,在linux下和防火墙下需开放对应端口。
    
    2. 本次项目实施过程
    
    使用docker下载镜像,创建好项目需要挂载的路径,通过docker-cli或者docker compose启动容器,启动容器后查看容器启动状态,查看容器的运行日志是否正常,以上全部正常执行后体验项目功能。

    3.注意:docker下载镜像有可能遇到比较慢的情况,参考以下解决措施:
    
    A.docker配置换源,进入/etc/docker的路径,如果没有就创建这个目录
    cd /etc/docker/
    mkdir -p /etc/docker
    
    B.编辑配置文件
    vim daemon.json   ##可以清空里面的内容:%d 然后复制下面的源进去wq保存
    
    {
        "registry-mirrors":[
            "https://286u3d9d.mirror.aliyuncs.com"
        ]
    }
    
    C.registry-mirrors:指定了一个镜像仓库的 URL https://286u3d9d.mirror.aliyuncs.com。 这个配置项用于设置 Docker镜像的镜像仓库地址,使得在拉取和推送 Docker 镜像时能够通过该镜像仓库进行加速。这边提供的是广东广州服务器的镜源,建议个人自己去阿里云建一个个人账号,根据实际所在区获取镜源。
    
    D.重新加载源,重启docker服务
    sudo systemctl daemon-reload 
    sudo systemctl restart docker

----------


三、项目搭建前巡检

    1. 检查docker是否正常运行
    systemctl status docker
    or
    service docker status
    注:我个人测试环境是使用systemctl进行管理,若有使用service管理请使用第二条的命令进行查看。   
    
    [root@VM-8-12-centos ~]# systemctl status docker
    ● docker.service - Docker Application Container Engine
       Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
       Active: active (running) since Mon 2024-04-22 23:13:57 CST; 4 days ago
         Docs: https://docs.docker.com
     Main PID: 17092 (dockerd)
        Tasks: 158
       Memory: 142.3M
       CGroup: /system.slice/docker.service

    若显示docker的Active是active (running),即表明docker是正常运行的。

    2.一般我会使用docker-compose去管理,所以预先需要创建好yaml文件,vim docker-compose.yml,格式如下例子:

    version: '3.9'
    services:
        nginx:
            image: nginx
            logging:
                options:
                    max-size: 1g
            restart: always
            volumes:
                - '/var/run/docker.sock:/tmp/docker.sock:ro'
            ports:
                - '80:80'

----------


四、项目实施过程

    1.根据开源项目,找到对应的镜像进行pull,若遇到很慢的情况,先检查是否网络问题以及是否已经换源。
    docker pull getpinry/pinry

    [root@VM-8-12-centos ~]# docker pull getpinry/pinry
    Using default tag: latest
    latest: Pulling from getpinry/pinry
    69692152171a: Pull complete 
    66a3c154490a: Pull complete 
    82a02637ec8f: Pull complete 
    d8b2fbd22335: Pull complete 
    c23c10f79e77: Pull complete 
    fed942222a11: Pull complete 
    15c59856e0c2: Pull complete 
    efe8f94c3b02: Pull complete 
    02ac53993651: Pull complete 
    db8c99692bb0: Retrying in 1 second 
    79b84675f08b: Download complete 
    4fb263c94429: Retrying in 6 seconds 
    2900d104f423: Retrying in 1 second 
    44b60670e9f6: Waiting 
    340c5087829d: Waiting 
    4821235a5970: Waiting 
    latest: Pulling from getpinry/pinry
    Digest: sha256:b0f9eeb195d478d9a989e220861b4638f4fb489d02fdaac1e46bbacd46e90a96
    Status: Image is up to date for getpinry/pinry:latest
    docker.io/getpinry/pinry:latest

    2.若已经下载完成显示新的一行,可以输入命令查看是否上一条命令执行成功
    echo$?
    若返回0,则成功;返回其他则根据实际情况重新下载或者查找原因。

    3.docker下载完后,可以查看对应的镜像是否下载成功
    docker images |grep pinry

    [root@VM-8-12-centos ~]# docker images |grep pinry
    getpinry/pinry              latest      b874c1af4954   24 months ago   350MB

    4.创建Pinry目录
    mkdir -p /opt/pinry
     
    5.下载成功后,编辑docker-compose.yml文件
    
    version: '3.9'
    services:
      pinry:
        image: getpinry/pinry
        volumes:
            - '/opt/pinry:/data'
        ports:
            - '7721:80'
        restart: always
        container_name: pinry

    编辑后输入wq进行保存
        
    6.为了便捷启动,也可以使用docker-cli启动
        
    docker run -d  --name pinry --restart always -p 7721:80  -v /opt/pinry:/data  getpinry/pinry

    7.启动docker-compose

    docker compose up -d  
    
    8.启动容器后,查看容器的状态是否正常  
    
    docker ps |grep  pinry
        
    [root@VM-8-12-centos docker-compose]# docker ps |grep  pinry
    3bdbf4b01acf   getpinry/pinry          "/pinry/docker/scrip…"   28 seconds ago   Up 27 seconds   0.0.0.0:7721->80/tcp, :::7721->80/tcp       pinry
    
    9.启动容器后,查看容器的日志是否正常
    
    docker logs -f pinry
    
    [root@VM-8-12-centos pinry]# docker logs -f pinry
    ==================================================================================
    Note: Please copy this key and keep it in a secure place.
    Then you should manually edit your pinry/local_settings.py
    and replace SECRET_KEY with new secret-key if you had previously generated a
    pinry/local_settings.py.
    If no previous pinry/local_settings.py generated, you can have a look and edit it.
    If you want to use docker-compose, just edit docker-compose.yml and use 'docker-compose up'
    
    Your secret-key is(also saved/overwritten your docker's /data/production_secret_key.txt):
    
    eimoothoowoFahy8eubaphaiPei5cheephahji5chee3phai3aena7Yazuay2aehi
    ==================================================================================
    WARNING:root:No SECRET_KEY given in environ, please have a check.If you have a local_settings file, please ignore this warning.
    
    153 static files copied to '/data/static'.
    WARNING:root:No SECRET_KEY given in environ, please have a check.If you have a local_settings file, please ignore this warning.
    Operations to perform:
      Apply all migrations: admin, auth, authtoken, contenttypes, core, django_images, sessions, taggit, users
    Running migrations:
      Applying contenttypes.0001_initial... OK
      Applying auth.0001_initial... OK
      Applying admin.0001_initial... OK
      Applying admin.0002_logentry_remove_auto_add... OK
      Applying admin.0003_logentry_add_action_flag_choices... OK
      Applying contenttypes.0002_remove_content_type_name... OK
      Applying auth.0002_alter_permission_name_max_length... OK
      Applying auth.0003_alter_user_email_max_length... OK
      Applying auth.0004_alter_user_username_opts... OK
      Applying auth.0005_alter_user_last_login_null... OK
      Applying auth.0006_require_contenttypes_0002... OK
      Applying auth.0007_alter_validators_add_error_messages... OK
      Applying auth.0008_alter_user_username_max_length... OK
      Applying auth.0009_alter_user_last_name_max_length... OK
      Applying auth.0010_alter_group_name_max_length... OK
      Applying auth.0011_update_proxy_permissions... OK
      Applying authtoken.0001_initial... OK
      Applying authtoken.0002_auto_20160226_1747... OK
      Applying authtoken.0003_tokenproxy... OK
      Applying users.0001_initial... OK
      Applying taggit.0001_initial... OK
      Applying taggit.0002_auto_20150616_2121... OK
      Applying django_images.0001_initial... OK
      Applying core.0001_initial... OK
      Applying core.0002_pin_referer... OK
      Applying core.0003_auto_20190222_1358... OK
      Applying core.0004_auto_20190715_0912... OK
      Applying core.0004_auto_20190222_1451... OK
      Applying core.0005_merge_20191122_0450... OK
      Applying core.0006_remove_pin_origin... OK
      Applying core.0007_pin_private... OK
      Applying core.0008_board_private... OK
      Applying core.0009_auto_20200825_0800... OK
      Applying core.0010_auto_20210311_1521... OK
      Applying django_images.0002_auto_20180826_0814... OK
      Applying sessions.0001_initial... OK
      Applying taggit.0003_taggeditem_add_unique_index... OK
    [2024-05-01 13:46:57 +0000] [23] [INFO] Starting gunicorn 20.1.0
    [2024-05-01 13:46:57 +0000] [23] [INFO] Listening at: http://0.0.0.0:8000 (23)
    [2024-05-01 13:46:57 +0000] [23] [INFO] Using worker: sync
    [2024-05-01 13:46:57 +0000] [24] [INFO] Booting worker with pid: 24
    [2024-05-01 13:46:58 +0000] [25] [INFO] Booting worker with pid: 25
    [2024-05-01 13:46:58 +0000] [26] [INFO] Booting worker with pid: 26
    [2024-05-01 13:46:58 +0000] [27] [INFO] Booting worker with pid: 27
    WARNING:root:No SECRET_KEY given in environ, please have a check.If you have a local_settings file, please ignore this warning.
    WARNING:root:No SECRET_KEY given in environ, please have a check.If you have a local_settings file, please ignore this warning.
    WARNING:root:No SECRET_KEY given in environ, please have a check.If you have a local_settings file, please ignore this warning.
    WARNING:root:No SECRET_KEY given in environ, please have a check.If you have a local_settings file, please ignore this warning.

----------


五、项目体验

    注:云服务器记得放开防火墙7721!
    访问地址https://43.138.153.157:7721/,欢迎点击玩一下!我已经创建了账号密码,test/123123
    ps:我的测试服务器是乞丐版,所以每次发了大的项目启动后,可能会把前面的项目停掉,不然会卡爆了,请大家体谅...
    更多好玩有趣有用的内容,请关注微信公众号:零氪的云原生


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

全糖去冰吃不了苦

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值