This repository was archived by the owner on May 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Update Dockerfile and CI #191
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ on: | |
- 'docs/**' | ||
- 'examples/**' | ||
- '**.md' | ||
tags: | ||
- 'v[0-9]+.[0-9]+.[0-9]+' | ||
pull_request: | ||
branches: | ||
- master | ||
|
@@ -19,9 +21,6 @@ on: | |
- 'docs/**' | ||
- 'examples/**' | ||
- '**.md' | ||
create: | ||
tags: | ||
- 'v[0-9]+.[0-9]+.[0-9]+*' | ||
|
||
env: | ||
DOCKER_BUILDKIT: 1 | ||
|
@@ -38,7 +37,6 @@ jobs: | |
outputs: | ||
sha_short: ${{ steps.vars.outputs.sha }} | ||
go_version: ${{ steps.vars.outputs.go_version }} | ||
git_tag: ${{ steps.vars.outputs.git_tag }} | ||
repo_name: ${{ steps.vars.outputs.repo }} | ||
steps: | ||
- name: Checkout Repository | ||
|
@@ -48,7 +46,6 @@ jobs: | |
run: | | ||
echo "::set-output name=sha::$(echo ${GITHUB_SHA} | cut -c1-7)" | ||
echo "::set-output name=go_version::$(grep "go 1." go.mod | cut -d " " -f 2)" | ||
echo "::set-output name=git_tag::$(echo ${GITHUB_REF/refs\/tags\//} | tr -d v)" | ||
echo "::set-output name=repo::$(echo ${GITHUB_REPOSITORY} | cut -d '/' -f 2)" | ||
|
||
binary: | ||
|
@@ -96,23 +93,43 @@ jobs: | |
with: | ||
path: ${{ github.workspace }}/bin/manager | ||
key: nginx-ingress-operator-${{ github.run_id }}-${{ github.run_number }} | ||
- name: DockerHub Login | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
if: github.event_name != 'pull_request' | ||
- name: Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: | | ||
nginx/nginx-ingress-operator | ||
tags: | | ||
type=edge | ||
type=ref,event=pr | ||
type=semver,pattern={{version}} | ||
labels: | | ||
org.opencontainers.image.documentation=https://docs.nginx.com/nginx-ingress-controller | ||
org.opencontainers.image.vendor=NGINX Inc <[email protected]> | ||
- name: Build Image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: '.' | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
tags: nginx/nginx-ingress-operator:${{ github.sha }} | ||
push: false | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
load: ${{ github.event_name == 'pull_request' }} | ||
push: ${{ github.event_name != 'pull_request' }} | ||
pull: true | ||
load: true | ||
- name: Run Trivy vulnerability scanner | ||
uses: aquasecurity/[email protected] | ||
continue-on-error: true | ||
with: | ||
image-ref: nginx/nginx-ingress-operator:${{ github.sha }} | ||
image-ref: nginx/nginx-ingress-operator:${{ steps.meta.outputs.version }} | ||
format: 'template' | ||
template: '@/contrib/sarif.tpl' | ||
output: 'trivy-results.sarif' | ||
|
@@ -121,7 +138,7 @@ jobs: | |
uses: github/codeql-action/upload-sarif@v1 | ||
continue-on-error: true | ||
with: | ||
sarif_file: 'trivy-result.sarif' | ||
sarif_file: 'trivy-results.sarif' | ||
- name: Upload Scan Results | ||
uses: actions/upload-artifact@v2 | ||
continue-on-error: true | ||
|
@@ -130,46 +147,11 @@ jobs: | |
path: 'trivy-results.sarif' | ||
if: always() | ||
|
||
release-docker: | ||
name: Release Image | ||
runs-on: ubuntu-20.04 | ||
needs: [vars, build, unit-tests] | ||
if: | ||
github.repository == 'nginxinc/nginx-ingress-operator' && | ||
github.event_name == 'create' && | ||
contains(github.ref, 'refs/tags/') | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
- name: Fetch Cached Artifacts | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ github.workspace }}/build/_output/bin/nginx-ingress-operator | ||
key: nginx-ingress-operator-${{ github.run_id }}-${{ github.run_number }} | ||
- name: Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: DockerHub Login | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- name: Push to Dockerhub | ||
uses: docker/build-push-action@v2 | ||
with: | ||
file: Dockerfile | ||
context: '.' | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
tags: | | ||
nginx/nginx-ingress-operator:latest | ||
nginx/nginx-ingress-operator:${{ needs.vars.outputs.git_tag }} | ||
push: true | ||
pull: true | ||
|
||
notify: | ||
name: Notify | ||
runs-on: ubuntu-20.04 | ||
needs: [vars, release-docker] | ||
needs: [vars, build] | ||
if: always() && github.ref == 'refs/heads/master' | ||
steps: | ||
- name: Workflow Status | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,12 +18,20 @@ COPY controllers/ controllers/ | |
# Build | ||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X main.version=${VERSION}" -a -o manager main.go | ||
|
||
# Use distroless as minimal base image to package the manager binary | ||
# Refer to https://github.com/GoogleContainerTools/distroless for more details | ||
FROM gcr.io/distroless/static:nonroot | ||
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest | ||
ARG VERSION | ||
WORKDIR / | ||
COPY --from=builder --chown=65532:65532 /workspace/manager . | ||
COPY --from=builder /workspace/manager . | ||
COPY config/crd/kic ./config/crd/kic | ||
USER 65532:65532 | ||
COPY LICENSE /licenses/ | ||
|
||
LABEL name="NGINX Ingress Operator" \ | ||
vendor="NGINX Inc <[email protected]" \ | ||
version="v${VERSION}" \ | ||
release="1" \ | ||
summary="The NGINX Ingress Operator is a Kubernetes/OpenShift component which deploys and manages one or more NGINX/NGINX Plus Ingress Controllers" \ | ||
description="The NGINX Ingress Operator is a Kubernetes/OpenShift component which deploys and manages one or more NGINX/NGINX Plus Ingress Controllers" | ||
|
||
ENTRYPOINT ["/manager"] | ||
|
||
USER 1001 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So handy that we don't have to update to this image any more 🎉