Fixing push

This commit is contained in:
jpic 2020-10-08 00:50:30 +02:00
parent 0edd573f4a
commit cada94ecc5
4 changed files with 28 additions and 20 deletions

View File

@ -5,17 +5,17 @@ build:
image: yourlabs/buildah
script:
- pip3 install -U --user -e .[cli]
- CACHE_DIR=$(pwd)/.cache python3 ./shlaxfile.py build
- CACHE_DIR=$(pwd)/.cache python3 ./shlaxfile.py build push
stage: build
# commenting until we have docker again
# build-itself:
# cache:
# key: cache
# paths: [.cache]
# image: shlax:$CI_COMMIT_SHORT_SHA
# script: python3 ./shlaxfile.py build
# stage: test
#
build-itself:
cache:
key: cache
paths: [.cache]
image: quay.io/yourlabs/shlax:$CI_COMMIT_SHORT_SHA
script: python3 ./shlaxfile.py build
stage: test
test:
image: yourlabs/python
stage: build

View File

@ -74,13 +74,19 @@ class Image:
def __str__(self):
return f'{self.repository}:{self.tags[-1]}'
async def push(self, *args, **kwargs):
user = os.getenv('DOCKER_USER')
passwd = os.getenv('DOCKER_PASS')
action = kwargs.get('action', self)
async def push(self, target):
user = os.getenv('IMAGES_USER')
passwd = os.getenv('IMAGES_PASS')
if user and passwd:
action.output.cmd('buildah login -u ... -p ...' + self.registry)
await action.exec('buildah', 'login', '-u', user, '-p', passwd, self.registry or 'docker.io', debug=False)
target.output.cmd('buildah login -u ... -p ...' + self.registry)
await target.parent.exec(
'buildah', 'login', '-u', user, '-p', passwd,
self.registry or 'docker.io', debug=False)
for tag in self.tags:
await action.exec('buildah', 'push', f'{self.repository}:{tag}')
await target.parent.exec(
'buildah',
'push',
self.repository + ':final',
f'{self.registry}/{self.repository}:{tag}'
)

View File

@ -37,10 +37,12 @@ class Buildah(Target):
return 'Replacing with: buildah unshare ' + ' '.join(sys.argv)
return f'Buildah({self.image})'
async def __call__(self, *actions, target=None):
async def __call__(self, *actions, target=None, push: bool=False):
if target:
self.parent = target
self.push = push
if not self.is_runnable():
os.execvp('buildah', ['buildah', 'unshare'] + sys.argv)
return # process has been replaced
@ -124,7 +126,7 @@ class Buildah(Target):
if result.status == 'success' and self.ctr:
await self.commit()
if os.getenv('BUILDAH_PUSH'):
if self.push:
await self.image.push(target)
if self.ctr is not None:

View File

@ -11,7 +11,7 @@ shlax = Container(
Copy('setup.py', 'shlax', '/app'),
Pip('/app'),
base='quay.io/podman/stable',
commit='shlax',
commit='quay.io/yourlabs/shlax',
),
)