Commit c5b33e35 authored by Ruben ten Hove's avatar Ruben ten Hove
Browse files

feat: generalized image build

parent ac7ba9d6
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -34,11 +34,18 @@ jobs:c:
      - local: tests/jobs/c.yml
    strategy: depend

jobs:container:
jobs:kaniko:
  stage: test
  trigger:
    include:
      - local: tests/jobs/container.yml
      - local: tests/jobs/kaniko.yml
    strategy: depend

jobs:buildah:
  stage: test
  trigger:
    include:
      - local: tests/jobs/buildah.yml
    strategy: depend

jobs:docs:
@@ -77,16 +84,16 @@ pipelines:container:polyrepo:
      - local: tests/pipelines/container/polyrepo.yml
    strategy: depend

pipelines:container:monorepo:
pipelines:kaniko:monorepo:
  stage: test
  trigger:
    include:
      - local: tests/pipelines/container/monorepo.yml
      - local: tests/pipelines/kaniko/monorepo.yml
    strategy: depend

pipelines:container:python:
pipelines:kaniko:python:
  stage: test
  trigger:
    include:
      - local: tests/pipelines/container/python.yml
      - local: tests/pipelines/kaniko/python.yml
    strategy: depend
+3 −3
Original line number Diff line number Diff line
@@ -127,14 +127,14 @@ include:
    ref: "v3.19.2"
```

# monorepos vs polirepos
# monorepos vs polyrepos

We support both! Read [this](pipelines/container/readme.md) for more information
on how to configure pipelines for monorepos and polirepos.
on how to configure pipelines for monorepos and polyrepos.

### example python polyrepo

Polirepos will likely work out of the box without extra configuration needed.
polyrepos will likely work out of the box without extra configuration needed.

```yaml
---
+1 −1
Original line number Diff line number Diff line
---
.ssh:
  image: alpine:latest
  image: docker.io/alpine:3
  before_script:
    - apk add --no-cache openssh
    - eval $(ssh-agent -s)

container/buildah.yml

0 → 100644
+41 −0
Original line number Diff line number Diff line
---
# https://github.com/containers/buildah
include:
  - local: container/image.yml

variables:
  BUILDAH_EXTRA_ARGS: "" # https://github.com/containers/buildah/blob/main/docs/buildah-build.1.md

.buildah:
  stage: build
  extends: .container:rules
  image: quay.io/buildah/stable:latest
  script:
    - echo "[*] Building and pushing '${IMAGE_CONTAINERFILE}' in context
      '${IMAGE_CONTEXT}' to '${IMAGE_NAME}:${IMAGE_DEV_TAG}' and
      '${IMAGE_NAME}:${IMAGE_TAG}'."
    - if [ "${BUILDAH_EXTRA_ARGS}" != "" ]; then echo "[*] Applying the extra
      arguments '${BUILDAH_EXTRA_ARGS}'."; fi
    - echo "{\"auths\":{\"$CI_REGISTRY\":{\"auth\":\"$(echo -n
      ${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD} | base64)\"}}}" >
      /tmp/auth.json
    - buildah build --authfile /tmp/auth.json -f ${IMAGE_CONTAINERFILE}
      --tag=${IMAGE_NAME}:${IMAGE_DEV_TAG} --tag=${IMAGE_NAME}:${IMAGE_TAG}
      --layers=${IMAGE_CACHE} ${BUILDAH_EXTRA_ARGS}
    - |
      for IMAGE in "${IMAGE_NAME}:${IMAGE_TAG}" "${IMAGE_NAME}:${IMAGE_DEV_TAG}"; do
        buildah push --authfile /tmp/auth.json ${IMAGE}
      done

# default for polyrepos
buildah:
  extends: .buildah

# monorepos: user should extend this hidden job (one job for each container)
.buildah:monorepo:
  extends: .buildah
  variables:
    CONTEXT_PATH: changeme
    IMAGE_NAME: ${CI_REGISTRY_IMAGE}/${CONTEXT_PATH}
    IMAGE_CONTEXT: ${CI_PROJECT_DIR}/${CONTEXT_PATH}
    IMAGE_CONTAINERFILE: ${CI_PROJECT_DIR}/${CONTEXT_PATH}/Dockerfile
+2 −2
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ variables:

.grype:
  # TODO: replace alpine and installation with our custom image
  image: alpine:3
  image: docker.io/alpine:3
  stage: test
  script:
    - apk add --no-cache curl
@@ -40,7 +40,7 @@ variables:
      - ${GRYPE_OUTPUT_FILE}
  allow_failure: true

# default for polirepos
# default for polyrepos
grype:
  extends: .grype

Loading