diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 7d8e4ab2..976b3552 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -# Build image for httpd-datadog GitLab CI. +# Build image for httpd-datadog CI. # # It contains: # - musl toolchain whose binaries also run on glibc (musl-build-env, see diff --git a/.github/chainguard/self.gitlab.github-release.sts.yaml b/.github/chainguard/self.gitlab.github-release.sts.yaml deleted file mode 100644 index 4236f802..00000000 --- a/.github/chainguard/self.gitlab.github-release.sts.yaml +++ /dev/null @@ -1,14 +0,0 @@ -# Publish the devcontainer from the mirrored main branch. -issuer: https://gitlab.ddbuild.io -subject: "project_path:DataDog/httpd-datadog:ref_type:branch:ref:main" - -claim_pattern: - project_path: "DataDog/httpd-datadog" - ref: "main" - ref_type: "branch" - ref_path: "refs/heads/main" - pipeline_source: "push" - ci_config_ref_uri: 'gitlab\.ddbuild\.io/DataDog/httpd-datadog//\.gitlab-ci\.yml@refs/heads/main' - -permissions: - packages: write diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 7726b54e..593a0cb8 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -37,7 +37,7 @@ jobs: needs: format runs-on: ubuntu-22.04 container: - # Advanced by .gitlab/devcontainer-to-ghcr.yml after main builds. + # Published by .github/workflows/devcontainer.yml. image: ghcr.io/datadog/httpd-datadog/devcontainer:main credentials: username: ${{ github.actor }} diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml new file mode 100644 index 00000000..2e401bf1 --- /dev/null +++ b/.github/workflows/devcontainer.yml @@ -0,0 +1,66 @@ +name: Devcontainer + +on: + push: + branches: [main] + paths: + - .devcontainer/** + - scripts/setup-httpd.py + - .github/workflows/devcontainer.yml + pull_request: + paths: + - .devcontainer/** + - scripts/setup-httpd.py + - .github/workflows/devcontainer.yml + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: devcontainer-ghcr-${{ github.ref }} + cancel-in-progress: false + +jobs: + build: + runs-on: ubuntu-22.04 + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 + - name: Stage build context and compute tags + id: image + shell: bash + run: | + make -f .devcontainer/devcontainer.mk .devcontainer-stage-context + image_hash=$(make -f .devcontainer/devcontainer.mk -s .devcontainer-image-hash) + image="ghcr.io/${GITHUB_REPOSITORY,,}/devcontainer" + { + echo 'tags<> "$GITHUB_OUTPUT" + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 + - name: Log in to GHCR + if: github.event_name != 'pull_request' + uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and publish image + uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 + with: + context: .devcontainer/.staged + file: .devcontainer/.staged/.devcontainer/Dockerfile + platforms: linux/amd64 + push: ${{ github.event_name != 'pull_request' }} + provenance: false + tags: ${{ steps.image.outputs.tags }} + cache-from: type=gha,scope=devcontainer-amd64 + cache-to: type=gha,scope=devcontainer-amd64,mode=max diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7f1ae917..567306ce 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,7 +9,7 @@ jobs: build: runs-on: ubuntu-22.04 container: - # Advanced by .gitlab/devcontainer-to-ghcr.yml after main builds. + # Published by .github/workflows/devcontainer.yml. image: ghcr.io/datadog/httpd-datadog/devcontainer:main credentials: username: ${{ github.actor }} diff --git a/.github/workflows/system-tests.yml b/.github/workflows/system-tests.yml index d51ca7fd..05bb0082 100644 --- a/.github/workflows/system-tests.yml +++ b/.github/workflows/system-tests.yml @@ -23,7 +23,7 @@ jobs: build-artifacts: runs-on: ubuntu-22.04 container: - # Advanced by .gitlab/devcontainer-to-ghcr.yml after main builds. + # Published by .github/workflows/devcontainer.yml. image: ghcr.io/datadog/httpd-datadog/devcontainer:main credentials: username: ${{ github.actor }} diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ac8e54f5..7bb2d34f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,6 @@ include: - local: ".gitlab/ssi-package.yml" - local: ".gitlab/one-pipeline.locked.yml" - local: .gitlab/devcontainer.yml - - local: .gitlab/devcontainer-to-ghcr.yml variables: # Inputs to .gitlab/devcontainer.yml (the dd-repo-tools shared @@ -42,26 +41,6 @@ stages: - shared-pipeline-publish - aws -devcontainer-ghcr-policy-check: - stage: .pre - image: registry.ddbuild.io/images/dd-octo-sts-ci-base:2025.07-1 - tags: ["arch:amd64"] - needs: [] - rules: - - changes: - paths: - - .github/chainguard/self.gitlab.github-release.sts.yaml - - .gitlab/devcontainer-to-ghcr.yml - - .gitlab-ci.yml - compare_to: refs/heads/main - - when: never - script: - - git config --global --add safe.directory "$CI_PROJECT_DIR" - - > - dd-octo-sts check --repo "$CI_PROJECT_DIR" - --scope "$DEVCONTAINER_GHCR_SCOPE" --policy "$DEVCONTAINER_GHCR_POLICY" - --skip-token-check - # Template jobs (hidden, reusable) .build-template: stage: build diff --git a/.gitlab/devcontainer-to-ghcr.yml b/.gitlab/devcontainer-to-ghcr.yml deleted file mode 100644 index ec3197fb..00000000 --- a/.gitlab/devcontainer-to-ghcr.yml +++ /dev/null @@ -1,92 +0,0 @@ -# DO NOT EDIT. Synced from DataDog/dd-repo-tools by the -# dd-repo-tools repository-tools campaigner. -# Source of truth: https://github.com/DataDog/dd-repo-tools/blob/main/shared/devcontainer/devcontainer-to-ghcr.yml - -variables: - # The content hash remains available for reproducibility; the stable tag lets - # GitHub workflows consume new devcontainer builds without editing YAML. - DEVCONTAINER_GHCR_IMAGE: ghcr.io/datadog/${CI_PROJECT_NAME}/devcontainer - DEVCONTAINER_GHCR_STABLE_TAG: main - DEVCONTAINER_GHCR_SCOPE: DataDog/${CI_PROJECT_NAME} - DEVCONTAINER_GHCR_POLICY: self.gitlab.github-release - -devcontainer_to_ghcr: - stage: .pre - image: registry.ddbuild.io/images/dd-octo-sts-ci-base:2025.07-1 - tags: ["arch:amd64"] - interruptible: false - resource_group: devcontainer-ghcr - needs: - - job: devcontainer_image - artifacts: true - id_tokens: - DDOCTOSTS_ID_TOKEN: - aud: dd-octo-sts - variables: - DEVCONTAINER_GHCR_TOKEN_FILE: /tmp/devcontainer-ghcr-token - CRANE_VERSION: v0.20.3 - CRANE_LINUX_X86_64_SHA256: 36c67a932f489b3f2724b64af90b599a8ef2aa7b004872597373c0ad694dc059 - rules: - - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"' - - when: never - before_script: - - | - crane_archive=/tmp/go-containerregistry_Linux_x86_64.tar.gz - crane_bin_dir="$CI_PROJECT_DIR/.ci-bin" - curl -fsSL \ - "https://github.com/google/go-containerregistry/releases/download/${CRANE_VERSION}/go-containerregistry_Linux_x86_64.tar.gz" \ - -o "$crane_archive" - printf '%s %s\n' "$CRANE_LINUX_X86_64_SHA256" "$crane_archive" | sha256sum -c - - mkdir -p "$crane_bin_dir" - tar -xzf "$crane_archive" -C "$crane_bin_dir" crane - export PATH="$crane_bin_dir:$PATH" - crane version - - | - umask 077 - if [ -n "${GHCR_TOKEN:-}" ]; then - printf '%s' "$GHCR_TOKEN" > "$DEVCONTAINER_GHCR_TOKEN_FILE" - else - dd-octo-sts token \ - --scope "$DEVCONTAINER_GHCR_SCOPE" \ - --policy "$DEVCONTAINER_GHCR_POLICY" \ - > "$DEVCONTAINER_GHCR_TOKEN_FILE" - fi - test -s "$DEVCONTAINER_GHCR_TOKEN_FILE" - crane auth login ghcr.io \ - --username "${GHCR_USERNAME:-DataDog}" \ - --password-stdin < "$DEVCONTAINER_GHCR_TOKEN_FILE" - script: - - | - source_ref=${DEVCONTAINER_IMAGE_AMD64:-${DEVCONTAINER_IMAGE:-}} - if [ -z "$source_ref" ] || [ -z "${CI_IMAGE_HASH:-}" ]; then - echo "ERROR: devcontainer_image did not publish an amd64 OCI reference" >&2 - exit 1 - fi - - immutable_ref="${DEVCONTAINER_GHCR_IMAGE}:${CI_IMAGE_HASH}" - if crane digest "$immutable_ref" >/dev/null 2>&1; then - echo "GHCR cache hit: $immutable_ref" - else - echo "Publishing $source_ref -> $immutable_ref" - crane copy "$source_ref" "$immutable_ref" - fi - - source_digest=$(crane digest "$source_ref") - published_digest=$(crane digest "$immutable_ref") - if [ "$source_digest" != "$published_digest" ]; then - echo "ERROR: GHCR digest mismatch: $published_digest != $source_digest" >&2 - exit 1 - fi - - crane tag "$immutable_ref" "$DEVCONTAINER_GHCR_STABLE_TAG" - stable_ref="${DEVCONTAINER_GHCR_IMAGE}:${DEVCONTAINER_GHCR_STABLE_TAG}" - test "$(crane digest "$stable_ref")" = "$published_digest" - echo "Published $stable_ref@$published_digest" - after_script: - - '"$CI_PROJECT_DIR/.ci-bin/crane" auth logout ghcr.io || true' - - | - if [ -z "${GHCR_TOKEN:-}" ] && [ -s "$DEVCONTAINER_GHCR_TOKEN_FILE" ]; then - dd-octo-sts revoke --token "$(cat "$DEVCONTAINER_GHCR_TOKEN_FILE")" \ - || echo "Warning: token revocation failed" - fi - rm -f "$DEVCONTAINER_GHCR_TOKEN_FILE" diff --git a/doc/development.md b/doc/development.md index c5905a3d..17390cfb 100644 --- a/doc/development.md +++ b/doc/development.md @@ -132,6 +132,13 @@ make dev-shell GitLab CI status can be checked via `glab ci` on the [automated mirror](https://gitlab.ddbuild.io/DataDog/httpd-datadog). +The [Devcontainer workflow](../.github/workflows/devcontainer.yml) builds the amd64 image +directly in GitHub Actions and publishes it to `ghcr.io/datadog/httpd-datadog/devcontainer`. +Changes to the build inputs on `main` publish both a content hash tag and `:main`, which the +GitHub build and test workflows use. Pull requests build the image without publishing it. +Run the workflow manually on `main` to bootstrap or refresh the image. Manual runs on other +branches publish only the content hash tag. + ### Key Paths Inside the CI Image - `/httpd` — httpd source