-
Notifications
You must be signed in to change notification settings - Fork 3
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
Prepare Docker images builds #25
Conversation
This reverts commit 2cbc71a.
# Conflicts: # .github/workflows/ferretdb_packages.yml
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.
PR Overview
This PR aims to build Docker images for both development and production environments as part of the FerretDB packaging process.
- Introduces several new GitHub Actions workflow steps to initialize the Docker builder and build/push Docker images.
- Updates the BuildKit configuration by disabling garbage collection in ferretdb_packaging/buildkitd.toml.
Reviewed Changes
File | Description |
---|---|
.github/workflows/ferretdb_packages.yml | New steps added for initializing the Docker builder and for building/pushing Docker images. |
ferretdb_packaging/buildkitd.toml | Disables garbage collection for both OCI and containerd workers. |
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
.github/workflows/ferretdb_packages.yml:209
- [nitpick] The environment variable 'FILE' is quite generic; consider renaming it to a more descriptive identifier (e.g., IMAGE_TYPE or DOCKER_IMAGE_FLAVOR) for better clarity.
FILE=development
- name: Initialize Docker builder | ||
run: make -C ferretdb_packaging docker-init | ||
|
||
- name: Build local development Docker image |
Check failure
Code scanning / CodeQL
Checkout of untrusted code in trusted context Critical
pull_request_target
|
||
- name: Download .deb package | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: deb12-${{ matrix.pg }}-${{ steps.version.outputs.debian_version }} | ||
path: packaging | ||
|
||
- name: Initialize Docker builder | ||
run: make -C ferretdb_packaging docker-init |
Check failure
Code scanning / CodeQL
Artifact poisoning Critical
make -C ferretdb_packaging docker-init
pull_request_target
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 20 days ago
To fix the problem, we need to ensure that the downloaded artifact is extracted to a temporary directory and not directly into the workspace. This will prevent any potential malicious files from overriding existing files in the workspace. Additionally, we should verify the contents of the artifact before using it.
- Create a temporary directory for extracting the artifact.
- Modify the
actions/download-artifact
step to extract the artifact to the temporary directory. - Verify the contents of the artifact before proceeding with the subsequent steps.
-
Copy modified lines R194-R196 -
Copy modified lines R201-R206
@@ -193,2 +193,5 @@ | ||
|
||
- name: Create temporary directory for artifacts | ||
run: mkdir -p ${{ runner.temp }}/artifacts/ | ||
|
||
- name: Download .deb package | ||
@@ -197,3 +200,8 @@ | ||
name: deb12-${{ matrix.pg }}-${{ steps.version.outputs.debian_version }} | ||
path: packaging | ||
path: ${{ runner.temp }}/artifacts/ | ||
|
||
- name: Verify artifact contents | ||
run: | | ||
# Add verification logic here | ||
ls ${{ runner.temp }}/artifacts/ | ||
|
- name: Build local development Docker image | ||
if: steps.version.outputs.docker_development_tag_flags != '' | ||
run: > | ||
make -C ferretdb_packaging docker-build | ||
POSTGRES_VERSION=${{ matrix.pg }} | ||
DOCUMENTDB_VERSION=${{ steps.version.outputs.debian_version }} | ||
FILE=development | ||
OUTPUT='type=docker' | ||
TAGS=${{ steps.version.outputs.docker_development_tag_flags }} | ||
|
||
- name: Build local production Docker image |
Check failure
Code scanning / CodeQL
Checkout of untrusted code in trusted context Critical
pull_request_target
run: > | ||
make -C ferretdb_packaging docker-build | ||
POSTGRES_VERSION=${{ matrix.pg }} | ||
DOCUMENTDB_VERSION=${{ steps.version.outputs.debian_version }} | ||
FILE=development | ||
OUTPUT='type=docker' | ||
TAGS=${{ steps.version.outputs.docker_development_tag_flags }} |
Check failure
Code scanning / CodeQL
Artifact poisoning Critical
make -C ferretdb_packaging docker-build POSTGRES_VERSION=${ matrix.pg } DOCUMENTDB_VERSION=${ steps.version.outputs.debian_version } FILE=development OUTPUT='type=docker' TAGS=${ steps.version.outputs.docker_development_tag_flags }
pull_request_target
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 20 days ago
To fix the problem, we need to ensure that the downloaded artifact is extracted to a temporary directory and not directly into the workspace. This will prevent any potential malicious files from overriding existing files in the workspace. Additionally, we should verify the contents of the artifact before using them in subsequent steps.
- Create a temporary directory for extracting the artifact.
- Modify the
actions/download-artifact@v4
step to extract the artifact to the temporary directory. - Verify the contents of the artifact before using them.
-
Copy modified lines R194-R196 -
Copy modified line R201
@@ -193,2 +193,5 @@ | ||
|
||
- name: Create temporary directory for artifacts | ||
run: mkdir -p ${{ runner.temp }}/artifacts/ | ||
|
||
- name: Download .deb package | ||
@@ -197,3 +200,3 @@ | ||
name: deb12-${{ matrix.pg }}-${{ steps.version.outputs.debian_version }} | ||
path: packaging | ||
path: ${{ runner.temp }}/artifacts/ | ||
|
- name: Build local production Docker image | ||
if: steps.version.outputs.docker_production_tag_flags != '' | ||
run: > | ||
make -C ferretdb_packaging docker-build | ||
POSTGRES_VERSION=${{ matrix.pg }} | ||
DOCUMENTDB_VERSION=${{ steps.version.outputs.debian_version }} | ||
FILE=production | ||
OUTPUT='type=docker' | ||
TAGS=${{ steps.version.outputs.docker_production_tag_flags }} | ||
|
||
# - name: Login to Docker Hub | ||
# uses: docker/login-action@v3 | ||
# with: | ||
# username: ferretdbbot | ||
# password: ${{ secrets.DOCKER_HUB_TOKEN }} | ||
|
||
# - name: Login to GitHub Container Registry | ||
# uses: docker/login-action@v3 | ||
# with: | ||
# registry: ghcr.io | ||
# username: ${{ github.actor }} | ||
# password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# - name: Login to Quay.io | ||
# uses: docker/login-action@v3 | ||
# with: | ||
# registry: quay.io | ||
# username: ferretdbbot | ||
# password: ${{ secrets.QUAY_TOKEN }} | ||
|
||
- name: Build and push development Docker images |
Check failure
Code scanning / CodeQL
Checkout of untrusted code in trusted context Critical
pull_request_target
run: > | ||
make -C ferretdb_packaging docker-build | ||
POSTGRES_VERSION=${{ matrix.pg }} | ||
DOCUMENTDB_VERSION=${{ steps.version.outputs.debian_version }} | ||
FILE=production | ||
OUTPUT='type=docker' | ||
TAGS=${{ steps.version.outputs.docker_production_tag_flags }} |
Check failure
Code scanning / CodeQL
Artifact poisoning Critical
make -C ferretdb_packaging docker-build POSTGRES_VERSION=${ matrix.pg } DOCUMENTDB_VERSION=${ steps.version.outputs.debian_version } FILE=production OUTPUT='type=docker' TAGS=${ steps.version.outputs.docker_production_tag_flags }
pull_request_target
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 20 days ago
To fix the artifact poisoning issue, we need to ensure that the downloaded artifacts are extracted to a temporary directory rather than the workspace. This prevents any potential overwriting of existing files. Additionally, we should verify the contents of the artifacts before using them.
- Create a temporary directory for extracting the artifacts.
- Modify the
actions/download-artifact@v4
step to extract the artifacts to this temporary directory. - Verify the contents of the artifacts before proceeding with any further steps.
-
Copy modified lines R194-R196 -
Copy modified line R201
@@ -193,2 +193,5 @@ | ||
|
||
- name: Create temporary directory for artifacts | ||
run: mkdir -p ${{ runner.temp }}/artifacts/ | ||
|
||
- name: Download .deb package | ||
@@ -197,3 +200,3 @@ | ||
name: deb12-${{ matrix.pg }}-${{ steps.version.outputs.debian_version }} | ||
path: packaging | ||
path: ${{ runner.temp }}/artifacts/ | ||
|
- name: Build and push development Docker images | ||
if: steps.version.outputs.docker_development_tag_flags != '' | ||
run: > | ||
make -C ferretdb_packaging docker-build | ||
POSTGRES_VERSION=${{ matrix.pg }} | ||
DOCUMENTDB_VERSION=${{ steps.version.outputs.debian_version }} | ||
FILE=development | ||
OUTPUT='type=image,push=true' | ||
TAGS=${{ steps.version.outputs.docker_development_tag_flags }} | ||
|
||
- name: Build and push production Docker images |
Check failure
Code scanning / CodeQL
Checkout of untrusted code in trusted context Critical
pull_request_target
run: > | ||
make -C ferretdb_packaging docker-build | ||
POSTGRES_VERSION=${{ matrix.pg }} | ||
DOCUMENTDB_VERSION=${{ steps.version.outputs.debian_version }} | ||
FILE=development | ||
OUTPUT='type=image,push=true' | ||
TAGS=${{ steps.version.outputs.docker_development_tag_flags }} |
Check failure
Code scanning / CodeQL
Artifact poisoning Critical
make -C ferretdb_packaging docker-build POSTGRES_VERSION=${ matrix.pg } DOCUMENTDB_VERSION=${ steps.version.outputs.debian_version } FILE=development OUTPUT='type=image,push=true' TAGS=${ steps.version.outputs.docker_development_tag_flags }
pull_request_target
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 20 days ago
To fix the problem, we need to ensure that the contents of the downloaded artifact are extracted to a temporary directory rather than the runner workspace. This will prevent any potential overriding of existing files by untrusted artifact contents. Specifically, we will create a temporary directory using ${{ runner.temp }}/artifacts/
and extract the artifact there. This change will be made in the .github/workflows/ferretdb_packages.yml
file.
-
Copy modified lines R194-R196 -
Copy modified line R201
@@ -193,2 +193,5 @@ | ||
|
||
- name: Create temporary directory for artifacts | ||
run: mkdir -p ${{ runner.temp }}/artifacts/ | ||
|
||
- name: Download .deb package | ||
@@ -197,3 +200,3 @@ | ||
name: deb12-${{ matrix.pg }}-${{ steps.version.outputs.debian_version }} | ||
path: packaging | ||
path: ${{ runner.temp }}/artifacts/ | ||
|
run: > | ||
make -C ferretdb_packaging docker-build | ||
POSTGRES_VERSION=${{ matrix.pg }} | ||
DOCUMENTDB_VERSION=${{ steps.version.outputs.debian_version }} | ||
FILE=production | ||
OUTPUT='type=image,push=true' | ||
TAGS=${{ steps.version.outputs.docker_production_tag_flags }} |
Check failure
Code scanning / CodeQL
Artifact poisoning Critical
make -C ferretdb_packaging docker-build POSTGRES_VERSION=${ matrix.pg } DOCUMENTDB_VERSION=${ steps.version.outputs.debian_version } FILE=production OUTPUT='type=image,push=true' TAGS=${ steps.version.outputs.docker_production_tag_flags }
pull_request_target
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 20 days ago
To fix the problem, we need to ensure that the downloaded artifacts are treated as untrusted and are extracted to a temporary directory. Additionally, we should verify the contents of the artifacts before using them in subsequent steps. This can be achieved by creating a temporary directory for the artifacts and updating the workflow to extract the artifacts there.
- Create a temporary directory for the artifacts.
- Update the
actions/download-artifact
step to extract the artifacts to the temporary directory. - Verify the contents of the artifacts before using them.
-
Copy modified lines R194-R196 -
Copy modified lines R201-R210
@@ -193,2 +193,5 @@ | ||
|
||
- name: Create temporary directory for artifacts | ||
run: mkdir -p ${{ runner.temp }}/artifacts/ | ||
|
||
- name: Download .deb package | ||
@@ -197,3 +200,12 @@ | ||
name: deb12-${{ matrix.pg }}-${{ steps.version.outputs.debian_version }} | ||
path: packaging | ||
path: ${{ runner.temp }}/artifacts/ | ||
|
||
- name: Verify artifact contents | ||
run: | | ||
# Add verification logic here | ||
# Example: Check if the expected files are present | ||
if [ ! -f ${{ runner.temp }}/artifacts/expected_file.deb ]; then | ||
echo "Expected file not found in the artifact" | ||
exit 1 | ||
fi | ||
|
Closes FerretDB/FerretDB#4725.