-
Notifications
You must be signed in to change notification settings - Fork 272
KNOX-3256: Refactor Docker build to use local Maven artifacts and unify CI/Dev workflows #1239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| ########################################################################## | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you 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. | ||
| ########################################################################## | ||
|
|
||
| # Ignore all files by default to reduce build context size and protect secrets. | ||
| * | ||
|
|
||
| # Allow the target directory and its subdirectories for the required artifacts. | ||
| !target/ | ||
| !target/*/ | ||
| !target/*/knox-*.tar.gz | ||
| !target/*/knoxshell-*.tar.gz | ||
|
|
||
| # Allow the build workflow configurations and scripts. | ||
| !.github/ | ||
| !.github/workflows/ | ||
| !.github/workflows/build/ | ||
| !.github/workflows/build/** |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,10 +30,6 @@ jobs: | |
| checks: write | ||
| pull-requests: write | ||
|
|
||
| env: | ||
| KNOX_URL: "https://github.com/apache/knox.git" | ||
| BRANCH: "${{ github.head_ref }}" # PR branch being tested | ||
|
|
||
| steps: | ||
| - name: Checkout Repository | ||
| uses: actions/checkout@v4 | ||
|
|
@@ -54,20 +50,11 @@ jobs: | |
| -Dshellcheck.skip=true -Dxml.skip=true \ | ||
| -s .github/workflows/build/settings.xml | ||
|
|
||
| - name: Extract Artifacts | ||
| run: | | ||
| mkdir -p .github/workflows/build/knox-temp-artifacts .github/workflows/build/knoxshell-temp-artifacts | ||
| # Extract artifacts to the build directory where Dockerfile expects them | ||
| tar -xvzf target/*/knox-*.tar.gz -C .github/workflows/build/knox-temp-artifacts | ||
| tar -xvzf target/*/knoxshell-*.tar.gz -C .github/workflows/build/knoxshell-temp-artifacts | ||
|
|
||
| - name: Set up Docker Compose | ||
| run: docker compose version | ||
|
|
||
| - name: Build Docker Images | ||
| run: | | ||
| export knoxurl=${KNOX_URL} | ||
| export branch=${BRANCH:-master} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. knox-dev service built the official image tagged
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
| # Build only knox-dev which is the runtime image using artifacts | ||
| docker compose -f ./.github/workflows/compose/docker-compose.yml build knox-dev | ||
|
|
||
|
|
@@ -99,7 +86,7 @@ jobs: | |
| if: always() | ||
| run: | | ||
| docker compose -f ./.github/workflows/compose/docker-compose.yml down --volumes | ||
| IMAGE_TAG="local-${GITHUB_RUN_ID:-local}-${GITHUB_RUN_ID:-local}" | ||
| if docker image inspect "apache/knox-dev:$IMAGE_TAG" >/dev/null 2>&1; then | ||
| docker rmi "apache/knox-dev:$IMAGE_TAG" | ||
| TAG=${IMAGE_TAG:-master} | ||
| if docker image inspect "apache/knox-dev:$TAG" >/dev/null 2>&1; then | ||
| docker rmi "apache/knox-dev:$TAG" | ||
| fi | ||
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.
Add a
.dockerignoreat the root that allowlists only what the Dockerfile needs: e.g. * !target//knox-.tar.gz !target//knoxshell-.tar.gz !.github/workflows/build/The build log shows about 200 MB of artifacts being transferred on every build. Looks like every build sends the full Maven target directory, .git history, docs, and any local credentials to the Docker daemon. This is both slow and a potential (I am not sure yet) secrets leakage.
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.
Fixed.