Skip to content

Commit 3a055a6

Browse files
author
Sean Sundberg
committed
Creates image with tools for working with AWS cloud environment
Signed-off-by: Sean Sundberg <seansund@us.ibm.com>
1 parent 84f8229 commit 3a055a6

8 files changed

Lines changed: 300 additions & 2 deletions

File tree

.github/release-drafter.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name-template: 'v$RESOLVED_VERSION'
2+
tag-template: 'v$RESOLVED_VERSION'
3+
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
4+
categories:
5+
- title: 'Features'
6+
labels:
7+
- 'feature'
8+
- 'enhancement'
9+
- title: 'Bug Fixes'
10+
labels:
11+
- 'fix'
12+
- 'bugfix'
13+
- 'bug'
14+
- title: 'Maintenance'
15+
label: 'chore'
16+
version-resolver:
17+
major:
18+
labels:
19+
- 'major'
20+
minor:
21+
labels:
22+
- 'minor'
23+
patch:
24+
labels:
25+
- 'patch'
26+
default: patch
27+
template: |
28+
$CHANGES
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
name: Docker build
2+
3+
# Controls when the workflow will run
4+
on:
5+
release:
6+
types:
7+
- published
8+
pull_request:
9+
branches:
10+
- main
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
base:
20+
- alpine
21+
- fedora
22+
terraform:
23+
- v1.0
24+
- v1.1
25+
- v1.2
26+
27+
env:
28+
TERRAFORM_LATEST: "v1.2"
29+
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v3
33+
34+
- name: Set up QEMU
35+
uses: docker/setup-qemu-action@v2
36+
37+
- name: Set up Docker Buildx
38+
id: buildx
39+
uses: docker/setup-buildx-action@v2
40+
41+
- name: Login to Docker Hub
42+
uses: docker/login-action@v2
43+
with:
44+
username: ${{ secrets.DOCKER_USER }}
45+
password: ${{ secrets.DOCKER_TOKEN }}
46+
47+
- name: Login to CNTK Quay
48+
uses: docker/login-action@v2
49+
with:
50+
registry: quay.io
51+
username: ${{ secrets.QUAY_CNTK_USERNAME }}
52+
password: ${{ secrets.QUAY_CNTK_TOKEN }}
53+
54+
- name: Setup variables ${{ matrix.base }}:${{ matrix.terraform }}
55+
id: variables
56+
shell: bash
57+
run: |
58+
SHORT_TERRAFORM=${{ matrix.terraform }}
59+
60+
SHORT_TAG_ENABLED="false"
61+
if [[ "${{ matrix.base }}" == "alpine" ]]; then
62+
SHORT_TAG_ENABLED="true"
63+
fi
64+
65+
BASE_ENABLED="false"
66+
LATEST_ENABLED="false"
67+
if [[ "${SHORT_TERRAFORM}" == "${TERRAFORM_LATEST}" ]]; then
68+
BASE_ENABLED="true"
69+
70+
if [[ "${{ matrix.base }}" == "alpine" ]]; then
71+
LATEST_ENABLED="true"
72+
fi
73+
fi
74+
75+
RELEASE_TAG=${GITHUB_REF#refs/tags/}
76+
RELEASE_TAG_ENABLED="false"
77+
RELEASE_TAG_SHORT_ENABLED="false"
78+
if [[ "${GITHUB_REF}" =~ refs/tags ]] && [[ "${RELEASE_TAG}" != "main" ]]; then
79+
RELEASE_TAG_ENABLED="true"
80+
81+
if [[ "${{ matrix.base }}" == "alpine" ]]; then
82+
RELEASE_TAG_SHORT_ENABLED="true"
83+
fi
84+
else
85+
RELEASE_TAG="main"
86+
fi
87+
88+
echo "Short terraform: ${SHORT_TERRAFORM}"
89+
echo "::set-output name=terraform::$SHORT_TERRAFORM"
90+
91+
echo "Short tag enabled: $SHORT_TAG_ENABLED"
92+
echo "::set-output name=short-enabled::$SHORT_TAG_ENABLED"
93+
94+
echo "Release tag: ${RELEASE_TAG}"
95+
echo "::set-output name=release-tag::$RELEASE_TAG"
96+
97+
echo "Release tag enabled: $RELEASE_TAG_ENABLED"
98+
echo "::set-output name=release-tag-enabled::$RELEASE_TAG_ENABLED"
99+
100+
echo "Release tag short enabled: $RELEASE_TAG_SHORT_ENABLED"
101+
echo "::set-output name=release-tag-short-enabled::$RELEASE_TAG_SHORT_ENABLED"
102+
103+
echo "Base enabled: $BASE_ENABLED"
104+
echo "::set-output name=base-enabled::$BASE_ENABLED"
105+
106+
echo "Latest enabled: $LATEST_ENABLED"
107+
echo "::set-output name=latest-enabled::$LATEST_ENABLED"
108+
109+
- name: Docker CNTK meta ${{ matrix.base }}:${{ matrix.terraform }}
110+
id: cntk-meta
111+
uses: docker/metadata-action@v4
112+
with:
113+
# list of Docker images to use as base name for tags
114+
images: |
115+
quay.io/cloudnativetoolkit/cli-tools-core
116+
# Docker tags based on the following events/attributes
117+
tags: |
118+
type=raw,value=${{ steps.variables.outputs.terraform }}-${{ matrix.base }}
119+
type=raw,value=${{ steps.variables.outputs.terraform }},enable=${{ steps.variables.outputs.short-enabled }}
120+
type=raw,value=${{ steps.variables.outputs.terraform }}-${{ steps.variables.outputs.release-tag }}-${{ matrix.base }},enable=${{ steps.variables.outputs.release-tag-enabled }}
121+
type=raw,value=${{ steps.variables.outputs.terraform }}-${{ steps.variables.outputs.release-tag }},enable=${{ steps.variables.outputs.release-tag-short-enabled }}
122+
type=raw,value=${{ matrix.base }},enable=${{ steps.variables.outputs.base-enabled }}
123+
type=raw,value=latest,enable=${{ steps.variables.outputs.latest-enabled }}
124+
125+
- name: Build and push ${{ matrix.base }}:${{ matrix.terraform }}
126+
uses: docker/build-push-action@v3
127+
with:
128+
context: .
129+
file: Dockerfile-${{ matrix.base }}
130+
build-args: |
131+
TERRAFORM_VERSION=${{ matrix.terraform }}
132+
push: ${{ github.event_name != 'pull_request' }}
133+
platforms: linux/amd64,linux/arm64
134+
tags: ${{ steps.cntk-meta.outputs.tags }}
135+
labels: ${{ steps.cntk-meta.outputs.labels }}

.github/workflows/release.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Release module
2+
3+
# Controls when the action will run. Triggers the workflow on push or pull request
4+
# events but only for the master branch
5+
on:
6+
push:
7+
branches: [ main ]
8+
9+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
10+
jobs:
11+
release:
12+
runs-on: ubuntu-latest
13+
14+
# Steps represent a sequence of tasks that will be executed as part of the job
15+
steps:
16+
# Drafts your next Release notes as Pull Requests are merged into "master"
17+
- uses: rlespinasse/github-slug-action@v3.x
18+
19+
- uses: release-drafter/release-drafter@v5
20+
with:
21+
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
22+
config-name: release-drafter.yaml
23+
publish: true
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.iml

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./Dockerfile-alpine

Dockerfile-alpine

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
ARG TERRAFORM_VERSION=v1.2
2+
FROM quay.io/cloudnativetoolkit/cli-tools-core:${TERRAFORM_VERSION}-v1.0.0-alpine
3+
4+
ARG TARGETPLATFORM
5+
6+
## AWS cli
7+
RUN sudo apk add --no-cache \
8+
python3 \
9+
py3-pip \
10+
&& sudo pip3 install --upgrade pip \
11+
&& sudo pip3 install awscli \
12+
&& rm -rf /var/cache/apk/* \
13+
&& aws --version

Dockerfile-fedora

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
ARG TERRAFORM_VERSION=v1.2
2+
FROM quay.io/cloudnativetoolkit/cli-tools-core:${TERRAFORM_VERSION}-v1.0.0-fedora
3+
4+
ARG TARGETPLATFORM
5+
6+
## AWS cli
7+
RUN sudo dnf install -y \
8+
python3 \
9+
python3-pip \
10+
&& sudo pip3 install --upgrade pip \
11+
&& sudo pip3 install awscli \
12+
&& dnf clean all \
13+
&& aws --version

README.md

Lines changed: 84 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,84 @@
1-
# image-cli-tools-aws
2-
Container image that contains tools to interact with AWS cloud environments
1+
# AWS cli-tools image
2+
3+
Container image with tools for interacting with AWS.
4+
5+
This image is built upon [quay.io/cloudnativetoolkit/cli-tools-core](https://quay.io/cloudnativetoolkit/cli-tools-core) which has common tools for interacting with cloud environments, including **terraform**, **terragrunt**, **kubectl** and **oc** clis.
6+
7+
## Contents
8+
9+
This image adds the following:
10+
11+
- aws cli
12+
13+
## Container registry
14+
15+
The build automation pushes the built container image to [quay.io/cloudnativetoolkit/cli-tools-aws](https://quay.io/cloudnativetoolkit/cli-tools-aws)
16+
17+
### Floating tags
18+
19+
The floating image tags use the following convention:
20+
21+
- `latest` - the latest **alpine** version of the image (currently terraform v1.2)
22+
- `alpine` - the latest **alpine** version of the image (currently terraform v1.2)
23+
- `fedora` - the latest **fedora** version of the image (currently terraform v1.2)
24+
- `v1.2` - the latest **alpine** version of the image using terraform v1.2
25+
- `v1.1` - the latest **alpine** version of the image using terraform v1.1
26+
- `v1.0` - the latest **alpine** version of the image using terraform v1.0
27+
- `v1.2-alpine` - the latest **alpine** version of the image using terraform v1.2
28+
- `v1.1-alpine` - the latest **alpine** version of the image using terraform v1.1
29+
- `v1.0-alpine` - the latest **alpine** version of the image using terraform v1.0
30+
- `v1.2-fedora` - the latest **fedora** version of the image using terraform v1.2
31+
- `v1.1-fedora` - the latest **fedora** version of the image using terraform v1.1
32+
- `v1.0-fedora` - the latest **fedora** version of the image using terraform v1.0
33+
34+
### Pinned tags
35+
36+
Each release within the repository corresponds to a pinned image tag that will never be moved to another image. The pinned tags use the following naming convention:
37+
38+
```text
39+
{terraform version}-{release tag}-{base OS image}
40+
```
41+
42+
where:
43+
44+
- `{terraform version}` - is the major and minor version of the terraform cli (e.g. v1.1)
45+
- `{release tag}` - is the release tag for this repository (e.g. v1.0.0)
46+
- `{base OS image}` - is the base OS image (`alpine` or `fedora`)
47+
48+
For example:
49+
50+
```text
51+
v1.1-v1.0.0-alpine
52+
```
53+
54+
## Usage
55+
56+
The image can be used by referring to the image url. The following can be used to run the container image interactively:
57+
58+
```shell
59+
docker run -it quay.io/cloudnativetoolkit/cli-tools-aws
60+
```
61+
62+
## Development
63+
64+
To build the default image using the latest version of terraform on alpine, run the following:
65+
66+
```shell
67+
docker build -t cli-tools-aws .
68+
```
69+
70+
### Changing terraform versions
71+
72+
The terraform version can be changed by passing the `TERRAFORM_VERSION` as a build arg. For example:
73+
74+
```shell
75+
docker build --build-arg TERRAFORM_VERSION=v1.1 -t cli-tools-aws:v1.1 .
76+
```
77+
78+
### Changing base OS versions
79+
80+
The base OS can be changed by using the `Dockerfile-fedora` file. For example:
81+
82+
```shell
83+
docker build -f Dockerfile-fedora -t cli-tools-aws:fedora .
84+
```

0 commit comments

Comments
 (0)