Commit d6ed1f2b authored by Kevin Daudt's avatar Kevin Daudt

Merge branch 'add-docker-image-template' into 'master'

Add a template to build docker images, which is copied from . The idea is that those repositories can refer to the template rather than duplicating the same steps.

This also adds a minimal linting for the yaml files so that we at least get feedback of obviously broken files. Later we want to improve on that.

See merge request !1
parents 04eefe93 9650af66
Pipeline #36 passed with stage
in 26 seconds
image: python:alpine
stages:
- verify
lint:
stage: verify
before_script:
- pip install pyyaml
script:
- scripts/lint-templates
tags:
- docker-alpine
MIT License
Copyright (c) 2019 Alpine Linux Team
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# gitlab-ci-templates
This contains templates that you can include for Gitlab CI jobs.
\ No newline at end of file
This contains templates that you can include for Gitlab CI jobs.
## How to use
In your `.gitlab-ci.yml`:
```yaml
include:
- project: 'alpine/infra/gitlab-ci-templates'
- ref: master
- file: '/docker-image.yml'
```
Don't forget to enable runners for you project.
image: alpinelinux/docker-cli:latest
stages:
- build
- upload
- manifest
.build:
stage: build
script:
- docker build -t alinelinux/$CI_PROJECT_NAME:latest-$ARCH .
build-s390x:
extends: .build
variables:
ARCH: s390x
tags:
- docker-alpine
- s390x
.upload:
stage: upload
only:
- master
script:
- docker tag :latest-$ARCH alpinelinux/$CI_RPOJECT_NAME:latest-$ARCH
- docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
- docker push alpinelinux/$CI_PROJECT_NAME:latest-$ARCH
upload-s390x:
extends: .upload
variables:
ARCH: s390x
tags:
- docker-alpine
- s390x
create-manifest:
stage: manifest
variables:
DOCKER_CLI_EXPERIMENTAL: enabled
only:
- master
tags:
- docker-alpine
- s390x
script:
- docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
- docker manifest create --amend alpinelinux/$CI_PROJECT_NAME:latest alpinelinux/$CI_PROJECT_NAME:latest-s390x
- docker manifest push --purge alpinelinux/$CI_PROJECT_NAME:latest
#!/bin/sh
for file in $(find -name '*.yml' -not -name '.*')
do
scripts/yaml-lint.py "$file" || exit $?
done
#!/usr/bin/env python3
import sys
import yaml
filename = sys.argv[1]
try:
with open(filename, 'r') as f:
try:
yaml.safe_load(f)
except yaml.parser.ParserError as e:
print("Could not parse {filename}".format(filename=filename))
print(e.problem)
print(e.problem_mark)
sys.exit(1)
except FileNotFoundError:
print("Could not find file {filename}".format(filename=filename))
sys.exit(2)
print("Parsed {filename} succesfully".format(filename=filename))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment