Make Circle respect Docker image's entrypoint

I’m running tests in a custom Docker image with Circle’s Docker executor.

My Docker image has this entrypoint in its Dockerfile.

ENTRYPOINT ["/usr/local/bin/activate.sh"]

All this entrypoint script does is start Postgres and source a Python virtualenv.

I want the test execution to respect this entrypoint. Circle docs say

For primary container (listed first in the list) if no command is specified then command and image entrypoint will be ignored

These two .circleci/config.yml don’t work.

  build:
    docker:
    - image: freelawproject/courtlistener-testing:0.1.0
      entrypoint: /usr/local/bin/activate.sh
    steps:
    - checkout
    - run: rm -fr /var/www/courtlistener
    - run: mv ~/project /var/www/courtlistener
    - run: cp /var/www/courtlistener/cl/settings/05-private.example /var/www/courtlistener/cl/settings/05-private.py
    - run: pytest /var/www/courtlistener/cl/corpus_importer/tests.py

Results in failure: pytest command not found.

    docker:
    - image: freelawproject/courtlistener-testing:0.1.0
      command: while true; do date; sleep 60; done
    steps:
    - checkout
    - run: rm -fr /var/www/courtlistener
    - run: mv ~/project /var/www/courtlistener
    - run: cp /var/www/courtlistener/cl/settings/05-private.example /var/www/courtlistener/cl/settings/05-private.py
    - run: pytest /var/www/courtlistener/cl/corpus_importer/tests.py

Results in failure: Consider clearing entrypoint/command values and try again.

Only this worked.

    docker:
    - image: freelawproject/courtlistener-testing:0.1.0
    steps:
    - checkout
    - run: rm -fr /var/www/courtlistener
    - run: mv ~/project /var/www/courtlistener
    - run: cp /var/www/courtlistener/cl/settings/05-private.example /var/www/courtlistener/cl/settings/05-private.py
    - run: /etc/init.d/postgresql start
    - run: source /var/www/.virtualenvs/courtlistener/bin/activate && pytest /var/www/courtlistener/cl/corpus_importer/tests.py

But I don’t like this last approach because it’s not DRY. What config do I need to make the Dockerfile’s ENTRYPOINT work?

Thanks,

I would go with the latest approach, on the basis that the image you are using might have an entrypoint that would be overwritten (or might have one in the future).

I don’t see this as being particularly not DRY - though I suppose you could make an env var for /var/www/courtlistener and use that in your commands.

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