Repository navigation
Authenticate to the gated pgEdge repositories without leaving credentials in the image #39
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
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 |
|---|---|---|
|
|
@@ -28,7 +28,9 @@ useradd -u ${POSTGRES_USER_ID} -m postgres -s /bin/bash | |
| dnf install -y epel-release dnf | ||
| dnf config-manager --set-enabled crb | ||
| dnf update -y --allowerasing | ||
| dnf install -y https://dnf.pgedge.com/reporpm/pgedge-release-latest.noarch.rpm | ||
| # downloads.pgedge.com, not dnf.pgedge.com: the gated repository cannot serve | ||
| # the package that configures access to it. | ||
| dnf install -y https://downloads.pgedge.com/reporpm/pgedge-release-latest.noarch.rpm | ||
| if [[ -n "${PACKAGE_RELEASE_CHANNEL}" ]]; then | ||
| sed -i "s|release|${PACKAGE_RELEASE_CHANNEL}|g" /etc/yum.repos.d/pgedge.repo | ||
| fi | ||
|
|
@@ -51,13 +53,35 @@ ARG POSTGRES_MAJOR_VERSION | |
|
|
||
| COPY packagelists/${TARGETARCH}/${POSTGRES_PACKAGE_LIST_FILE} /usr/share/pgedge/packages.txt | ||
|
|
||
| RUN <<EOF | ||
| RUN --mount=type=secret,id=repo_client_crt \ | ||
| --mount=type=secret,id=repo_client_key \ | ||
| <<EOF | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -o errexit | ||
| set -o pipefail | ||
| set -o nounset | ||
|
|
||
| # The pgEdge repositories authenticate clients with mutual TLS. BuildKit mounts | ||
| # the secrets for this RUN alone and never writes them to a layer; the copies | ||
| # pgedge-subscription-manager installs are removed, and the repositories | ||
| # disabled again, before this layer is committed. So the image carries no | ||
| # credentials and no repository it cannot reach. | ||
| trap 'rm -f /etc/pki/pgedge/client.crt /etc/pki/pgedge/client.key; dnf config-manager --set-disabled "pgedge*" >/dev/null 2>&1 || true' EXIT | ||
|
Member
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. Non-blocking suggestion: we could add an option to the
Member
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. Okay. I'll open a separate ticket for it. |
||
|
|
||
| # A chained stage starts FROM a published parent built before the repositories | ||
| # were gated: its pgedge-release predates pgedge-subscription-manager and its | ||
| # repository definition is enabled, pointing at a host it can no longer reach. | ||
| # Disable those definitions and replace the package first, so neither this | ||
| # install nor the channel rewrite below depends on when the parent was built. | ||
| dnf config-manager --set-disabled "pgedge*" >/dev/null 2>&1 || true | ||
| command -v pgedge-subscription-manager >/dev/null 2>&1 \ | ||
| || dnf install -y --disablerepo="pgedge*" \ | ||
| https://downloads.pgedge.com/reporpm/pgedge-release-latest.noarch.rpm | ||
|
|
||
|
|
||
| pgedge-subscription-manager install /run/secrets/repo_client_crt /run/secrets/repo_client_key --force | ||
|
|
||
| xargs dnf install -y < /usr/share/pgedge/packages.txt | ||
| # Patch any OS packages (including transitive dependencies pulled in above) | ||
| # to the latest available errata so the image ships with security fixes. | ||
|
|
@@ -119,13 +143,33 @@ USER root | |
|
|
||
| COPY packagelists/${TARGETARCH}/${PACKAGE_LIST_FILE} /usr/share/pgedge/packages.txt | ||
|
|
||
| RUN <<EOF | ||
| RUN --mount=type=secret,id=repo_client_crt \ | ||
| --mount=type=secret,id=repo_client_key \ | ||
| <<EOF | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -o errexit | ||
| set -o pipefail | ||
| set -o nounset | ||
|
|
||
| # The pgEdge repositories authenticate clients with mutual TLS. BuildKit mounts | ||
| # the secrets for this RUN alone and never writes them to a layer; the copies | ||
| # pgedge-subscription-manager installs are removed, and the repositories | ||
| # disabled again, before this layer is committed. So the image carries no | ||
| # credentials and no repository it cannot reach. | ||
| trap 'rm -f /etc/pki/pgedge/client.crt /etc/pki/pgedge/client.key; dnf config-manager --set-disabled "pgedge*" >/dev/null 2>&1 || true' EXIT | ||
|
|
||
| # A chained stage starts FROM a published parent built before the repositories | ||
| # were gated: its pgedge-release predates pgedge-subscription-manager and its | ||
| # repository definition is enabled, pointing at a host it can no longer reach. | ||
| # Disable those definitions and replace the package first, so neither this | ||
| # install nor the channel rewrite below depends on when the parent was built. | ||
| dnf config-manager --set-disabled "pgedge*" >/dev/null 2>&1 || true | ||
| command -v pgedge-subscription-manager >/dev/null 2>&1 \ | ||
| || dnf install -y --disablerepo="pgedge*" \ | ||
| https://downloads.pgedge.com/reporpm/pgedge-release-latest.noarch.rpm | ||
|
|
||
|
|
||
| # The repo config is inherited from the parent image, which may have been built | ||
| # from a different channel, so re-point it here rather than relying on the base | ||
| # stage. Idempotent: once rewritten there is no "release" left to match. | ||
|
|
@@ -135,6 +179,8 @@ fi | |
|
|
||
| # A delta: re-pinning a package the parent's "dnf update -y" has moved past | ||
| # would be a downgrade, which dnf refuses. | ||
| pgedge-subscription-manager install /run/secrets/repo_client_crt /run/secrets/repo_client_key --force | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
|
|
||
| xargs dnf install -y < /usr/share/pgedge/packages.txt | ||
| dnf update -y | ||
| dnf clean all | ||
|
|
@@ -161,13 +207,33 @@ USER root | |
|
|
||
| COPY packagelists/${TARGETARCH}/${STANDARD_PACKAGE_LIST_FILE} /usr/share/pgedge/packages.txt | ||
|
|
||
| RUN <<EOF | ||
| RUN --mount=type=secret,id=repo_client_crt \ | ||
| --mount=type=secret,id=repo_client_key \ | ||
| <<EOF | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -o errexit | ||
| set -o pipefail | ||
| set -o nounset | ||
|
|
||
| # The pgEdge repositories authenticate clients with mutual TLS. BuildKit mounts | ||
| # the secrets for this RUN alone and never writes them to a layer; the copies | ||
| # pgedge-subscription-manager installs are removed, and the repositories | ||
| # disabled again, before this layer is committed. So the image carries no | ||
| # credentials and no repository it cannot reach. | ||
| trap 'rm -f /etc/pki/pgedge/client.crt /etc/pki/pgedge/client.key; dnf config-manager --set-disabled "pgedge*" >/dev/null 2>&1 || true' EXIT | ||
|
|
||
| # A chained stage starts FROM a published parent built before the repositories | ||
| # were gated: its pgedge-release predates pgedge-subscription-manager and its | ||
| # repository definition is enabled, pointing at a host it can no longer reach. | ||
| # Disable those definitions and replace the package first, so neither this | ||
| # install nor the channel rewrite below depends on when the parent was built. | ||
| dnf config-manager --set-disabled "pgedge*" >/dev/null 2>&1 || true | ||
| command -v pgedge-subscription-manager >/dev/null 2>&1 \ | ||
| || dnf install -y --disablerepo="pgedge*" \ | ||
| https://downloads.pgedge.com/reporpm/pgedge-release-latest.noarch.rpm | ||
|
|
||
|
|
||
| # The repo config is inherited from the parent image, which may have been built | ||
| # from a different channel, so re-point it here rather than relying on the base | ||
| # stage. Idempotent: once rewritten there is no "release" left to match. | ||
|
|
@@ -177,6 +243,8 @@ fi | |
|
|
||
| # A delta: re-pinning a package the parent's "dnf update -y" has moved past | ||
| # would be a downgrade, which dnf refuses. | ||
| pgedge-subscription-manager install /run/secrets/repo_client_crt /run/secrets/repo_client_key --force | ||
|
|
||
| xargs dnf install -y < /usr/share/pgedge/packages.txt | ||
| # Patch any OS packages (including transitive dependencies pulled in above) | ||
| # to the latest available errata so the image ships with security fixes. | ||
|
|
@@ -265,13 +333,33 @@ USER root | |
|
|
||
| COPY packagelists/${TARGETARCH}/${COLDFRONT_PACKAGE_LIST_FILE} /usr/share/pgedge/coldfront-packages.txt | ||
|
|
||
| RUN <<CFEOF | ||
| RUN --mount=type=secret,id=repo_client_crt \ | ||
| --mount=type=secret,id=repo_client_key \ | ||
| <<CFEOF | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -o errexit | ||
| set -o pipefail | ||
| set -o nounset | ||
|
|
||
| # The pgEdge repositories authenticate clients with mutual TLS. BuildKit mounts | ||
| # the secrets for this RUN alone and never writes them to a layer; the copies | ||
| # pgedge-subscription-manager installs are removed, and the repositories | ||
| # disabled again, before this layer is committed. So the image carries no | ||
| # credentials and no repository it cannot reach. | ||
| trap 'rm -f /etc/pki/pgedge/client.crt /etc/pki/pgedge/client.key; dnf config-manager --set-disabled "pgedge*" >/dev/null 2>&1 || true' EXIT | ||
|
|
||
| # A chained stage starts FROM a published parent built before the repositories | ||
| # were gated: its pgedge-release predates pgedge-subscription-manager and its | ||
| # repository definition is enabled, pointing at a host it can no longer reach. | ||
| # Disable those definitions and replace the package first, so neither this | ||
| # install nor the channel rewrite below depends on when the parent was built. | ||
| dnf config-manager --set-disabled "pgedge*" >/dev/null 2>&1 || true | ||
| command -v pgedge-subscription-manager >/dev/null 2>&1 \ | ||
| || dnf install -y --disablerepo="pgedge*" \ | ||
| https://downloads.pgedge.com/reporpm/pgedge-release-latest.noarch.rpm | ||
|
|
||
|
|
||
| # The repo config is inherited from the parent image, which may have been built | ||
| # from a different channel, so re-point it here rather than relying on the base | ||
| # stage. Idempotent: once rewritten there is no "release" left to match. | ||
|
|
@@ -281,6 +369,8 @@ fi | |
|
|
||
| # Dependencies are dnf's to resolve. No second "dnf update -y": that would move | ||
| # ColdFront past its pinned NVR. | ||
| pgedge-subscription-manager install /run/secrets/repo_client_crt /run/secrets/repo_client_key --force | ||
|
|
||
| xargs dnf install -y --setopt=install_weak_deps=False < /usr/share/pgedge/coldfront-packages.txt | ||
| dnf clean all | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.