Commit 25e82ef6 authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

Merge branch 'feat/source-date-epoch' into 'master'

feat: Add option to set image create time to Git commit time

See merge request to-be-continuous/cnb!47
parents b4e3a22f 9fbf4590
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ The CNB template uses some global configuration used throughout all jobs.
| --------------------- | -------------------------------------- | ----------------- |
| `builder-image` / `CNB_BUILDER_IMAGE` | The CNB builder image used to build your application image<br/>_depending on your needs, [choose the most appropriate one](https://paketo.io/docs/concepts/builders/#what-paketo-builders-are-available)_ | `docker.io/paketobuildpacks/builder-jammy-base:latest` <br/>[![Trivy Badge](https://to-be-continuous.gitlab.io/doc/secu/trivy-badge-CNB_BUILDER_IMAGE.svg)](https://to-be-continuous.gitlab.io/doc/secu/trivy-CNB_BUILDER_IMAGE) |
| `platform-api` / `CNB_PLATFORM_API` | The CNB [platform API version](https://github.com/buildpacks/spec/blob/main/platform.md#platform-api-version) | `0.9` |
| `source-date-epoch-enabled` / `CNB_SOURCE_DATE_EPOCH_ENABLED` | Enable setting [`SOURCE_DATE_EPOCH` to configure image create time](https://github.com/buildpacks/rfcs/blob/main/text/0103-source-date-epoch.md) based on Git commit date. | `false` |

### Available Builders

+5 −0
Original line number Diff line number Diff line
@@ -29,6 +29,11 @@
      "default": "0.9",
      "advanced": true
    },
    {
      "name": "CNB_SOURCE_DATE_EPOCH_ENABLED",
      "description": "Enable setting [`SOURCE_DATE_EPOCH` environment variable](https://github.com/buildpacks/rfcs/blob/main/text/0103-source-date-epoch.md) based on commit date",
      "default": "false"
    },
    {
      "name": "CNB_SNAPSHOT_IMAGE",
      "description": "CNB snapshot image",
+14 −0
Original line number Diff line number Diff line
@@ -31,6 +31,10 @@ spec:
    platform-api:
      description: The CNB [platform API version](https://github.com/buildpacks/spec/blob/main/platform.md#platform-api-version)
      default: '0.9'
    source-date-epoch-enabled:
      description: Enable setting SOURCE_DATE_EPOCH environment variable based on commit date
      type: boolean
      default: false
    snapshot-image:
      description: CNB snapshot image
      default: $CI_REGISTRY_IMAGE/snapshot:$CI_COMMIT_REF_SLUG
@@ -134,6 +138,9 @@ variables:
  # default CNB platform API version
  CNB_PLATFORM_API: $[[ inputs.platform-api ]]

  # set SOURCE_DATE_EPOCH based on commit date
  CNB_SOURCE_DATE_EPOCH_ENABLED: $[[ inputs.source-date-epoch-enabled ]]

  # absolute root directory in final image
  CNB_SRC_APP_DIR: $[[ inputs.src-app-dir ]]
  # default final image hierarchy root dir
@@ -687,6 +694,13 @@ cnb-build:
      then
        export CNB_LOG_LEVEL="debug"
      fi
    # maybe set SOURCE_DATE_EPOCH
    - |
      if [[ "$CNB_SOURCE_DATE_EPOCH_ENABLED" == "true" ]]
      then
        export SOURCE_DATE_EPOCH=$(date -d "$CI_COMMIT_TIMESTAMP" +%s)
        log_info "SOURCE_DATE_EPOCH set to: \\e[33;1m${SOURCE_DATE_EPOCH}\\e[0m"
      fi
    # make local platform
    - mk_platform
    # build