Need help in migrating to 2.0


#1

Hi,

I’m using CircleCI 1.0 to build a Docker image. I’m having trouble migrating my 1.0 workflow to 2.0. Actually I don’t even know if this is possible in 2.0.

I have the following build config:

  • all it’s doing is build a docker image and push it to ECR
  • tag based, using regex to match valid semver tags
  • using AWS ECR to pull and push a build cache image, as well as push the final image

I’m confused about how would this map to 2.0? Do I still need to push and pull the build cache image, or I can use the caching layers of 2.0 now?

This is my 1.0 config:

machine:
  services:
    - docker
  python:
    version: 2.7.12
  environment:
    AWS_DEFAULT_REGION: us-east-1
    image_repo: abc
    image_root: docker/app
    image_user: abc.dkr.ecr.us-east-1.amazonaws.com

general:
  branches:
    only:
      - skip

dependencies:
  pre:
    - virtualenv venv
    - . venv/bin/activate
    - pip install fabric semantic_version awscli boto3 docker-squash 'docker < 3' --disable-pip-version-check

  override:
    - "rsync -a --exclude='.git' --exclude='*.pyc' --exclude=.idea --exclude=circle.yml --exclude=db --exclude=docker --exclude=docs --exclude=node_modules --exclude=venv ../../ apptmp/":
        pwd: $image_root
    - "echo $CIRCLE_TAG > VERSION":
        pwd: $image_root

    - "$(aws ecr get-login)"

    - docker pull $image_user/$image_repo:build_cache; exit 0

    - "docker build --rm=false -t $image_user/$image_repo:build_cache .":
        pwd: $image_root

    - docker push $image_user/$image_repo:build_cache

test:
  override:
    - exit 0

deployment:
  ecr:
    tag: /[0-9]+(\.[0-9]+)*/
    commands:
      - docker tag $image_user/$image_repo:build_cache $image_user/$image_repo:$CIRCLE_TAG
      - docker tag $image_user/$image_repo:build_cache $image_user/$image_repo:latest

      - docker push $image_user/$image_repo:$CIRCLE_TAG
      - docker push $image_user/$image_repo:latest

      - aws ecr batch-delete-image --repository-name $image_repo --image-ids "$(aws ecr list-images --repository-name $image_repo --filter tagStatus=UNTAGGED --query 'imageIds[*]')" || true

How can I migrate this to 2.0? I’m trying to mix it with https://github.com/circleci/image-builder/blob/master/.circleci/config.yml but that’s even more confusing with the many Ubuntu XXL things. What is that for?


#2

Yes, if you are a free-tier customer, no if you are a paid customer. For the latter, there is a native layer cache solution that you can request from customer support (see the docs).

To start with though, I would suggest you create a simple config.yml for 2.0 without layer caching, and just get it working to start with. Choose a suitable base image for Docker building (docker:17.05.0-ce-git is what I use) and give it a whirl. If you get stuck, show us what you have, and someone might be able to make suggestions.

That’s at the same level as build, and all of these are just labels for build jobs. You can call them what you like, and in the example you link to, there are several.


#3

Thanks a lot! What about the setup_remote_docker, do I need it? The Ubuntu build image doesn’t have that line, while the official circleci-demo-docker does have it:


#4

If you are doing manual Docker or Compose stuff, you can. See the docs for the purpose of it. If you don’t use it, the Docker command will be run locally. Try it with and without if you like, and consider whether the isolation it provides is useful to you.


#5

If you’re on the free tier, I wrote up some Docker layer caching strategies linked from here.


#6

Yes, free tier. Thanks for you blog post, I’ll go through it soon!


#7

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