• Using dockerize to wait for service completed (CI/CD)


    I have a postgresql, and a redis server.

    my django application needs to wait for them all completed to run.

    BTW, postgresql, redis, django all run in Docker containers . Here 3 containers .

    so, use dockerize in my main django Dockerfile

    # install dockerize
    RUN apt-get update && apt-get install -y wget
    ENV DOCKERIZE_VERSION v0.6.1
    RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
        && tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
        && rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz

    in my docker-compose.yml

      web:
        build: .
        # wait for postgresql, redis server up using dockerize
        command: 
                dockerize -wait tcp://redis-cache:6379 -timeout 30s \
                dockerize -wait tcp://db:5432 -timeout 30s \
                python3 manage.py runserver 0.0.0.0:8000
    tcp://redis-cache:6379 // my redis server
    tcp://db:5432 // my postgresql database server
     

    after all tcp ports okay, run the commands

    python3 manage.py runserver 0.0.0.0:8000
  • 相关阅读:
    爬虫入门
    读写文件操作
    列表的操作
    课后习题小练
    Python切片
    逗号的麻烦
    字符串学与练
    Turtle的学习
    FTL(FreeMarker)基础
    java反射机制基础
  • 原文地址:https://www.cnblogs.com/spaceship9/p/15820747.html
Copyright © 2020-2023  润新知