我有一个看起来像这样的Dockerfile:
FROM python:3.6
WORKDIR /app
ADD . /app/
# Install system requirements
RUN apt-get update && \
xargs -a requirements_apt.txt apt-get install -y
# Install Python requirements
RUN python -m pip install --upgrade pip
RUN python -m pip install -r requirements_pip.txt
# Circle CI ignores entrypoints by default
ENTRYPOINT ["dostuff"]我有一个CircleCI配置,它可以:
version: 2.1
orbs:
aws-ecr: circleci/aws-ecr@6.15.3
jobs:
benchmark_tests_dev:
docker:
- image: blah_blah_image:test_dev
#auth
steps:
- checkout
- run:
name: Compile and run benchmarks
command: make bench
workflows:
workflow_test_and_deploy_dev:
jobs:
- aws-ecr/build-and-push-image:
name: build_test_dev
context: my_context
account-url: AWS_ECR_ACCOUNT_URL
region: AWS_REGION
repo: my_repo
aws-access-key-id: AWS_ACCESS_KEY_ID
aws-secret-access-key: AWS_SECRET_ACCESS_KEY
dockerfile: Dockerfile
tag: test_dev
filters:
branches:
only: my-test-branch
- benchmark_tests_dev:
requires: [build_test_dev]
context: my_context
filters:
branches:
only: my-test-branch
- aws-ecr/build-and-push-image:
name: deploy_dev
requires: [benchmark_tests_dev]
context: my_context
account-url: AWS_ECR_ACCOUNT_URL
region: AWS_REGION
repo: my_repo
aws-access-key-id: AWS_ACCESS_KEY_ID
aws-secret-access-key: AWS_SECRET_ACCESS_KEY
dockerfile: Dockerfile
tag: test2
filters:
branches:
only: my-test-branchmake bench看起来像:
bench:
python tests/benchmarks/bench_1.py
python tests/benchmarks/bench_2.py这两种基准测试都遵循以下模式:
# imports
# define constants
# Define functions/classes
if __name__ == "__main__":
# Run those tests如果我在my-test-branch上本地构建我的Docker容器,重写入口点以进入它,然后在容器中运行make bench,这两个脚本都完美地执行和退出。
如果我提交到同一个分支并触发CircleCI工作流,则bench_1.py将运行,然后永不退出。我已经尝试过在make命令中切换Python脚本的顺序。在这种情况下,bench_2.py运行,然后永远不退出。我尝试过在两个脚本的sys.exit()块的末尾放置一个if __name__ == "__main__":,这并不会强制在CircleCI上退出。第一个要运行的脚本将运行到完成,因为我已经在整个脚本中放置了日志来跟踪进度。它从来没有离开过。
知道为什么这些脚本会在本地运行并退出容器,而不会在CircleCI上的容器中退出吗?
编辑
我刚意识到“永不退出”是我在做的一个假设。脚本有可能退出,但在那之后,CircleCI作业会悄然挂起?关键是脚本运行、完成,CircleCI作业继续运行,直到我得到10分钟的超时错误(Too long with no output (exceeded 10m0s): context deadline exceeded)。
https://stackoverflow.com/questions/66671373
复制相似问题