diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index ff55b51aa..d591c4ed0 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -64,6 +64,7 @@ jobs: build-args: | APP_VERSION=${{ steps.docker_meta.outputs.version }} GIT_SHA=${{ github.sha }} + DOCKER_TAG=${{ steps.docker_meta.outputs.tags }} solo: runs-on: ubuntu-latest diff --git a/app/lib/usage_report.rb b/app/lib/usage_report.rb index 96a725d78..52861b00a 100644 --- a/app/lib/usage_report.rb +++ b/app/lib/usage_report.rb @@ -9,7 +9,9 @@ def self.generate report.version do |version| version.app Rails.application.config.app_version version.sha Rails.application.config.git_sha + version.image ENV.fetch("DOCKER_TAG", nil)&.split(":")&.first end + report.arch RUBY_PLATFORM end end diff --git a/docker/runtime.dockerfile b/docker/runtime.dockerfile index 0fe4ad031..bd97dd824 100644 --- a/docker/runtime.dockerfile +++ b/docker/runtime.dockerfile @@ -55,8 +55,10 @@ ENV RUBY_YJIT_ENABLE="1" ARG APP_VERSION ARG GIT_SHA +ARG DOCKER_TAG ENV APP_VERSION=$APP_VERSION ENV GIT_SHA=$GIT_SHA +ENV DOCKER_TAG=$DOCKER_TAG # Runtime environment variables ENV PORT=3214 diff --git a/spec/lib/usage_report_spec.rb b/spec/lib/usage_report_spec.rb index 86543d84f..6e87bb9f9 100644 --- a/spec/lib/usage_report_spec.rb +++ b/spec/lib/usage_report_spec.rb @@ -21,10 +21,27 @@ expect(parsed["id"]).to eq "guid-goes-here" end + it "includes architecture" do + stub_const("RUBY_PLATFORM", "test-arch") + expect(parsed["arch"]).to eq "test-arch" + end + it "includes application version" do expect(parsed["version"]["app"]).to eq "test" end + it "includes image type" do + ClimateControl.modify DOCKER_TAG: "ghcr.io/manyfold3d/manyfold:latest" do + expect(JSON.parse(described_class.generate)["version"]["image"]).to eq "ghcr.io/manyfold3d/manyfold" + end + end + + it "works if there is no image type" do + ClimateControl.modify DOCKER_TAG: nil do + expect(JSON.parse(described_class.generate)["version"]["image"]).to be_nil + end + end + it "includes git SHA" do expect(parsed["version"]["sha"]).to eq "deadbeef" end