Caching my custom docker image


#1

i notice now w/ my custom docker images i see this everytime

Build-agent version 0.0.6347-92eac3d (2018-06-13T18:13:12+0000)
Starting container asidjazz/pub-api:latest
  image cache not found on this host, downloading asidjazz/pub-api:latest

is there any way I can cache this? here is my current config:

version: 2
jobs:
  web:
    docker_layer_caching: true
    docker:
      - image: asidjazz/pub-web
    working_directory: ~/pub

    steps:
      - checkout

      - setup_remote_docker:
          docker_layer_cache: true

      - restore_cache:
          key: dependency-cache-{{ checksum "web/package.json" }}
          paths: 
            - web/node_modules

      - run: 
          name: Install Dependencies
          command: |
            cd web
            yarn install

      - save_cache:
          key: dependency-cache-{{ checksum "web/package.json" }}
          paths:
            - web/node_modules
        
      - run: 
          name: Run Tests
          command: |
            cd web
            yarn test

      - deploy:
          name: Deploy Web 
          command: |
            if [ "${CIRCLE_BRANCH}" = 'master' ]; then
              commandId=$(aws ssm send-command \
                --region=us-east-1 \
                --targets "Key=tag:SSM,Values=web-${CIRCLE_BRANCH}" \
                --document-name "AWS-RunShellScript" \
                --comment "Deploy Web to ${CIRCLE_BRANCH}" \
                --parameters '{"commands": ["su - ec2-user -c \"cd ~/pub/web; yarn deploy\""]}' \
                --output text \
                --query "Command.CommandId")
              status="InProgress"
              echo ["$commandId"] Status: "$status"
              while  [ "$status" = InProgress ]
              do
                status=$(aws ssm list-commands \
                  --region=us-east-1 \
                  --command-id "$commandId" \
                  --query "Commands[*].Status" \
                  | tr -cd '[:alpha:]')
                printf .
              done
              echo
              echo ["$commandId"] Status: "$status"
              aws ssm list-command-invocations \
                --region=us-east-1 \
                --command-id "$commandId" \
                --query="CommandInvocations[*].CommandPlugins[*].Output" \
                --details \
                | sed 1,2d | sed "s/^[ \t]*\"//" | sed 's/\\n/\'$'\n/g' | head -n -3
            fi
  api:
    docker_layer_caching: true
    docker:
      - image: asidjazz/pub-api:latest
    working_directory: ~/pub

    steps:
      - checkout

      - setup_remote_docker:
          docker_layer_cache: true

      - restore_cache:
          key: dependency-cache-{{ checksum "api/composer.json" }}
          paths: 
            - api/vendor

      - run: 
          name: Install Dependencies
          command: |
            cd api
            composer install

      - save_cache:
          key: dependency-cache-{{ checksum "api/composer.json" }}
          paths:
            - api/vendor
        
      - run: 
          name: Run Tests
          command: |
            cd api
            vendor/bin/phpunit

      - deploy:
          name: Deploy API 
          command: |
            if [ "${CIRCLE_BRANCH}" = 'master' ]; then
              commandId=$(aws ssm send-command \
                --region=us-east-1 \
                --targets "Key=tag:SSM,Values=api-${CIRCLE_BRANCH}" \
                --document-name "AWS-RunShellScript" \
                --comment "Deploy API to ${CIRCLE_BRANCH}" \
                --parameters '{"commands": ["su - ec2-user -c \"cd /var/www/html/pub/api; composer deploy\""]}' \
                --output text \
                --query "Command.CommandId")
              status="InProgress"
              echo ["$commandId"] Status: "$status"
              while  [ "$status" = InProgress ]
              do
                status=$(aws ssm list-commands \
                  --region=us-east-1 \
                  --command-id "$commandId" \
                  --query "Commands[*].Status" \
                  | tr -cd '[:alpha:]')
                printf .
              done
              echo
              echo ["$commandId"] Status: "$status"
              aws ssm list-command-invocations \
                --region=us-east-1 \
                --command-id "$commandId" \
                --query="CommandInvocations[*].CommandPlugins[*].Output" \
                --details \
                | sed 1,2d | sed "s/^[ \t]*\"//" | sed 's/\\n/\'$'\n/g' | head -n -3
            fi


workflows:
  version: 2
  web-and-api:
    jobs:
      - api
      - web


#2

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.