Skip to content

Commit

Permalink
[chore] build images for PRs (#955)
Browse files Browse the repository at this point in the history
* [chore] build images for PRs

* Add missing "on:"

* Fix input type

* Add license header

* Do not fail fast

* test: comment cache-from

* Revert: test: comment cache-from

* Comment featureflagservice build

* Revert "[cartservice] Update OTel .NET to 1.5.1 (#957)"

This reverts commit 814a4e9.

---------

Co-authored-by: Austin Parker <[email protected]>
  • Loading branch information
pellared and austinlparker committed Jul 13, 2023
1 parent 814a4e9 commit 9f8806f
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 124 deletions.
133 changes: 133 additions & 0 deletions .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0
on:
workflow_call:
inputs:
push:
description: Should the images be pushed
default: false
required: false
type: boolean
version:
description: The version used when tagging the image
default: dev
required: false
type: string

jobs:
build_and_push_images:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

env:
RELEASE_VERSION: "${{ github.event.release.tag_name }}"
DOCKERHUB_REPO: "otel/demo"
GHCR_REPO: "ghcr.io/open-telemetry/demo"

strategy:
fail-fast: false
matrix:
file_tag:
- file: ./src/adservice/Dockerfile
tag_suffix: adservice
context: ./
- file: ./src/cartservice/src/Dockerfile
tag_suffix: cartservice
context: ./
- file: ./src/checkoutservice/Dockerfile
tag_suffix: checkoutservice
context: ./
- file: ./src/currencyservice/Dockerfile
tag_suffix: currencyservice
context: ./src/currencyservice
- file: ./src/emailservice/Dockerfile
tag_suffix: emailservice
context: ./src/emailservice
# TODO: https://github.com/open-telemetry/opentelemetry-demo/issues/956
# - file: ./src/featureflagservice/Dockerfile
# tag_suffix: featureflagservice
# context: ./
- file: ./src/frontend/Dockerfile
tag_suffix: frontend
context: ./
- file: ./src/frontendproxy/Dockerfile
tag_suffix: frontendproxy
context: ./
- file: ./src/loadgenerator/Dockerfile
tag_suffix: loadgenerator
context: ./
- file: ./src/paymentservice/Dockerfile
tag_suffix: paymentservice
context: ./
- file: ./src/productcatalogservice/Dockerfile
tag_suffix: productcatalogservice
context: ./
- file: ./src/quoteservice/Dockerfile
tag_suffix: quoteservice
context: ./
- file: ./src/shippingservice/Dockerfile
tag_suffix: shippingservice
context: ./
- file: ./src/recommendationservice/Dockerfile
tag_suffix: recommendationservice
context: ./
- file: ./src/kafka/Dockerfile
tag_suffix: kafka
context: ./
- file: ./src/accountingservice/Dockerfile
tag_suffix: accountingservice
context: ./
- file: ./src/frauddetectionservice/Dockerfile
tag_suffix: frauddetectionservice
context: ./
- file: ./src/frontend/Dockerfile.cypress
tag_suffix: frontend-tests
context: ./
- file: ./test/Dockerfile
tag_suffix: integrationTests
context: ./

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
if: ${{ inputs.push }}

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
if: ${{ inputs.push }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
config-inline: |
[worker.oci]
max-parallelism = 2
- name: Matrix Build and push demo images
uses: docker/[email protected]
with:
context: ${{ matrix.file_tag.context }}
file: ${{ matrix.file_tag.file }}
platforms: linux/amd64,linux/arm64
push: ${{ inputs.push }}
tags: |
${{ env.DOCKERHUB_REPO }}:${{ inputs.version }}-${{matrix.file_tag.tag_suffix }}
${{ env.GHCR_REPO }}:${{ inputs.version }}-${{ matrix.file_tag.tag_suffix }}
cache-from: type=gha
cache-to: type=gha
3 changes: 3 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
branches: [ main ]

jobs:
build_images:
uses: ./.github/workflows/build-images.yml

markdownlint:
runs-on: ubuntu-latest
steps:
Expand Down
117 changes: 4 additions & 113 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,116 +8,7 @@ on:

jobs:
build_and_push_images:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

env:
RELEASE_VERSION: "${{ github.event.release.tag_name }}"
DOCKERHUB_REPO: "otel/demo"
GHCR_REPO: "ghcr.io/open-telemetry/demo"

strategy:
matrix:
file_tag:
- file: ./src/adservice/Dockerfile
tag_suffix: adservice
context: ./
- file: ./src/cartservice/src/Dockerfile
tag_suffix: cartservice
context: ./
- file: ./src/checkoutservice/Dockerfile
tag_suffix: checkoutservice
context: ./
- file: ./src/currencyservice/Dockerfile
tag_suffix: currencyservice
context: ./src/currencyservice
- file: ./src/emailservice/Dockerfile
tag_suffix: emailservice
context: ./src/emailservice
- file: ./src/featureflagservice/Dockerfile
tag_suffix: featureflagservice
context: ./
- file: ./src/frontend/Dockerfile
tag_suffix: frontend
context: ./
- file: ./src/frontendproxy/Dockerfile
tag_suffix: frontendproxy
context: ./
- file: ./src/loadgenerator/Dockerfile
tag_suffix: loadgenerator
context: ./
- file: ./src/paymentservice/Dockerfile
tag_suffix: paymentservice
context: ./
- file: ./src/productcatalogservice/Dockerfile
tag_suffix: productcatalogservice
context: ./
- file: ./src/quoteservice/Dockerfile
tag_suffix: quoteservice
context: ./
- file: ./src/shippingservice/Dockerfile
tag_suffix: shippingservice
context: ./
- file: ./src/recommendationservice/Dockerfile
tag_suffix: recommendationservice
context: ./
- file: ./src/kafka/Dockerfile
tag_suffix: kafka
context: ./
- file: ./src/accountingservice/Dockerfile
tag_suffix: accountingservice
context: ./
- file: ./src/frauddetectionservice/Dockerfile
tag_suffix: frauddetectionservice
context: ./
- file: ./src/frontend/Dockerfile.cypress
tag_suffix: frontend-tests
context: ./
- file: ./test/Dockerfile
tag_suffix: integrationTests
context: ./

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
if: github.event_name != 'pull_request'

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
if: github.event_name != 'pull_request'

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
config-inline: |
[worker.oci]
max-parallelism = 2
- name: Matrix Build and push demo images
uses: docker/[email protected]
with:
context: ${{ matrix.file_tag.context }}
file: ${{ matrix.file_tag.file }}
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ env.DOCKERHUB_REPO }}:${{ env.RELEASE_VERSION || 'pr' }}-${{matrix.file_tag.tag_suffix }}
${{ env.GHCR_REPO }}:${{ env.RELEASE_VERSION || 'pr' }}-${{ matrix.file_tag.tag_suffix }}
cache-from: type=gha
cache-to: type=gha
uses: ./.github/workflows/build-images.yml
with:
push: true
version: ${{ github.event.release.tag_name }}"
2 changes: 0 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ release.
([#935](https://github.com/open-telemetry/opentelemetry-demo/pull/935))
* [cartservice] update service to .NET 7
([#942](https://github.com/open-telemetry/opentelemetry-demo/pull/942))
* [cartservice] update .NET package to 1.5.1 release
([#935](https://github.com/open-telemetry/opentelemetry-demo/pull/957))
* Introduce minimal mode to run demo
([#872](https://github.com/open-telemetry/opentelemetry-demo/pull/872))
* [frontendproxy]Envoy expose a route for the collector to route frontend spans
Expand Down
4 changes: 2 additions & 2 deletions src/cartservice/src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.

# https://mcr.microsoft.com/v2/dotnet/sdk/tags/list
FROM mcr.microsoft.com/dotnet/sdk:7.0.305 AS builder
FROM mcr.microsoft.com/dotnet/sdk:7.0.304 AS builder

WORKDIR /usr/src/app/

Expand All @@ -31,7 +31,7 @@ RUN \
# -----------------------------------------------------------------------------

# https://mcr.microsoft.com/v2/dotnet/runtime-deps/tags/list
FROM mcr.microsoft.com/dotnet/runtime-deps:7.0.8-alpine3.18
FROM mcr.microsoft.com/dotnet/runtime-deps:7.0.7-alpine3.17

WORKDIR /usr/src/app/
COPY --from=builder /cartservice/ ./
Expand Down
10 changes: 5 additions & 5 deletions src/cartservice/src/cartservice.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Grpc.AspNetCore" Version="2.54.0" />
<PackageReference Include="Grpc.AspNetCore.HealthChecks" Version="2.54.0" />
<PackageReference Include="StackExchange.Redis" Version="2.6.116" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.5.1" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.5.1" />
<PackageReference Include="Grpc.AspNetCore" Version="2.53.0" />
<PackageReference Include="Grpc.AspNetCore.HealthChecks" Version="2.53.0" />
<PackageReference Include="StackExchange.Redis" Version="2.6.111" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.5.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.5.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.5.0-beta.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.5.0-beta.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.5.0-beta.1" />
Expand Down
4 changes: 2 additions & 2 deletions src/cartservice/tests/cartservice.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Grpc.Net.Client" Version="2.54.0" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="7.0.8" />
<PackageReference Include="Grpc.Net.Client" Version="2.53.0" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="7.0.7" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
Expand Down

0 comments on commit 9f8806f

Please sign in to comment.