docker build -t s3cmd-tests --build-arg pyVersion=3.6 -f run-tests.dockerfile .
docker run --rm s3cmd-tests
The included run-tests.dockerfile allows contributors to easily test their changes with Python versions that aren't installed locally.
Docker must, of course, be installed on your system if it is not already. See https://docs.docker.com/install/ for instructions.
To begin, build the Dockerfile into an image for the Python version you wish to test against. The build must be repeated whenever your source changes, but the Python image itself will be cached. To build:
Place a valid .s3cfg file in the root project directory. While .s3cfg has been added to the .gitignore to avoid sending your credentials to public repositories, you should still make sure you remove it when your testing is complete.
Run docker build -t s3cmd-tests -f run-tests.dockerfile .
(the trailing period is required)
This will:
The main purpose of this Dockerfile is to allow you to run with multiple Python versions. To see the Docker Python images available, visit Docker Hub. Most of the Linux variants should be usable, but the "alpine" variants will result in the smallest downloads and images. For example:
docker build -t s3cmd-tests --build-arg pyVersion=3.8.1-alpine3.11 -f run-tests.dockerfile .
After successfully building the image, you can run it with docker run --rm s3cmd-tests
. This will execute the run-tests.py script in the Docker container with your .s3cfg credentials.
Normal run-tests.py
options may appended. For example:
docker run --rm s3cmd-tests --bucket-prefix mytests
Additional notes:
docker run -i -t --rm --entrypoint sh s3cmd-tests
.
bash
may be specified if you are using a Python image that supports it (not Alpine).docker pull python
or docker pull python:3.7
(substituting your desired version)docker images
to show all the images on your system, and docker image prune
to cleanup unused, untagged images. Please use this command carefully if you have other Docker images on your system.docker rmi python:3.7
, substituting the tag/version you wish to remove. docker images
will list the images on your system.