Skip to content

Commit c6e3896

Browse files
first commit
0 parents  commit c6e3896

File tree

9 files changed

+144
-0
lines changed

9 files changed

+144
-0
lines changed

.github/workflows/build.yml

Lines changed: 47 additions & 0 deletions
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

Lines changed: 31 additions & 0 deletions
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

.gitignore

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

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"conventionalCommits.scopes": [
3+
]
4+
}

Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM python:3.11.5-slim-bookworm
2+
3+
LABEL org.opencontainers.image.source https://github.com/Container-Driven-Development/Python-Base
4+
LABEL org.opencontainers.image.description "Base image for Python scripts exporting AWS resources using boto library to Prometheus"
5+
6+
ENTRYPOINT ["/usr/local/bin/python"]
7+
8+
ADD requirements.txt /requirements.txt
9+
10+
RUN ["pip", "install", "--no-cache-dir", "-r", "/requirements.txt"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 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.

Makefile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
test:
2+
helm upgrade --install --debug -n customer-monitoring-system --set-file script_py=./examples/s3-metrics.py -f ./tmp/values.test.yaml s3-metrics ./helm
3+
4+
test_cleanup:
5+
helm uninstall -n customer-monitoring-system s3-metrics
6+
7+
template:
8+
helm template --debug --output-dir=./tmp/ -n customer-monitoring-system --set-file script_py=./examples/s3-metrics.py -f ./tmp/values.test.yaml s3-metrics ./helm
9+
10+
chart_release:
11+
git checkout gh-pages
12+
git merge main
13+
git commit -m "merged"
14+
git push
15+
helm package ./helm
16+
helm repo index .
17+
git add .
18+
git commit -m "update chart"
19+
git push origin gh-pages
20+
git checkout main
21+
22+
.PHONY: test template chart_release

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Python-Base
2+
3+
Base image for Python scripts

requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
boto3==1.28.19
2+
prometheus_client==0.17.1
3+
python_json_logger==2.0.7
4+
watchdog==3.0.0
5+
requests==2.30.0

0 commit comments

Comments
 (0)