Skip to content

Commit

Permalink
Turn image from scratch to optimize usage
Browse files Browse the repository at this point in the history
  • Loading branch information
rikatz committed Jan 26, 2024
1 parent f40668a commit 8a51622
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 198 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ jobs:
- changes
- build
if: |
(needs.changes.outputs.charts == 'true')
(needs.changes.outputs.charts == 'true') || (needs.changes.outputs.baseimage == 'true')
strategy:
matrix:
Expand Down Expand Up @@ -236,6 +236,7 @@ jobs:
KIND_CLUSTER_NAME: kind
SKIP_CLUSTER_CREATION: true
SKIP_IMAGE_CREATION: true
SKIP_INGRESS_IMAGE_CREATION: true
run: |
kind get kubeconfig > $HOME/.kube/kind-config-kind
make kind-e2e-chart-tests
Expand All @@ -246,7 +247,7 @@ jobs:
- changes
- build
if: |
(needs.changes.outputs.go == 'true')
(needs.changes.outputs.go == 'true') || (needs.changes.outputs.baseimage == 'true')
strategy:
matrix:
k8s: [v1.26.6, v1.27.3, v1.28.0, v1.29.0]
Expand All @@ -260,7 +261,7 @@ jobs:
- changes
- build
if: |
(needs.changes.outputs.go == 'true')
(needs.changes.outputs.go == 'true') || (needs.changes.outputs.baseimage == 'true')
strategy:
matrix:
k8s: [v1.26.6, v1.27.3, v1.28.0, v1.29.0]
Expand All @@ -275,7 +276,7 @@ jobs:
- changes
- build
if: |
(needs.changes.outputs.go == 'true')
(needs.changes.outputs.go == 'true') || (needs.changes.outputs.baseimage == 'true')
strategy:
matrix:
k8s: [v1.26.6, v1.27.3, v1.28.0, v1.29.0]
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
kube-webhook-certgen: ${{ steps.filter.outputs.kube-webhook-certgen }}
ext-auth-example-authsvc: ${{ steps.filter.outputs.ext-auth-example-authsvc }}
nginx: ${{ steps.filter.outputs.nginx }}
nginx125: ${{ steps.filter.outputs.nginx125 }}
opentelemetry: ${{ steps.filter.outputs.opentelemetry }}

steps:
Expand Down Expand Up @@ -66,6 +67,8 @@ jobs:
- 'images/nginx/**'
opentelemetry:
- 'images/opentelemetry/**'
nginx125:
- 'images/nginx-1.25/TAG'
#### TODO: Make the below jobs 'less dumb' and use the job name as parameter (the github.job context does not work here)
cfssl:
Expand Down Expand Up @@ -199,3 +202,36 @@ jobs:
- name: image build
run: |
cd images/opentelemetry && make NGINX_VERSION=${{ matrix.nginx }} build
nginx125:
permissions:
contents: write
packages: write
runs-on: ubuntu-latest
needs: changes
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.changes.outputs.nginx125 == 'true')
env:
PLATFORMS: linux/amd64,linux/arm,linux/arm64
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Set up QEMU
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
with:
version: latest
platforms: ${{ env.PLATFORMS }}
- name: Login to GitHub Container Registry
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: build-image
run: |
export TAG=$(cat images/nginx-1.25/TAG)
cd images/nginx-1.25/rootfs && docker buildx build --platform=${{ env.PLATFORMS }} --push --load -t ingressnginx/nginx-1.25:${TAG} .

167 changes: 0 additions & 167 deletions .github/workflows/nginx125.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions images/nginx-1.25/rootfs/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,6 @@ make
make modules
make install


# TODO: Ricardo Move to the right place
export OPENTELEMETRY_CONTRIB_COMMIT=aaa51e2297bcb34297f3c7aa44fa790497d2f7f3
cd "$BUILD_PATH"

