kind: pipeline type: docker name: build-and-run-python trigger: branch: include: - master event: include: - push - custom - merge_request steps: - name: build python image image: docker volumes: - name: dockersock path: /var/run/docker.sock commands: # 构建镜像 - docker build -t alert-python:latest -f Dockerfile . - name: run python container image: docker volumes: - name: dockersock path: /var/run/docker.sock commands: - docker stop alert-python || true - docker rm alert-python || true # 直接挂载配置文件到容器内的 /opt/alert/model-lab/config.py(同时覆写 /app/config.py) - docker run -d --restart always --name alert-python --network alert-net -p 8082:8082 -v $(pwd)/config.py:/opt/alert/model-lab/config.py:ro -v $(pwd)/config.py:/app/config.py:ro alert-python:latest volumes: - name: dockersock host: path: /var/run/docker.sock