Skip to content

Commit c68b37c

Browse files
feat: 🎉 initial commit
Signed-off-by: Mario Vejlupek <[email protected]>
1 parent d422149 commit c68b37c

File tree

6 files changed

+129
-0
lines changed

6 files changed

+129
-0
lines changed

.github/workflows/build.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# NOTES:
2+
# 1. Create PAT with `read:packages` and `write:packages` see https://docs.github.com/en/free-pro-team@latest/packages/guides/migrating-to-github-container-registry-for-docker-images#authenticating-with-the-container-registry
3+
# 2. Create CR_PAT variable under Settings / Secrets
4+
5+
name: BUILD
6+
7+
on:
8+
push:
9+
# Publish `v1.2.3` tags as releases.
10+
tags:
11+
- v*
12+
13+
env:
14+
FETCHER_IMAGE_VERSION: ""
15+
BASE_IMAGE_VERSION: ""
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- uses: actions/checkout@v2
23+
24+
- name: Run build
25+
run: |
26+
IMAGE_NAME=ghcr.io/$(echo "${{ github.repository }}" | tr '[A-Z]' '[a-z]' )
27+
# Strip git ref prefix from version
28+
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
29+
docker build . \
30+
--build-arg FETCHER_IMAGE_VERSION=${FETCHER_IMAGE_VERSION} \
31+
--build-arg BASE_IMAGE_VERSION=${BASE_IMAGE_VERSION} \
32+
--file Dockerfile --tag $IMAGE_NAME:$VERSION
33+
34+
- name: Log into GitHub Container Registry
35+
run: echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
36+
37+
- name: Push image to GitHub Container Registry
38+
run: |
39+
IMAGE_NAME=ghcr.io/$(echo "${{ github.repository }}" | tr '[A-Z]' '[a-z]' )
40+
# Strip git ref prefix from version
41+
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
42+
echo IMAGE_NAME=$IMAGE_NAME
43+
echo VERSION=$VERSION
44+
docker push $IMAGE_NAME:$VERSION
45+
# Push latest as well for caching purposes
46+
docker tag $IMAGE_NAME:$VERSION $IMAGE_NAME:latest
47+
docker push $IMAGE_NAME:latest

.github/workflows/test.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# TODO:
2+
# 1. Create PAT with `read:packages` and `write:packages` see https://docs.github.com/en/free-pro-team@latest/packages/guides/migrating-to-github-container-registry-for-docker-images#authenticating-with-the-container-registry
3+
# 2. Create CR_PAT variable under Settings / Secrets
4+
5+
name: TEST
6+
7+
on:
8+
push:
9+
branches:
10+
- main
11+
12+
env:
13+
FETCHER_IMAGE_VERSION: ""
14+
BASE_IMAGE_VERSION: ""
15+
16+
# NOTE: DO NOT CHANGE THIS THIS IS TMP IMAGE NAME
17+
IMAGE_NAME: image
18+
19+
jobs:
20+
test:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@v2
25+
26+
- name: Run tests
27+
run: |
28+
docker build . \
29+
--build-arg FETCHER_IMAGE_VERSION=${FETCHER_IMAGE_VERSION} \
30+
--build-arg BASE_IMAGE_VERSION=${BASE_IMAGE_VERSION} \
31+
--file Dockerfile --tag $IMAGE_NAME

.vscode/settings.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"conventionalCommits.scopes": [
3+
"Dockerfile"
4+
]
5+
}

Dockerfile

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
ARG ALPINE_VERSION=3.16
2+
FROM python:3.10.5-alpine${ALPINE_VERSION} as builder
3+
4+
ARG AWS_CLI_VERSION=2.7.20
5+
RUN apk add --no-cache git unzip groff build-base libffi-dev cmake
6+
RUN git clone --single-branch --depth 1 -b ${AWS_CLI_VERSION} https://github.com/aws/aws-cli.git
7+
8+
WORKDIR aws-cli
9+
RUN sed -i'' 's/PyInstaller.*/PyInstaller==5.2/g' requirements-build.txt
10+
RUN python -m venv venv
11+
RUN . venv/bin/activate
12+
RUN scripts/installers/make-exe
13+
RUN unzip -q dist/awscli-exe.zip
14+
RUN aws/install --bin-dir /aws-cli-bin
15+
RUN /aws-cli-bin/aws --version
16+
17+
# reduce image size: remove autocomplete and examples
18+
RUN rm -rf /usr/local/aws-cli/v2/current/dist/aws_completer /usr/local/aws-cli/v2/current/dist/awscli/data/ac.index /usr/local/aws-cli/v2/current/dist/awscli/examples
19+
RUN find /usr/local/aws-cli/v2/current/dist/awscli/botocore/data -name examples-1.json -delete
20+
21+
# build the final image
22+
FROM registry.gitlab.com/gitlab-org/terraform-images/branches/v0-41-0-1.2:396db5b5b4341d2b7820c0f39246890b08888a3b
23+
COPY --from=builder /usr/local/aws-cli/ /usr/local/aws-cli/
24+
COPY --from=builder /aws-cli-bin/ /usr/local/bin/

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Container Driven Development
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# gitlab-terraform-aws-cli-v2
2+
23
Terraform AWS setup based on this answer https://stackoverflow.com/a/61268529/358100

0 commit comments

Comments
 (0)