|
8 | 8 | resource_class: large |
9 | 9 | environment: |
10 | 10 | IMAGE_NAME: << parameters.image_name >> |
11 | | - # Enable 'docker manifest' |
12 | | - DOCKER_CLI_EXPERIMENTAL: "enabled" |
13 | | - DOCKER_BUILDKIT: 1 |
14 | 11 | steps: |
15 | 12 | - checkout |
16 | | - - run: |
17 | | - name: Calculate docker tag |
18 | | - command: | |
19 | | - set -x |
20 | | - mkdir .circleci/shared |
21 | | - # git keeps a hash of all sub trees |
22 | | - echo "export DOCKER_TAG=$(git rev-parse HEAD:.circleci/docker)" >> .circleci/shared/env_file |
23 | | - # Saves our calculated docker tag to our workpace for later use |
24 | | - - persist_to_workspace: |
25 | | - root: . |
26 | | - paths: |
27 | | - - .circleci/shared/ |
28 | | - - load_shared_env: |
29 | | - root: . |
30 | | - - run: |
31 | | - name: Check if image should be built |
32 | | - command: | |
33 | | - set +x |
34 | | - export AWS_ACCESS_KEY_ID=${CIRCLECI_AWS_ACCESS_KEY_FOR_DOCKER_BUILDER_V1} |
35 | | - export AWS_SECRET_ACCESS_KEY=${CIRCLECI_AWS_SECRET_KEY_FOR_DOCKER_BUILDER_V1} |
36 | | - eval $(aws ecr get-login --no-include-email --region us-east-1) |
37 | | - set -x |
38 | | - # Check if image already exists, if it does then skip building it |
39 | | - if docker manifest inspect "308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/${IMAGE_NAME}:${DOCKER_TAG}"; then |
40 | | - circleci-agent step halt |
41 | | - fi |
42 | | - PREVIOUS_DOCKER_TAG=$(git rev-parse "$(git merge-base HEAD << pipeline.git.base_revision >>):.circleci/docker") |
43 | | - # If no image exists but the hash is the same as the previous hash then we should error out here |
44 | | - # no stampeding herd effect plz. |
45 | | - if [[ ${PREVIOUS_DOCKER_TAG} = ${DOCKER_TAG} ]]; then |
46 | | - echo "ERROR: Something has gone wrong and the previous image isn't available for the merge-base of your branch" |
47 | | - echo " contact the PyTorch team to restore the original images" |
48 | | - exit 1 |
49 | | - fi |
50 | 13 | - run: |
51 | 14 | name: build_docker_image_<< parameters.image_name >> |
52 | 15 | no_output_timeout: "1h" |
|
55 | 18 | export AWS_ACCESS_KEY_ID=${CIRCLECI_AWS_ACCESS_KEY_FOR_DOCKER_BUILDER_V1} |
56 | 19 | export AWS_SECRET_ACCESS_KEY=${CIRCLECI_AWS_SECRET_KEY_FOR_DOCKER_BUILDER_V1} |
57 | 20 | set -x |
58 | | - source .circleci/shared/env_file |
59 | 21 | cd .circleci/docker && ./build_docker.sh |
60 | | -
|
61 | 22 | docker_for_ecr_gc_build_job: |
62 | 23 | machine: |
63 | 24 | image: ubuntu-1604:201903-01 |
|
84 | 45 | type: string |
85 | 46 | environment: |
86 | 47 | PROJECT: << parameters.project >> |
87 | | - # TODO: Remove legacy image tags once we feel comfortable with new docker image tags |
88 | 48 | IMAGE_TAG: << parameters.tags_to_keep >> |
89 | 49 | docker: |
90 | 50 | - image: 308535385114.dkr.ecr.us-east-1.amazonaws.com/gc/ecr |
91 | 51 | aws_auth: |
92 | 52 | aws_access_key_id: ${CIRCLECI_AWS_ACCESS_KEY_FOR_DOCKER_BUILDER_V1} |
93 | 53 | aws_secret_access_key: ${CIRCLECI_AWS_SECRET_KEY_FOR_DOCKER_BUILDER_V1} |
| 54 | + |
94 | 55 | steps: |
95 | | - - checkout |
96 | | - - run: |
97 | | - # NOTE: see 'docker_build_job' for how these tags actually get built |
98 | | - name: dynamically generate tags to keep |
99 | | - no_output_timeout: "1h" |
100 | | - command: | |
101 | | - GENERATED_IMAGE_TAG=$(\ |
102 | | - git log --oneline --pretty='%H' .circleci/docker \ |
103 | | - | xargs -I '{}' git rev-parse '{}:.circleci/docker' \ |
104 | | - | paste -sd "," -) |
105 | | - echo "export GENERATED_IMAGE_TAG='${GENERATED_IMAGE_TAG}'" >> ${BASH_ENV} |
106 | 56 | - run: |
107 | 57 | name: garbage collecting for ecr images |
108 | 58 | no_output_timeout: "1h" |
|
111 | 61 | export AWS_ACCESS_KEY_ID=${CIRCLECI_AWS_ACCESS_KEY_FOR_DOCKER_BUILDER_V1} |
112 | 62 | export AWS_SECRET_ACCESS_KEY=${CIRCLECI_AWS_SECRET_KEY_FOR_DOCKER_BUILDER_V1} |
113 | 63 | set -x |
114 | | - /usr/bin/gc.py --filter-prefix ${PROJECT} --ignore-tags "${IMAGE_TAG},${GENERATED_IMAGE_TAG}" |
| 64 | + /usr/bin/gc.py --filter-prefix ${PROJECT} --ignore-tags ${IMAGE_TAG} |
115 | 65 |
|
116 | 66 | docker_hub_index_job: |
117 | 67 | docker: |
|
0 commit comments