Introduce a custom Kaniko-based image for OCI container builds, including a wrapper script (`build.sh`) for flexible execution. Added Forgejo CI workflows for PR, branch, and tag builds, along with detailed documentation in the updated README. Licensed under Apache 2.0. Reviewed-on: #1 Co-authored-by: Guillaume B.B. Van Hemmen <GuillaumeHemmen@noreply.git.van-hemmen.com> Co-committed-by: Guillaume B.B. Van Hemmen <GuillaumeHemmen@noreply.git.van-hemmen.com>
This commit is contained in:
parent
b4f487f93b
commit
ddad91c367
9 changed files with 755 additions and 2 deletions
65
.forgejo/workflows/docker-dev.yaml
Normal file
65
.forgejo/workflows/docker-dev.yaml
Normal file
|
@ -0,0 +1,65 @@
|
|||
# dev: docker build + upload branch name
|
||||
# pr: docker build + upload branch name
|
||||
# tag: docker build tag version+latest
|
||||
on:
|
||||
push:
|
||||
branches-ignore:
|
||||
- 'master'
|
||||
jobs:
|
||||
docker-dev:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: gcr.io/kaniko-project/executor:debug
|
||||
steps:
|
||||
- name: setup docker config
|
||||
env:
|
||||
REGISTRY_HOST: git.van-hemmen.com
|
||||
REGISTRY_USER: ${{ secrets.docker_username }}
|
||||
REGISTRY_PASS: ${{ secrets.access_token }}
|
||||
run: |
|
||||
mkdir -p /kaniko/.docker
|
||||
cat > /kaniko/.docker/config.json <<EOF
|
||||
{
|
||||
"auths": {
|
||||
"${REGISTRY_HOST}": {
|
||||
"username": "${REGISTRY_USER}",
|
||||
"password": "${REGISTRY_PASS}"
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
- name: build and push
|
||||
env:
|
||||
GIT_USERNAME: ${{ secrets.docker_username }}
|
||||
GIT_PASSWORD: ${{ secrets.access_token }}
|
||||
KANIKO_CONTEXT: git://git.van-hemmen.com/actions/kaniko.git
|
||||
KANIKO_DESTINATION: git.van-hemmen.com/actions/kaniko:${GITHUB_SHA}
|
||||
KANIKO_DOCKERFILE: ./Dockerfile
|
||||
KANIKO_VERBOSITY: info
|
||||
run: |
|
||||
# ----- build a list of --destination flags -------------------------
|
||||
OLD_IFS="$IFS"; IFS=',' # split on commas
|
||||
DEST_FLAGS=""
|
||||
|
||||
for raw in $KANIKO_DESTINATION; do
|
||||
# trim possible whitespace
|
||||
raw=$(echo "$raw" | xargs)
|
||||
|
||||
# expand any ${VAR} / $VAR placeholders safely
|
||||
expanded=$(eval echo "$raw")
|
||||
|
||||
[ -n "$expanded" ] && DEST_FLAGS="$DEST_FLAGS --destination=$expanded"
|
||||
done
|
||||
IFS="$OLD_IFS"
|
||||
# -------------------------------------------------------------------
|
||||
|
||||
echo "Kaniko will be called with:$DEST_FLAGS"
|
||||
|
||||
/kaniko/executor \
|
||||
--verbosity="$KANIKO_VERBOSITY" \
|
||||
--context="$KANIKO_CONTEXT#$GITHUB_REF_NAME" \
|
||||
--dockerfile="$KANIKO_DOCKERFILE" \
|
||||
$DEST_FLAGS
|
||||
|
||||
|
22
.forgejo/workflows/docker-pr.yaml
Normal file
22
.forgejo/workflows/docker-pr.yaml
Normal file
|
@ -0,0 +1,22 @@
|
|||
on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
docker-pr:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: gcr.io/kaniko-project/executor:debug
|
||||
steps:
|
||||
- name: build
|
||||
env:
|
||||
GIT_USERNAME: ${{ secrets.docker_username }}
|
||||
GIT_PASSWORD: ${{ secrets.access_token }}
|
||||
KANIKO_CONTEXT: git://git.van-hemmen.com/actions/kaniko.git
|
||||
KANIKO_DOCKERFILE: ./Dockerfile
|
||||
KANIKO_VERBOSITY: info
|
||||
run: |
|
||||
/kaniko/executor \
|
||||
--verbosity="$KANIKO_VERBOSITY" \
|
||||
--context="$KANIKO_CONTEXT#$GITHUB_HEAD_REF" \
|
||||
--dockerfile="$KANIKO_DOCKERFILE" \
|
||||
--no-push
|
65
.forgejo/workflows/docker-tag.yaml
Normal file
65
.forgejo/workflows/docker-tag.yaml
Normal file
|
@ -0,0 +1,65 @@
|
|||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
jobs:
|
||||
docker-tag:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: gcr.io/kaniko-project/executor:debug
|
||||
steps:
|
||||
- name: setup docker config
|
||||
env:
|
||||
REGISTRY_HOST: git.van-hemmen.com
|
||||
REGISTRY_USER: ${{ secrets.docker_username }}
|
||||
REGISTRY_PASS: ${{ secrets.access_token }}
|
||||
run: |
|
||||
mkdir -p /kaniko/.docker
|
||||
cat > /kaniko/.docker/config.json <<EOF
|
||||
{
|
||||
"auths": {
|
||||
"${REGISTRY_HOST}": {
|
||||
"username": "${REGISTRY_USER}",
|
||||
"password": "${REGISTRY_PASS}"
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
- name: build and push
|
||||
env:
|
||||
GIT_USERNAME: ${{ secrets.docker_username }}
|
||||
GIT_PASSWORD: ${{ secrets.access_token }}
|
||||
KANIKO_CONTEXT: git://git.van-hemmen.com/actions/kaniko.git
|
||||
KANIKO_DESTINATION: git.van-hemmen.com/actions/kaniko:${GITHUB_REF_NAME},git.van-hemmen.com/actions/kaniko:latest
|
||||
KANIKO_DOCKERFILE: ./Dockerfile
|
||||
KANIKO_VERBOSITY: info
|
||||
run: |
|
||||
# ----- build a list of --destination flags -------------------------
|
||||
OLD_IFS="$IFS"; IFS=',' # split on commas
|
||||
DEST_FLAGS=""
|
||||
|
||||
for raw in $KANIKO_DESTINATION; do
|
||||
# trim possible whitespace
|
||||
raw=$(echo "$raw" | xargs)
|
||||
|
||||
# expand any ${VAR} / $VAR placeholders safely
|
||||
expanded=$(eval echo "$raw")
|
||||
|
||||
[ -n "$expanded" ] && DEST_FLAGS="$DEST_FLAGS --destination=$expanded"
|
||||
done
|
||||
IFS="$OLD_IFS"
|
||||
# -------------------------------------------------------------------
|
||||
|
||||
echo "Kaniko will be called with:$DEST_FLAGS"
|
||||
|
||||
/kaniko/executor \
|
||||
--verbosity="$KANIKO_VERBOSITY" \
|
||||
--context="$KANIKO_CONTEXT#$GITHUB_REF_NAME" \
|
||||
--dockerfile="$KANIKO_DOCKERFILE" \
|
||||
--build-arg BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
|
||||
--build-arg VCS_REF="$GITHUB_SHA" \
|
||||
--build-arg VERSION="$GITHUB_HEAD_REF" \
|
||||
$DEST_FLAGS
|
||||
|
||||
|
87
CODE_OF_CONDUCT.md
Normal file
87
CODE_OF_CONDUCT.md
Normal file
|
@ -0,0 +1,87 @@
|
|||
# Code of Conduct
|
||||
|
||||
Thank you for helping make this project a welcoming, friendly, and productive place for collaboration. All community members—maintainers, contributors, and users—are expected to follow this Code of Conduct (CoC) whenever they interact in official project spaces (issues, pull requests, discussions, chat channels, events, etc.).
|
||||
|
||||
---
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
The purpose of this CoC is to:
|
||||
|
||||
1. Foster a collaborative and respectful environment.
|
||||
2. Clarify expectations for behavior.
|
||||
3. Provide a mechanism for reporting, addressing, and resolving unacceptable behavior.
|
||||
|
||||
---
|
||||
|
||||
## 2. Expected Behavior
|
||||
|
||||
Project participants are expected to:
|
||||
|
||||
| Behavior | Examples |
|
||||
| -------- | -------- |
|
||||
| Be respectful | Use welcoming and inclusive language; be polite in disagreements. |
|
||||
| Be considerate | Acknowledge and value different viewpoints. |
|
||||
| Be constructive | Offer helpful feedback and focus on solutions. |
|
||||
| Be responsible | Take ownership of contributions and mistakes. |
|
||||
| Be professional | Communicate in a courteous, positive, and dignified manner. |
|
||||
|
||||
---
|
||||
|
||||
## 3. Unacceptable Behavior
|
||||
|
||||
Examples of behavior that **will not be tolerated** include, but are not limited to:
|
||||
|
||||
* Insults, threats, or personal attacks.
|
||||
* Harassment, bullying, intimidation, or stalking.
|
||||
* Public or private disclosure of someone’s confidential information.
|
||||
* Excessive profanity or sexually explicit content.
|
||||
* Malicious software, spam, self-promotion unrelated to the project.
|
||||
* Any illegal activities or encouragement thereof.
|
||||
|
||||
---
|
||||
|
||||
## 4. Scope
|
||||
|
||||
This CoC applies within all official project spaces as well as public spaces when an individual is representing the project. Examples include using an official e-mail address, posting on official social media, or acting as a designated representative at an event.
|
||||
|
||||
---
|
||||
|
||||
## 5. Reporting Violations
|
||||
|
||||
If you observe or experience any behavior that violates this CoC:
|
||||
|
||||
1. **Privately report** it to the maintainers via:
|
||||
`conduct [at] van-hemmen.com`.
|
||||
2. Provide as much detail as possible (links, screenshots, timestamps, involved parties).
|
||||
3. All reports will be handled **confidentially**.
|
||||
|
||||
---
|
||||
|
||||
## 6. Enforcement
|
||||
|
||||
Upon receiving a report, the maintainers will:
|
||||
|
||||
1. Acknowledge receipt as soon as possible.
|
||||
2. Review and investigate the incident.
|
||||
3. Decide on an appropriate action, which may include:
|
||||
|
||||
* A private warning.
|
||||
* Temporary or permanent removal from project spaces.
|
||||
* Reversal of contributions (e.g., reverting PRs).
|
||||
* Escalation to relevant authorities if required.
|
||||
|
||||
Decisions of the maintainers are final. Appeals may be considered at the maintainers’ discretion.
|
||||
|
||||
---
|
||||
|
||||
## 7. Responsibilities of Maintainers
|
||||
|
||||
* Uphold and enforce this CoC consistently and fairly.
|
||||
* Protect reporters’ confidentiality.
|
||||
* Keep records of any incidents and outcomes.
|
||||
* Update this document as needed.
|
||||
|
||||
---
|
||||
|
||||
Thank you for helping keep this community open, respectful, and productive.
|
121
CONTRIBUTING.md
Normal file
121
CONTRIBUTING.md
Normal file
|
@ -0,0 +1,121 @@
|
|||
# Contributing Guide
|
||||
|
||||
Thank you for your interest in contributing! We appreciate all pull requests (PRs), code reviews, bug reports, and feature ideas. To keep things smooth for everyone, please follow these guidelines.
|
||||
|
||||
---
|
||||
|
||||
## Table of Contents
|
||||
1. [Getting Started](#getting-started)
|
||||
2. [Code of Conduct](#code-of-conduct)
|
||||
3. [How to Contribute](#how-to-contribute)
|
||||
- [Reporting Issues](#reporting-issues)
|
||||
- [Proposing Enhancements](#proposing-enhancements)
|
||||
- [Pull Requests](#pull-requests-prs)
|
||||
4. [Commit Message Guidelines](#commit-message-guidelines)
|
||||
5. [Pull Request Process](#pull-request-process)
|
||||
6. [Maintainer Responsibilities](#maintainer-responsibilities)
|
||||
7. [License](#license)
|
||||
|
||||
---
|
||||
|
||||
## Getting Started
|
||||
1. **Fork the repository** and create your own branch.
|
||||
2. **Clone your fork** to your local machine.
|
||||
3. **Create** a new branch for each piece of work:
|
||||
```bash
|
||||
git checkout -b feature/brief-description
|
||||
```
|
||||
|
||||
## Code of Conduct
|
||||
All contributors are expected to follow our [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md). Be respectful, inclusive, and open-minded.
|
||||
|
||||
## How to Contribute
|
||||
|
||||
### Reporting Issues
|
||||
- Search the issue tracker to see if your issue has already been reported.
|
||||
- If not, open a new issue and provide:
|
||||
- **Title**: Clear, concise.
|
||||
- **Description**: Steps to reproduce, expected vs. actual behavior.
|
||||
- **Environment**: OS, Java version, etc.
|
||||
- **Screenshots/Logs**: When applicable.
|
||||
|
||||
### Proposing Enhancements
|
||||
- Check existing enhancement requests.
|
||||
- Clearly outline:
|
||||
- Motivation and use case.
|
||||
- Proposed solution or approach.
|
||||
- Potential alternatives.
|
||||
|
||||
### Pull Requests (PRs)
|
||||
> **Important:**
|
||||
> - **An issue _must_ exist before any PR is submitted.**
|
||||
> - **Every PR _must_ link to its corresponding issue in the description (e.g., “Closes #123”).**
|
||||
> - **All PRs _must_ be merged using a squash commit.**
|
||||
|
||||
Steps:
|
||||
1. Ensure your branch is up to date with `main`:
|
||||
```bash
|
||||
git fetch origin
|
||||
git rebase origin/main
|
||||
```
|
||||
2. Commit your changes (see “Commit Message Guidelines” below).
|
||||
3. Push your branch to your fork:
|
||||
```bash
|
||||
git push -u origin feature/brief-description
|
||||
```
|
||||
4. Open a PR against `main`.
|
||||
5. Fill out the PR template completely.
|
||||
|
||||
---
|
||||
|
||||
## Commit Message Guidelines
|
||||
format: "`<type>`: `<message>`"
|
||||
|
||||
Allowed `<type>` values:
|
||||
`feat`, `fix`, `docs`, `test`, `refactor`, `perf`, `ci`, `chore`.
|
||||
|
||||
Example:
|
||||
> fix: prevent NPE in OrderService when cart is null docs: add README section for Docker usage
|
||||
|
||||
---
|
||||
|
||||
## Pull Request Process
|
||||
|
||||
1. **Ensure the PR description links to its issue**
|
||||
Use “Closes #<issue-number>” (or “Fixes”, “Resolves”).
|
||||
2. Keep the PR focused—one logical change per PR.
|
||||
3. Rebase onto the latest `main` before opening or updating the PR:
|
||||
```bash
|
||||
git fetch origin
|
||||
git rebase origin/main
|
||||
```
|
||||
4. Push to your fork:
|
||||
```bash
|
||||
git push -u origin feature/brief-description
|
||||
```
|
||||
5. Fill out every section of the PR template (tests, screenshots, etc.).
|
||||
6. Address all review comments; push additional commits as needed.
|
||||
7. **Merging strategy**
|
||||
All PRs are merged using **“Squash and merge.”**
|
||||
This keeps the main branch history linear and clean.
|
||||
8. Once approved and all checks pass, a maintainer will squash-merge the PR.
|
||||
|
||||
---
|
||||
|
||||
## Maintainer Responsibilities
|
||||
|
||||
* Triage new issues and confirm validity.
|
||||
* Review PRs in a timely manner.
|
||||
* Ensure all CI checks pass before merging.
|
||||
* Enforce the squash-merge rule.
|
||||
* Keep the documentation and release notes up to date.
|
||||
|
||||
---
|
||||
|
||||
## License
|
||||
|
||||
By contributing, you agree that your work will be licensed under the same license as the project. See [LICENSE](LICENSE).
|
||||
|
||||
---
|
||||
|
||||
Thank you again for helping make this project better!
|
44
Dockerfile
Normal file
44
Dockerfile
Normal file
|
@ -0,0 +1,44 @@
|
|||
# syntax=docker/dockerfile:1.4
|
||||
###############################################################################
|
||||
# Custom Kaniko builder
|
||||
#
|
||||
# Base image : gcr.io/kaniko-project/executor:debug
|
||||
# Maintainer : Guillaume "B.B" Van Hemmen <guillaume@van-hemmen.com>
|
||||
# Repository : https://git.van-hemmen.com/actions/kaniko
|
||||
###############################################################################
|
||||
|
||||
FROM gcr.io/kaniko-project/executor:debug
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Build-time args (optionally provided via --build-arg / Kaniko flags)
|
||||
#-----------------------------------------------------------------------------
|
||||
ARG BUILD_DATE
|
||||
ARG VCS_REF
|
||||
ARG VERSION
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# OCI / Docker annotations
|
||||
#-----------------------------------------------------------------------------
|
||||
LABEL \
|
||||
org.opencontainers.image.title="Kaniko Builder" \
|
||||
org.opencontainers.image.description="Fork of Google’s Kaniko debug image with build.sh as entrypoint" \
|
||||
org.opencontainers.image.url="https://git.van-hemmen.com/actions/kaniko" \
|
||||
org.opencontainers.image.source="https://git.van-hemmen.com/actions/kaniko" \
|
||||
org.opencontainers.image.version="${VERSION:-unknown}" \
|
||||
org.opencontainers.image.created="${BUILD_DATE:-unknown}" \
|
||||
org.opencontainers.image.revision="${VCS_REF:-unknown}" \
|
||||
org.opencontainers.image.licenses="APACHE 2.0" \
|
||||
org.opencontainers.image.authors="Guillaume \"B.B\" Van Hemmen <guillaume@van-hemmen.com>" \
|
||||
maintainer="Guillaume \"B.B\" Van Hemmen <guillaume@van-hemmen.com>"
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Copy artefacts & make the wrapper executable
|
||||
#-----------------------------------------------------------------------------
|
||||
COPY build.sh /usr/local/bin/build.sh
|
||||
COPY LICENSE /LICENSE
|
||||
RUN chmod +x /usr/local/bin/build.sh
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Runtime entrypoint
|
||||
#-----------------------------------------------------------------------------
|
||||
ENTRYPOINT ["/usr/local/bin/build.sh"]
|
202
LICENSE
Normal file
202
LICENSE
Normal file
|
@ -0,0 +1,202 @@
|
|||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2018 Google LLC
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
55
README.md
55
README.md
|
@ -1,3 +1,54 @@
|
|||
# kaniko
|
||||
# kaniko (action)
|
||||
|
||||
Custom Kaniko image (from Google’s debug variant) for Forgejo Actions: build & push container images in CI/CD by just setting env vars—no Docker daemon needed.
|
||||

|
||||

|
||||
|
||||
Custom **Kaniko** image (forked from Google’s `gcr.io/kaniko-project/executor:debug`) for Forgejo Actions.
|
||||
Build & push OCI-compatible container images in your pipelines **without** a Docker daemon. Just set a few environment variables.
|
||||
|
||||
---
|
||||
|
||||
## Highlights
|
||||
|
||||
| Feature | Benefit |
|
||||
|---------|---------|
|
||||
| **Daemon-less builds** | Works in completely rootless, container-only environments |
|
||||
| **Debug base** | Includes `/shell` & common tools for troubleshooting |
|
||||
| **Registry-agnostic** | Push to Docker Hub, GHCR, Harbor, Quay, Google Artifact Registry, etc. |
|
||||
| **Small wrapper script** | Autodetects credentials and common env-var combos |
|
||||
|
||||
---
|
||||
|
||||
## Image tags
|
||||
|
||||
| Tag | Base | Intended use |
|
||||
|-----|------|--------------|
|
||||
| `latest` | Google `debug` executor | General CI pipelines |
|
||||
|
||||
---
|
||||
|
||||
## Quick start
|
||||
|
||||
```yaml
|
||||
# .forgejo/workflows/build.yaml
|
||||
name: Build & push image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: docker
|
||||
steps:
|
||||
|
||||
- name: Build & push with Kaniko
|
||||
uses: actions/kaniko@v1
|
||||
env:
|
||||
# ✍️ Fill these placeholders
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: myorg/myapp
|
||||
IMAGE_TAG: ${{ github.sha }}
|
||||
# Optional authentication variables...
|
||||
# REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||
# REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
|
|
96
build.sh
Normal file
96
build.sh
Normal file
|
@ -0,0 +1,96 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
###############################################################################
|
||||
# Mandatory variables – abort if not provided
|
||||
###############################################################################
|
||||
if [[ -z "${KANIKO_CONTEXT:-}" ]]; then
|
||||
echo "Error: KANIKO_CONTEXT environment variable is required but not set." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "${GITHUB_REF_NAME:-}" ]]; then
|
||||
echo "Error: GITHUB_REF_NAME environment variable is required but not set." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "${GIT_USERNAME:-}" ]]; then
|
||||
echo "Error: GIT_USERNAME environment variable is required but not set." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "${GIT_PASSWORD:-}" ]]; then
|
||||
echo "Error: GIT_PASSWORD environment variable is required but not set." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
###############################################################################
|
||||
# Optional / defaulted variables
|
||||
###############################################################################
|
||||
REGISTRY_HOST="${REGISTRY_HOST:-git.van-hemmen.com}"
|
||||
REGISTRY_USER="${REGISTRY_USER:-}"
|
||||
REGISTRY_PASS="${REGISTRY_PASS:-}"
|
||||
|
||||
KANIKO_DESTINATION="${KANIKO_DESTINATION:-}" # optional
|
||||
KANIKO_VERBOSITY="${KANIKO_VERBOSITY:-info}"
|
||||
KANIKO_DOCKERFILE="${KANIKO_DOCKERFILE:-./Dockerfile}"
|
||||
|
||||
###############################################################################
|
||||
# Handle registry authentication (only if credentials are present)
|
||||
###############################################################################
|
||||
AUTH_ENABLED=false
|
||||
if [[ -n "${REGISTRY_USER}" && -n "${REGISTRY_PASS}" ]]; then
|
||||
echo "Registry credentials supplied – configuring authentication for ${REGISTRY_HOST}"
|
||||
mkdir -p /kaniko/.docker
|
||||
cat > /kaniko/.docker/config.json <<EOF
|
||||
{
|
||||
"auths": {
|
||||
"${REGISTRY_HOST}": {
|
||||
"username": "${REGISTRY_USER}",
|
||||
"password": "${REGISTRY_PASS}"
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
AUTH_ENABLED=true
|
||||
else
|
||||
echo "Registry credentials not supplied – skipping authentication."
|
||||
fi
|
||||
|
||||
###############################################################################
|
||||
# Decide between --destination [...] or --no-push
|
||||
###############################################################################
|
||||
DEST_FLAGS=""
|
||||
|
||||
# Push is only possible if we have BOTH credentials and at least one destination
|
||||
if $AUTH_ENABLED && [[ -n "${KANIKO_DESTINATION// }" ]]; then
|
||||
echo "Building list of --destination flags"
|
||||
OLD_IFS="$IFS"; IFS=','
|
||||
|
||||
for raw in $KANIKO_DESTINATION; do
|
||||
raw="$(echo "$raw" | xargs)" # trim whitespace
|
||||
expanded="$(eval echo "$raw")" # expand variables
|
||||
[[ -n "$expanded" ]] && DEST_FLAGS+=" --destination=${expanded}"
|
||||
done
|
||||
|
||||
IFS="$OLD_IFS"
|
||||
echo "Image(s) will be pushed to the registry."
|
||||
else
|
||||
DEST_FLAGS="--no-push"
|
||||
if ! $AUTH_ENABLED; then
|
||||
echo "Image(s) will NOT be pushed because registry credentials are missing."
|
||||
elif [[ -z "${KANIKO_DESTINATION// }" ]]; then
|
||||
echo "KANIKO_DESTINATION not provided – image(s) will be built with --no-push."
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Kaniko will be called with: ${DEST_FLAGS}"
|
||||
|
||||
###############################################################################
|
||||
# Invoke Kaniko
|
||||
###############################################################################
|
||||
/kaniko/executor \
|
||||
--verbosity="${KANIKO_VERBOSITY}" \
|
||||
--context="${KANIKO_CONTEXT}#${GITHUB_REF_NAME}" \
|
||||
--dockerfile="${KANIKO_DOCKERFILE}" \
|
||||
${DEST_FLAGS}
|
Loading…
Add table
Add a link
Reference in a new issue