lets make another awscli
This commit is contained in:
Коммит
56adc199b5
|
@ -0,0 +1,3 @@
|
|||
.travis.yml
|
||||
Dockerfile
|
||||
script/**
|
|
@ -0,0 +1 @@
|
|||
# things to ignore
|
|
@ -0,0 +1,16 @@
|
|||
sudo: required
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
|
||||
language: go
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
script:
|
||||
# Standard build
|
||||
- BUILD_ARGS="--no-cache" make build
|
||||
|
||||
after_success:
|
||||
- make push
|
|
@ -0,0 +1,40 @@
|
|||
# Dockerfile for alpine awscli
|
||||
FROM python:3.6.3-alpine3.6
|
||||
|
||||
MAINTAINER Edward Raigosa <wenlock@github.com>
|
||||
|
||||
ARG user=aws
|
||||
ARG group=aws
|
||||
ARG uid=1000
|
||||
ARG gid=1000
|
||||
|
||||
ENV S3_TMP /tmp/s3cmd.zip
|
||||
ENV S3_ZIP /tmp/s3cmd-master
|
||||
ENV RDS_TMP /tmp/RDSCLi.zip
|
||||
ENV RDS_VERSION 1.19.004
|
||||
ENV AWSCLI_VERSION=1.11.189
|
||||
|
||||
USER root
|
||||
RUN set -x -v && apk --no-cache add \
|
||||
bash \
|
||||
bash-completion \
|
||||
less \
|
||||
curl \
|
||||
jq \
|
||||
openssh \
|
||||
&& python3 -m pip install \
|
||||
python-dateutil \
|
||||
awscli===${AWSCLI_VERSION} \
|
||||
&& addgroup -g ${gid} ${group} \
|
||||
&& adduser -h "/home/${user}" -u ${uid} -G ${group} -s /bin/bash -D ${user} \
|
||||
&& mkdir -p "/home/${user}/.aws" \
|
||||
&& chown -R ${user}:${group} "/home/${user}" \
|
||||
&& chmod 755 "/home/${user}" \
|
||||
&& chmod 700 "/home/${user}/.aws"
|
||||
|
||||
USER aws
|
||||
|
||||
WORKDIR "/home/${user}"
|
||||
# Expose volume for adding credentials
|
||||
RUN aws --version
|
||||
CMD ["/bin/bash", "--login"]
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License
|
||||
|
||||
Copyright (c) 2017 Edward Raigosa & GitHub Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
|
@ -0,0 +1,36 @@
|
|||
SHELL := /bin/bash
|
||||
APP_ROOT ?= $(shell pwd)
|
||||
VERSION ?= $(shell cat "$(APP_ROOT)/VERSION")
|
||||
DOCKER_IMAGE ?= wenlock/awscli
|
||||
TRAVIS_BRANCH ?=
|
||||
DOCKER_USERNAME ?=
|
||||
DOCKER_PASSWORD ?=
|
||||
|
||||
ifneq ($(http_proxy),)
|
||||
BUILD_ARGS := $(BUILD_ARGS) --build-arg http_proxy=$(http_proxy)
|
||||
endif
|
||||
ifneq ($(https_proxy),)
|
||||
BUILD_ARGS := $(BUILD_ARGS) --build-arg https_proxy=$(http_proxy)
|
||||
endif
|
||||
ifneq ($(no_proxy),)
|
||||
BUILD_ARGS := $(BUILD_ARGS) --build-arg no_proxy=$(no_proxy)
|
||||
endif
|
||||
|
||||
|
||||
default: build
|
||||
|
||||
.PHONY: build push
|
||||
|
||||
build:
|
||||
BUILD_ARGS=$(BUILD_ARGS) \
|
||||
DOCKER_IMAGE=$(DOCKER_IMAGE) \
|
||||
VERSION=$(VERSION) \
|
||||
$(APP_ROOT)/script/build
|
||||
|
||||
push:
|
||||
DOCKER_USERNAME=$(DOCKER_USERNAME) \
|
||||
DOCKER_PASSWORD=$(DOCKER_PASSWORD) \
|
||||
TRAVIS_BRANCH=$(TRAVIS_BRANCH) \
|
||||
DOCKER_IMAGE=$(DOCKER_IMAGE) \
|
||||
VERSION=$(VERSION) \
|
||||
$(APP_ROOT)/script/docker-push
|
|
@ -0,0 +1,46 @@
|
|||
# Another awscli
|
||||
|
||||
Lets build another aws cli tool for docker so we can hack. :tada:
|
||||
|
||||
## Using the image
|
||||
Here is some instructions on how to use it.
|
||||
|
||||
### Setup a function
|
||||
This works in bash
|
||||
|
||||
```bash
|
||||
function awscli {
|
||||
export AWS_CLI_IMAGE="${AWS_CLI_IMAGE:-wenlock/awscli}"
|
||||
docker run -it --rm -e AWS_ACCESS_KEY_ID \
|
||||
-e AWS_SECRET_ACCESS_KEY \
|
||||
-e AWS_DEFAULT_REGION \
|
||||
${AWS_CLI_IMAGE} aws $@
|
||||
}
|
||||
```
|
||||
|
||||
Don't like the `latest` version, just set `export AWS_CLI_IMAGE=wenlock/awscli:1.11.189`.
|
||||
We'll get the aws version you ask for.
|
||||
|
||||
### Setup credentials with environment vars
|
||||
|
||||
```bash
|
||||
export AWS_ACCESS_KEY_ID=aaaabbbbbb
|
||||
export AWS_SECRET_ACCESS_KEY=xxxxxxxxxx
|
||||
export AWS_DEFAULT_REGION=us-east-1
|
||||
```
|
||||
|
||||
### Use it
|
||||
|
||||
For example:
|
||||
|
||||
`eval $(aws ecr get-login)`
|
||||
|
||||
## Contributing to awscli
|
||||
|
||||
Want to help me, wow cool!
|
||||
|
||||
Fork this repo and submit a PR :D
|
||||
|
||||
|
||||
## Licensing
|
||||
[MIT](LICENSE.txt)
|
|
@ -0,0 +1 @@
|
|||
1.11.189
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
APP_ROOT="${APP_ROOT:-$(git rev-parse --show-toplevel)}"
|
||||
BUILD_ARGS="${BUILD_ARGS:-}"
|
||||
DOCKER_IMAGE="${DOCKER_IMAGE:-wenlock/awscli}"
|
||||
VERSION="${VERSION:-0.0.1}"
|
||||
DOCKER_REMOTE_CONFIG="${DOCKER_REMOTE_CONFIG:-}"
|
||||
|
||||
|
||||
|
||||
echo "==> building ${DOCKER_IMAGE}:${VERSION}"
|
||||
eval "docker ${DOCKER_REMOTE_CONFIG} \
|
||||
build ${BUILD_ARGS} -f \"${APP_ROOT}/Dockerfile\" \
|
||||
--tag \"${DOCKER_IMAGE}:${VERSION}\" ${APP_ROOT}"
|
||||
docker tag "${DOCKER_IMAGE}:${VERSION}" "${DOCKER_IMAGE}:latest"
|
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
APP_ROOT="${APP_ROOT:-$(git rev-parse --show-toplevel)}"
|
||||
DOCKER_IMAGE="${DOCKER_IMAGE:-wenlock/awscli}"
|
||||
VERSION="${VERSION:-0.0.1}"
|
||||
DOCKER_REMOTE_CONFIG="${DOCKER_REMOTE_CONFIG:-}"
|
||||
TRAVIS_BRANCH="${TRAVIS_BRANCH:-}"
|
||||
|
||||
if docker login -u="${DOCKER_USERNAME}" -p="${DOCKER_PASSWORD}" > /dev/null 2<&1; then
|
||||
echo "==> pushing ${DOCKER_IMAGE}:${VERSION}"
|
||||
eval "docker ${DOCKER_REMOTE_CONFIG} \
|
||||
push \
|
||||
\"${DOCKER_IMAGE}:${VERSION}\""
|
||||
|
||||
if [ "$TRAVIS_BRANCH" == "master" ]; then
|
||||
echo "==> pushing ${DOCKER_IMAGE}:latest"
|
||||
eval "docker ${DOCKER_REMOTE_CONFIG} \
|
||||
push \
|
||||
\"${DOCKER_IMAGE}:latest\""
|
||||
fi
|
||||
else
|
||||
echo "==> skipping image push, no login"
|
||||
fi
|
Загрузка…
Ссылка в новой задаче