Skip to content

Commit

Permalink
Official Docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
jantman committed Aug 26, 2019
1 parent 7189c5a commit c886332
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ matrix:
env: TOXENV=py37
dist: xenial
sudo: true
- python: "3.7"
env: TOXENV=docker
dist: xenial
sudo: true
services:
- docker
- python: "2.7"
env: TOXENV=docs
- python: "2.7"
Expand Down
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

Unreleased Changes
------------------

* `Issue #301 <https://github.com/jantman/awslimitchecker/issues/301>`__ - Distribute an official Docker image for awslimitchecker.

7.0.0 (2019-08-13)
------------------

Expand Down
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM python:3-alpine

ARG git_version

COPY . /awslimitchecker
RUN cd /awslimitchecker && pip install -e .

LABEL org.opencontainers.image.revision=$git_version \
org.opencontainers.image.source="https://github.com/jantman/awslimitchecker.git" \
org.opencontainers.image.url="https://github.com/jantman/awslimitchecker" \
org.opencontainers.image.authors="[email protected]"
5 changes: 5 additions & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sut:
build: .
environment:
AWS_DEFAULT_REGION: us-east-1
command: /usr/local/bin/awslimitchecker --version
55 changes: 55 additions & 0 deletions docker_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash -x

set -x
set -e

if [ -z "$1" ]; then
>&2 echo "USAGE: docker_build.sh [build|dockerbuild|push|dockerbuildtest]"
exit 1
fi

function gettag {
# if it's a build of a tag, return that right away
[ ! -z "$TRAVIS_TAG" ] && { echo $TRAVIS_TAG; return 0; }
# otherwise, prefix with PR number if available
prefix=''
[ ! -z "$TRAVIS_PULL_REQUEST" ] && [[ "$TRAVIS_PULL_REQUEST" != "false" ]] && prefix="PR${TRAVIS_PULL_REQUEST}_"
ref="test_${prefix}$(git rev-parse --short HEAD)_$(date +%s)"
echo "${ref}"
}

function getversion {
python -c 'from awslimitchecker.version import _VERSION; print(_VERSION)'
}

function getbuildurl {
[ ! -z "$TRAVIS_BUILD_WEB_URL" ] && { echo $TRAVIS_BUILD_WEB_URL; return 0; }
echo "local"
}

function dockertoxbuild {
tag=$(gettag)
version=$(getversion)
buildurl=$(getbuildurl)
echo "Building Docker image..."
docker build \
--build-arg git_version="$(git rev-parse --short HEAD)" \
--no-cache \
-t "jantman/awslimitchecker:${tag}" .
echo "Built image and tagged as: jantman/awslimitchecker:${tag}"
}

function dockerbuildtest {
tag=$(gettag)
dockertoxbuild
./dockertest.sh "jantman/awslimitchecker:${tag}"
}

if [[ "$1" == "dockerbuild" ]]; then
dockertoxbuild
elif [[ "$1" == "dockerbuildtest" ]]; then
dockerbuildtest
else
>&2 echo "USAGE: do_docker.sh [dockerbuild|dockerbuildtest]"
exit 1
fi
11 changes: 11 additions & 0 deletions dockertest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash -x

set -x
set -e

if [ -z "$1" ]; then
>&2 echo "USAGE: dockertest.sh repo/image:tag"
exit 1
fi

docker run -it --rm -e AWS_DEFAULT_REGION=us-east-1 "$1" /usr/local/bin/awslimitchecker --version
13 changes: 12 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py27,py34,py35,py36,py37,pypy,pypy3,docs,localdocs,integration,integration3
envlist = py27,py34,py35,py36,py37,pypy,pypy3,docs,localdocs,integration,integration3,docker

[testenv]
deps =
Expand Down Expand Up @@ -165,3 +165,14 @@ basepython = python3.6
sitepackages = False
whitelist_externals = env test
commands = {[testenv:integration]commands}

[testenv:docker]
setenv =
TOXINIDIR={toxinidir}
TOXDISTDIR={distdir}
commands =
python --version
virtualenv --version
pip --version
pip freeze
{toxinidir}/docker_build.sh dockerbuildtest

0 comments on commit c886332

Please sign in to comment.