Compare commits
23 Commits
Author | SHA1 | Date | |
---|---|---|---|
70ab7aa80d | |||
53148b13e9 | |||
17619fe844 | |||
1b60aaab69 | |||
24c0f309a8 | |||
00e92ce73c | |||
92afc86488 | |||
425544a9e2 | |||
b7b8c1cc43 | |||
fe5505f5bb | |||
c09ac19197 | |||
3fd7e42cf1 | |||
03978ae7ca | |||
05bda1c7a6 | |||
aac8445456 | |||
556ee2952c | |||
795c9cdd5f | |||
c6819fad58 | |||
b7aeed6996 | |||
775f388990 | |||
ebc3a8886b | |||
42cd5492ad | |||
8c4c43e20c |
15
.gitea/workflows/test.yaml
Normal file
15
.gitea/workflows/test.yaml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
name: Run tests wf
|
||||||
|
on:
|
||||||
|
registry_package:
|
||||||
|
types: [published, updated]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-process:
|
||||||
|
runs-on: alt-sisyphus
|
||||||
|
steps:
|
||||||
|
- name: Check event
|
||||||
|
run: |
|
||||||
|
echo "name package = ${{ github.event.registry_package.name }}"
|
||||||
|
echo "path package = ${{ github.event.registry_package.html_url }}"
|
||||||
|
echo "version package = ${{ github.event.registry_package.package_version.version }}"
|
||||||
|
echo "version package = ${{ github.event.registry_package.package_version.container_metadata.tag.name }}"
|
@ -11,15 +11,16 @@ ORG=${2:-"base"}
|
|||||||
URL=${3:-"gitea.basealt.ru"}
|
URL=${3:-"gitea.basealt.ru"}
|
||||||
REPO=${4:-"alt"}
|
REPO=${4:-"alt"}
|
||||||
WS=${5:-"image-forge"}
|
WS=${5:-"image-forge"}
|
||||||
|
wspath="/workspace/$REPO/$WS"
|
||||||
|
|
||||||
errors=''
|
errors=''
|
||||||
haserr=false
|
haserr=false
|
||||||
for IM in $(ls $WS/org/$ORG/ | xargs)
|
for IM in $(ls $wspath/org/$ORG/ | xargs)
|
||||||
do
|
do
|
||||||
echo "image=$IM"
|
echo "image=$IM"
|
||||||
imgpath="$REPO/$WS/$BR/$IM:$BR"
|
imgpath="$REPO/$BR/$ORG/$IM:$BR"
|
||||||
command=''
|
command=''
|
||||||
testpath="$WS/org/$ORG/$IM/test.yaml"
|
testpath="$wspath/org/$ORG/$IM/test.yaml"
|
||||||
if test -f $testpath
|
if test -f $testpath
|
||||||
then
|
then
|
||||||
entrypoint=''
|
entrypoint=''
|
||||||
@ -48,14 +49,15 @@ do
|
|||||||
else
|
else
|
||||||
echo "not found package name in images labels"
|
echo "not found package name in images labels"
|
||||||
fi
|
fi
|
||||||
else
|
else tag=$(date +"%Y%m%d")
|
||||||
then tag=$(date +"%Y%m%d")
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $tag != '' ]]
|
if [[ $tag != '' ]]
|
||||||
then
|
then
|
||||||
skopeo copy -a docker://$URL/$imgpath:$BR docker://$URL/$imgpath:$tag
|
echo "newtag=$tag"
|
||||||
scopeo delete docker://$URL/$imgpath:$BR
|
newimgpath="$REPO/$BR/$ORG/$IM:$tag"
|
||||||
|
skopeo copy -a docker://$URL/$imgpath docker://$URL/$newimgpath
|
||||||
|
#skopeo delete docker://$URL/$imgpath
|
||||||
echo "tag is updated"
|
echo "tag is updated"
|
||||||
else echo "new tag is empty and is not sent to repository"
|
else echo "new tag is empty and is not sent to repository"
|
||||||
fi
|
fi
|
||||||
@ -70,7 +72,6 @@ do
|
|||||||
echo "podman rmi --all"
|
echo "podman rmi --all"
|
||||||
podman rmi --all
|
podman rmi --all
|
||||||
|
|
||||||
fi
|
|
||||||
haserr=false
|
haserr=false
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ jobs:
|
|||||||
org: ${{ env.ORG }}
|
org: ${{ env.ORG }}
|
||||||
url: ${{ env.URL }}
|
url: ${{ env.URL }}
|
||||||
repo: ${{ env.REPO }}
|
repo: ${{ env.REPO }}
|
||||||
|
ws: ${{ env.WS }}
|
||||||
buildres: ${{ steps.build-script.outcome }}
|
buildres: ${{ steps.build-script.outcome }}
|
||||||
steps:
|
steps:
|
||||||
- name: Check workspace
|
- name: Check workspace
|
||||||
@ -25,6 +26,9 @@ jobs:
|
|||||||
reponame=$(echo $GR | cut -d '/' -f 1)
|
reponame=$(echo $GR | cut -d '/' -f 1)
|
||||||
echo "REPO=$reponame" >> ${GITHUB_ENV}
|
echo "REPO=$reponame" >> ${GITHUB_ENV}
|
||||||
echo $reponame
|
echo $reponame
|
||||||
|
repows=$(echo $GR | cut -d '/' -f 2)
|
||||||
|
echo "WS=$repows" >> ${GITHUB_ENV}
|
||||||
|
echo $repows
|
||||||
env:
|
env:
|
||||||
GU: ${{ gitea.server_url }}
|
GU: ${{ gitea.server_url }}
|
||||||
GR: ${{ gitea.repository }}
|
GR: ${{ gitea.repository }}
|
||||||
@ -64,52 +68,57 @@ jobs:
|
|||||||
- name: Run standart building script
|
- name: Run standart building script
|
||||||
id: build-script
|
id: build-script
|
||||||
run: |
|
run: |
|
||||||
build_args="-b $BR -o $ORG --skip-images base/distroless-devel --overwrite-organization $BR --registry $URL/${{ gitea.workspace }}/$BR"
|
build_args="-b $BR -o $ORG --skip-images base/distroless-devel --registry $URL/$REPO/$BR -a amd64"
|
||||||
echo "build.py $build_args"
|
echo "build.py $build_args"
|
||||||
${{ gitea.workspace }}/build.py $build_args
|
${{ gitea.workspace }}/build.py $build_args
|
||||||
env:
|
env:
|
||||||
ORG: ${{ env.ORG }}
|
ORG: ${{ env.ORG }}
|
||||||
BR: ${{ env.BRANCH }}
|
BR: ${{ env.BRANCH }}
|
||||||
|
REPO: ${{ env.REPO }}
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
- name: Send notification if build crashed
|
- name: Send notification if build crashed
|
||||||
if: ${{ steps.build-script.outcome != 'success' }}
|
if: ${{ steps.build-script.outcome != 'success' }}
|
||||||
run: |
|
run: |
|
||||||
issueid=1
|
issueid=1
|
||||||
body="Building images finish with some errors."
|
body="Building images finish with some errors."
|
||||||
curl -X 'POST' "$URL/api/v1/repos/$REPO/image-forge/issues/$issueid/comments?token=$T" -H 'accept: application/json' -H 'Content-Type: application/json' -d "{ \"body\": \"$body\" }" -s
|
curl -X 'POST' "$URL/api/v1/repos/$REPO/$GWS/issues/$issueid/comments?token=$T" -H 'accept: application/json' -H 'Content-Type: application/json' -d "{ \"body\": \"$body\" }" -s
|
||||||
echo "notification about test error is sent to issue $issueid"
|
echo "notification about test error is sent to issue $issueid"
|
||||||
env:
|
env:
|
||||||
T: ${{ secrets.TOKEN }}
|
T: ${{ secrets.TOKEN }}
|
||||||
BR: ${{ env.BRANCH }}
|
BR: ${{ env.BRANCH }}
|
||||||
URL: ${{ gitea.server_url }}
|
URL: ${{ gitea.server_url }}
|
||||||
REPO: ${{ env.REPO }}
|
REPO: ${{ env.REPO }}
|
||||||
|
GWS: ${{ env.WS }}
|
||||||
- name: Delete event tag
|
- name: Delete event tag
|
||||||
run: |
|
run: |
|
||||||
tagname=$(echo $EV | jq '.ref' -r | sed "s/refs\/tags\///g")
|
tagname=$(echo $EV | jq '.ref' -r | sed "s/refs\/tags\///g")
|
||||||
curl -X 'DELETE' "$URL/api/v1/repos/$REPO/image-forge/tags/$tagname?token=$T" -H 'accept: application/json' -s
|
curl -X 'DELETE' "$URL/api/v1/repos/$REPO/$GWS/tags/$tagname?token=$T" -H 'accept: application/json' -s
|
||||||
echo "tag $tagname is deleted"
|
echo "tag $tagname is deleted"
|
||||||
env:
|
env:
|
||||||
T: ${{ secrets.TOKEN }}
|
T: ${{ secrets.TOKEN }}
|
||||||
BR: ${{ env.BRANCH }}
|
BR: ${{ env.BRANCH }}
|
||||||
URL: ${{ gitea.server_url }}
|
URL: ${{ gitea.server_url }}
|
||||||
REPO: ${{ env.REPO }}
|
REPO: ${{ env.REPO }}
|
||||||
|
GWS: ${{ env.WS }}
|
||||||
EV: ${{ toJson(gitea.event) }}
|
EV: ${{ toJson(gitea.event) }}
|
||||||
test-process:
|
test-process:
|
||||||
needs: build-process
|
needs: build-process
|
||||||
if: ${{ needs.build-process.outputs.buildres == 'success' }}
|
if: ${{ needs.build-process.outputs.buildres == 'success' }}
|
||||||
runs-on: alt-p10
|
runs-on: alt-p10
|
||||||
|
outputs:
|
||||||
|
testres: ${{ steps.test-script.outcome }}
|
||||||
steps:
|
steps:
|
||||||
- name: Update apt
|
- name: Update apt
|
||||||
uses: actions/init-alt-env@v1
|
uses: actions/init-alt-env@v1
|
||||||
- name: Install requires
|
- name: Install requires
|
||||||
run: |
|
run: |
|
||||||
echo "apt-get install -y python3-module-tomli python3-module-jinja2 podman buildah skopeo jq yq curl"
|
echo "apt-get install -y python3-module-tomli python3-module-jinja2 podman buildah skopeo jq yq curl"
|
||||||
apt-get install -y python3-module-tomli python3-module-jinja2 podman buildah jq curl
|
apt-get install -y python3-module-tomli python3-module-jinja2 podman buildah skopeo jq yq curl
|
||||||
- name: Check out current repo
|
- name: Check out current repo
|
||||||
uses: https://gitea.com/actions/checkout@v4
|
uses: https://gitea.com/actions/checkout@v4
|
||||||
- name: Login podman gitea
|
- name: Login podman gitea
|
||||||
run: |
|
run: |
|
||||||
echo "podman login ${{ env.URL }}"
|
echo "podman login ${{ needs.build-process.outputs.url }}"
|
||||||
podman login --username $P_USER --password $P_PASS ${{ needs.build-process.outputs.url }}
|
podman login --username $P_USER --password $P_PASS ${{ needs.build-process.outputs.url }}
|
||||||
env:
|
env:
|
||||||
P_USER: ${{ secrets.PODMAN_USER }}
|
P_USER: ${{ secrets.PODMAN_USER }}
|
||||||
@ -118,7 +127,7 @@ jobs:
|
|||||||
id: test-script
|
id: test-script
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
run: |
|
run: |
|
||||||
$WS/.gitea/workflows/testscript $BR $ORG $URL $REPO $WS
|
$WS/.gitea/workflows/testscript $BR $ORG $URL $REPO $GWS
|
||||||
cat haserr.log >> ${GITHUB_ENV}
|
cat haserr.log >> ${GITHUB_ENV}
|
||||||
echo "test process finished"
|
echo "test process finished"
|
||||||
env:
|
env:
|
||||||
@ -127,16 +136,60 @@ jobs:
|
|||||||
URL: ${{ needs.build-process.outputs.url }}
|
URL: ${{ needs.build-process.outputs.url }}
|
||||||
REPO: ${{ needs.build-process.outputs.repo }}
|
REPO: ${{ needs.build-process.outputs.repo }}
|
||||||
WS: ${{ gitea.workspace }}
|
WS: ${{ gitea.workspace }}
|
||||||
|
GWS: ${{ needs.build-process.outputs.ws }}
|
||||||
- name: Send notification if test crashed
|
- name: Send notification if test crashed
|
||||||
if: ${{ env.ERR == 'true' || steps.test-script.outcome == 'failure' }}
|
if: ${{ env.ERR == 'true' || steps.test-script.outcome == 'failure' }}
|
||||||
run: |
|
run: |
|
||||||
issueid=1
|
issueid=1
|
||||||
errors=$(cat errors.log)
|
d errors=$(cat errors.log)
|
||||||
body="Testing images finish with some errors. $errors"
|
body="Testing images finish with some errors. $errors"
|
||||||
curl -X 'POST' "$URL/api/v1/repos/$REPO/image-forge/issues/$issueid/comments?token=$T" -H 'accept: application/json' -H 'Content-Type: application/json' -d "{ \"body\": \"$body\" }" -s
|
curl -X 'POST' "$URL/api/v1/repos/$REPO/gitea-image-forge/issues/$issueid/comments?token=$T" -H 'accept: application/json' -H 'Content-Type: application/json' -d "{ \"body\": \"$body\" }" -s
|
||||||
echo "notification about test error is sent to issue $issueid"
|
echo "notification about test error is sent to issue $issueid"
|
||||||
env:
|
env:
|
||||||
T: ${{ secrets.TOKEN }}
|
T: ${{ secrets.TOKEN }}
|
||||||
BR: ${{ needs.build-process.outputs.branch }}
|
BR: ${{ needs.build-process.outputs.branch }}
|
||||||
URL: ${{ gitea.server_url }}
|
URL: ${{ gitea.server_url }}
|
||||||
REPO: ${{ needs.build-process.outputs.repo }}
|
REPO: ${{ needs.build-process.outputs.repo }}
|
||||||
|
push-process:
|
||||||
|
needs: [build-process, test-process]
|
||||||
|
if: ${{ needs.test-process.outputs.testres == 'success' && secrets.PUSH_REPO != '' }}
|
||||||
|
runs-on: alt-p10
|
||||||
|
steps:
|
||||||
|
- name: Update apt
|
||||||
|
uses: actions/init-alt-env@v1
|
||||||
|
- name: Install reqier-s
|
||||||
|
run: |
|
||||||
|
echo "apt-get install -y skopeo jq"
|
||||||
|
apt-get install -y skopeo jq
|
||||||
|
- name: Get branch and tags to push
|
||||||
|
run: |
|
||||||
|
echo "PUSH_BRANCH=$BR" >> ${GITHUB_ENV}
|
||||||
|
images=$()
|
||||||
|
echo "PUSH_IMAGES=$images" >> ${GITHUB_ENV}
|
||||||
|
if [[ $BR == 'p10' ]]; then echo "PUSH_TAGS=latest" >> ${GITHUB_ENV}; fi
|
||||||
|
env:
|
||||||
|
BR: ${{ needs.build-process.outputs.branch }}
|
||||||
|
- name: Get branch (only for c*N branches)
|
||||||
|
if: ${{ contains(github.ref_name, 'c10f2') }}
|
||||||
|
run: |
|
||||||
|
newbr=$(skopeo list-tags docker://$URL/$REPO/$BR/base/alt | jq '.Tags.[]' -r 2> /dev/null | sort | grep -m 1 c 2> /dev/null)
|
||||||
|
echo "PUSH_BRANCH=$newbr" >> ${GITHUB_ENV}
|
||||||
|
env:
|
||||||
|
BR: ${{ needs.build-process.outputs.branch }}
|
||||||
|
ORG: ${{ needs.build-process.outputs.org }}
|
||||||
|
URL: ${{ needs.build-process.outputs.url }}
|
||||||
|
REPO: ${{ needs.build-process.outputs.repo }}
|
||||||
|
- name: Run skopeo action
|
||||||
|
if: ${{ env.PUSH_BRANCH == needs.build-process.outputs.branch }}
|
||||||
|
uses: actions/skopeo-copy@v1
|
||||||
|
with:
|
||||||
|
source: ${{ needs.build-process.outputs.url }/${{ needs.build-process.outputs.repo }}/${{ needs.build-process.outputs.branch }}/${{ needs.build-process.outputs.org }}
|
||||||
|
source-proto: docker://
|
||||||
|
dest: ${{ secrets.PUSH_REPO }}/${{ needs.build-process.outputs.branch }}
|
||||||
|
dest-proto: docker://
|
||||||
|
dest-login: ${{ secrets.PUSH_USER }}
|
||||||
|
dest-pass: ${{ secrets.PUSH_PASS }}
|
||||||
|
tags: ${{ env.PUSH_TAGS }}
|
||||||
|
last-ver-tags: true
|
||||||
|
images: ${{ env.PUSH_IMAGES }}
|
||||||
|
args: -a
|
||||||
|
21
.gitea/workflows/wf_public.yaml
Normal file
21
.gitea/workflows/wf_public.yaml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
name: 'Reusable test job'
|
||||||
|
description: 'Test for images'
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
result:
|
||||||
|
description: "Result of test (success|failure)"
|
||||||
|
value: ${{ jobs.example_job.outputs.output1 }}
|
||||||
|
inputs:
|
||||||
|
image: string
|
||||||
|
branch: string
|
||||||
|
url: string
|
||||||
|
repo: string
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: 'composite'
|
||||||
|
steps:
|
||||||
|
- name: Install requires
|
||||||
|
run: |
|
||||||
|
echo "apt-get install -y skopeo jq"
|
||||||
|
apt-get install -y skopeo jq
|
||||||
|
- name: Scopeo copy
|
6
build.py
6
build.py
@ -230,7 +230,7 @@ class DockerBuilder:
|
|||||||
) -> str:
|
) -> str:
|
||||||
if self.registry:
|
if self.registry:
|
||||||
registry = self.registry.rstrip("/") + "/"
|
registry = self.registry.rstrip("/") + "/"
|
||||||
alt_image = "alt/alt"
|
alt_image = "base/alt"
|
||||||
else:
|
else:
|
||||||
registry = ""
|
registry = ""
|
||||||
alt_image = "alt"
|
alt_image = "alt"
|
||||||
@ -307,7 +307,7 @@ class DockerBuilder:
|
|||||||
f"{from_image['organization']}/{from_image['name']}"
|
f"{from_image['organization']}/{from_image['name']}"
|
||||||
)
|
)
|
||||||
elif distrolessfile.exists():
|
elif distrolessfile.exists():
|
||||||
requires.add("alt/distroless-builder")
|
requires.add("base/distroless-builder")
|
||||||
raw_from = self.distrolesses[canonical_name].raw_from
|
raw_from = self.distrolesses[canonical_name].raw_from
|
||||||
from_ = self.render_template(raw_from, self.organization)
|
from_ = self.render_template(raw_from, self.organization)
|
||||||
if match := re.match(self.image_re, from_):
|
if match := re.match(self.image_re, from_):
|
||||||
@ -345,7 +345,7 @@ class DockerBuilder:
|
|||||||
def distroless_build(self, image: Image, arches):
|
def distroless_build(self, image: Image, arches):
|
||||||
def distroless_build_arch(arch, manifest):
|
def distroless_build_arch(arch, manifest):
|
||||||
distroless_builder = self.render_full_tag(
|
distroless_builder = self.render_full_tag(
|
||||||
Image("alt/distroless-builder"), self.branch
|
Image("base/distroless-builder"), self.branch
|
||||||
)
|
)
|
||||||
distroless = self.distrolesses[image.canonical_name]
|
distroless = self.distrolesses[image.canonical_name]
|
||||||
distroless.render_arch_branch(arch, self.branch)
|
distroless.render_arch_branch(arch, self.branch)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM {{ registry }}{{ organization }}/buildpack-deps-curl:{{ branch }}
|
FROM {{ registry }}base/buildpack-deps-curl:{{ branch }}
|
||||||
|
|
||||||
MAINTAINER alt-cloud
|
MAINTAINER alt-cloud
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM {{ registry }}{{ organization }}/buildpack-deps-scm:{{ branch }}
|
FROM {{ registry }}base/buildpack-deps-scm:{{ branch }}
|
||||||
|
|
||||||
MAINTAINER alt-cloud
|
MAINTAINER alt-cloud
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM {{ registry }}{{ organization }}/base:{{ branch }}
|
FROM {{ registry }}base/base:{{ branch }}
|
||||||
|
|
||||||
MAINTAINER alt-cloud
|
MAINTAINER alt-cloud
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from = "{{ registry }}{{ organization }}/distroless-static:{{ branch }}"
|
from = "{{ registry }}base/distroless-static:{{ branch }}"
|
||||||
builder-install-packages = [
|
builder-install-packages = [
|
||||||
"glibc-core",
|
"glibc-core",
|
||||||
'{{if_branches(["p10"], "glibc-nss")}}',
|
'{{if_branches(["p10"], "glibc-nss")}}',
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from = "{{ registry }}{{ organization }}/distroless-base:{{ branch }}"
|
from = "{{ registry }}base/distroless-base:{{ branch }}"
|
||||||
builder-install-packages = [
|
builder-install-packages = [
|
||||||
"coreutils",
|
"coreutils",
|
||||||
"findutils",
|
"findutils",
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
from = "{{ registry }}{{ organization }}/distroless-base:{{ branch }}"
|
from = "{{ registry }}base/distroless-base:{{ branch }}"
|
||||||
full-files = ["/usr/bin/gotop"]
|
full-files = ["/usr/bin/gotop"]
|
||||||
entrypoint = ["/usr/bin/gotop"]
|
entrypoint = ["/usr/bin/gotop"]
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
from = "{{ registry }}{{ organization }}/distroless-static:{{ branch }}"
|
from = "{{ registry }}base/distroless-static:{{ branch }}"
|
||||||
files = ["/bin/true"]
|
files = ["/bin/true"]
|
||||||
cmd = ["/bin/true"]
|
cmd = ["/bin/true"]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM {{ registry }}{{ organization }}/buildpack-deps:{{ branch }}
|
FROM {{ registry }}base/buildpack-deps:{{ branch }}
|
||||||
|
|
||||||
MAINTAINER alt-cloud
|
MAINTAINER alt-cloud
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM {{ registry }}{{ organization }}/base:{{ branch }}
|
FROM {{ registry }}base/base:{{ branch }}
|
||||||
|
|
||||||
MAINTAINER alt-cloud
|
MAINTAINER alt-cloud
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM {{ registry }}{{ organization }}/base:{{ branch }}
|
FROM {{ registry }}base/base:{{ branch }}
|
||||||
|
|
||||||
MAINTAINER alt-cloud
|
MAINTAINER alt-cloud
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user