Expand Down
7 changes: 5 additions & 2 deletions rootfs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

ARG BASE_IMAGE

FROM ${BASE_IMAGE}
FROM ${BASE_IMAGE} as builder

ARG TARGETARCH
ARG VERSION
Expand Down Expand Up @@ -83,6 +83,9 @@ USER www-data
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log

ENTRYPOINT ["/usr/bin/dumb-init", "--"]
FROM scratch
COPY --from=builder / /

USER www-data
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
CMD ["/nginx-ingress-controller"]
6 changes: 4 additions & 2 deletions rootfs/Dockerfile-chroot
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ RUN apk update \
&& apk upgrade \
&& /chroot.sh

FROM alpine:3.19.0
FROM alpine:3.19.0 as builder

ARG TARGETARCH
ARG VERSION
Expand Down Expand Up @@ -116,10 +116,12 @@ RUN mkdir -p /chroot/modules_mount \
&& mkdir -p modules_mount \
&& ln -s /modules_mount /chroot/modules_mount

FROM scratch

USER www-data

EXPOSE 80 443

COPY --from=builder / /
ENTRYPOINT ["/usr/bin/dumb-init", "--"]

CMD ["/nginx-ingress-controller"]
Expand Down
21 changes: 0 additions & 21 deletions test/e2e/settings/opentelemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ const (
var _ = framework.IngressNginxDescribe("Configure Opentelemetry", func() {
f := framework.NewDefaultFramework("enable-opentelemetry")

/*shouldSkip := false
skip, ok := os.LookupEnv("SKIP_OPENTELEMETRY_TESTS")
if ok && skip == enable {
shouldSkip = true
}*/

ginkgo.BeforeEach(func() {
f.NewEchoDeployment()
})
Expand All @@ -53,9 +47,6 @@ var _ = framework.IngressNginxDescribe("Configure Opentelemetry", func() {
})

ginkgo.It("should not exists opentelemetry directive", func() {
/*if shouldSkip {
ginkgo.Skip("skipped")
}*/
config := map[string]string{}
config[enableOpentelemetry] = disable
f.SetNginxConfigMapData(config)
Expand All @@ -69,9 +60,6 @@ var _ = framework.IngressNginxDescribe("Configure Opentelemetry", func() {
})

ginkgo.It("should exists opentelemetry directive when is enabled", func() {
/*if shouldSkip {
ginkgo.Skip("skipped")
}*/
config := map[string]string{}
config[enableOpentelemetry] = enable
config[opentelemetryConfig] = opentelemetryConfigPath
Expand All @@ -86,9 +74,6 @@ var _ = framework.IngressNginxDescribe("Configure Opentelemetry", func() {
})

ginkgo.It("should include opentelemetry_trust_incoming_spans on directive when enabled", func() {
/*if shouldSkip {
ginkgo.Skip("skipped")
}*/
config := map[string]string{}
config[enableOpentelemetry] = enable
config[opentelemetryConfig] = opentelemetryConfigPath
Expand All @@ -104,9 +89,6 @@ var _ = framework.IngressNginxDescribe("Configure Opentelemetry", func() {
})

ginkgo.It("should not exists opentelemetry_operation_name directive when is empty", func() {
/*if shouldSkip {
ginkgo.Skip("skipped")
}*/
config := map[string]string{}
config[enableOpentelemetry] = enable
config[opentelemetryConfig] = opentelemetryConfigPath
Expand All @@ -122,9 +104,6 @@ var _ = framework.IngressNginxDescribe("Configure Opentelemetry", func() {
})

ginkgo.It("should exists opentelemetry_operation_name directive when is configured", func() {
/*if shouldSkip {
ginkgo.Skip("skipped")
}*/
config := map[string]string{}
config[enableOpentelemetry] = enable
config[opentelemetryConfig] = opentelemetryConfigPath
Expand Down

0 comments on commit 8a51622

Please sign in to comment.