Skip to content

Commit

Permalink
Add Docker build to Travis cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
rye committed Mar 1, 2017
1 parent 1d52960 commit 17718fd
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 45 deletions.
10 changes: 7 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ install:

script:
- tox
- docker build -t stodevx/cs251-toolkit:`script/pick-docker-tag 2>/dev/null` .

deploy:
- provider: pypi
Expand Down Expand Up @@ -47,6 +46,11 @@ after_success:
fi

- if [[ $TRAVIS_PYTHON_VERSION == "3.6" ]]; then
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD";
docker push stodevx/cs251-toolkit:`script/pick-docker-tag 2>/dev/null`;
tag_to_build=`script/pick-docker-tag 2>/dev/null`;
if [[ -z "$tag_to_build" ]];
then
echo "No tag to build. I'm sad now.";
else
docker build -t docker push stodevx/cs251-toolkit:$tag_to_build .;
fi
fi
29 changes: 16 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,16 +277,18 @@ grading arguments:

`--workers` controls the amount of parallelization. It defaults to the number of cores in your machine. `-w1` will disable the process pool entirely, which is helpful for debugging.

## Docker Info (in progress)
## Docker Info

With [#9](https://github.com/StoDevX/cs251-toolkit/issues/9), we've started converting this project into a Docker image.
This will make setting it up quite a bit easier.
Right now, we don't have a place for you to pull the built image from, so you still have to clone this repository and build it yourself.

To do this, first make sure you have [Docker](https://www.docker.com/products/overview#/install_the_platform) installed.
We have made a Docker Image for this project, which will make setting it up quite a bit easier.
To set up the project, please first make sure you have [Docker](https://www.docker.com/products/overview#/install_the_platform) installed.
Follow your particular operating system's instructions to set it up if you haven't already.

To build,
To pull the latest image of the `master` branch from Docker, (what you should probably do by default)
```console
$ docker pull stodevx/cs251-toolkit:HEAD
```

To build from source,

```console
$ # within this repository, run:
Expand All @@ -295,18 +297,19 @@ $ # e.g.:
$ docker build -t stodevx/cs251-toolkit:v0.0.0 .
```

Technically, you don't need to supply a version, and you can pick whatever tag name you want. It's conventional to use `stodevx/cs251-toolkit`, since that's the basis of our GitHub repository, but you can do whatever for your machine.
Technically, you don't need to supply a version, and you can pick whatever tag name you want. It's conventional to use `stodevx/cs251-toolkit:HEAD`, since that's what `script/run-docker` does.

To run,

```console
$ # anywhere, run:
$ docker run -it <tag name>:<version> <command, args>
$ # e.g.:
$ docker run -it stodevx/cs251-toolkit:v0.0.0 .
$ # from within the project directory---technically, you can call from any directory
$ script/run-docker <command>
$ # e.g.
$ script/run-docker cs251tk --record hw1
```

Again, tag name and version should match what you built. If you supplied a version and you have multiple images on your system, Docker should intelligently figure out the latest version as long as you followed semantic versioning.
Again, tag name and version should match what you built or pulled.
If you supplied a version and you have multiple images on your system, Docker should intelligently figure out the latest version as long as you followed semantic versioning.

## Contributing
- `git clone https://github.com/StoDevX/cs251-toolkit`
Expand Down
45 changes: 16 additions & 29 deletions script/pick-docker-tag
Original file line number Diff line number Diff line change
@@ -1,39 +1,26 @@
#!/bin/sh

if latest_tag=`git describe --abbrev=0 --tags HEAD 2>&1`;
then
>&2 echo "latest: $latest_tag"
else
>&2 echo "no latest"
fi

if on_tag=`git describe --exact-match --tags HEAD 2>/dev/null`;
then
>&2 echo "on: $on_tag"
else
>&2 echo "not on"
fi
>&2 echo "env: `env`"

if branch=`git rev-parse --abbrev-ref HEAD`;
if [ -z "$TRAVIS_TAG" ];
then
>&2 echo "branch: $branch"
else
>&2 echo "no branch"
fi

if [[ "${branch}" == "HEAD" ]];
then
if [ -z "$on_tag" ];
if [ "$TRAVIS_BRANCH" = "master" ];
then
echo "HEAD"
if [ "$TRAVIS_PULL_REQUEST" = "false" ];
then
>&2 echo "commit to master, building HEAD tag..."
echo "HEAD"
else
>&2 echo "commit to master but this is a PR. let's not get ahead of ourselves."
fi
else
echo "$on_tag"
>&2 echo "commit to branch other than master. whatever, dude."
fi

else
if [[ "${branch}" == "master" ]];
then
echo "HEAD"
else
echo "$branch"
fi

>&2 echo "building a tag."
echo "$TRAVIS_TAG"

fi

0 comments on commit 17718fd

Please sign in to comment.