Skip to content

Commit 89c162f

Browse files
committed
Update Otel build
1 parent 4cc9d8f commit 89c162f

3 files changed

Lines changed: 50 additions & 29 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,16 @@ env:
4141
# IMAGE_OWNER: cogini
4242
# AWS ECR Docker repo "org" name (may be blank, otherwise must have trailing slash)
4343
ECR_IMAGE_OWNER: cogini/
44-
# ECR_IMAGE_OWNER: ""
44+
# ECR_IMAGE_OWNER: ''
4545
# Tag for release images, used to find the latest deployed image.
4646
IMAGE_TAG: latest
4747
IMAGE_VER: ${{ github.sha }}
48-
# Registry for test images
48+
# Registry for internal images
4949
REGISTRY: ghcr.io/
5050
# Registry for public images, default (blank) is docker.io
51-
# PUBLIC_REGISTRY: ""
52-
PUBLIC_REGISTRY: "ghcr.io/"
51+
# PUBLIC_REGISTRY: ''
52+
# Assume that base image has been synced to local registry
53+
PUBLIC_REGISTRY: 'ghcr.io/'
5354
AWS_OTEL_COLLECTOR_REPO_ORG: ${{ github.repository_owner }}
5455
POSTGRES_REPO_ORG: ${{ github.repository_owner }}
5556
RABBITMQ_REPO_ORG: ${{ github.repository_owner }}
@@ -64,7 +65,7 @@ env:
6465
# AWS default region
6566
# vars.AWS_REGION
6667
# AWS role allowing GitHub Actions to access resources and deploy
67-
# secrets.AWS_ROLE_TO_ASSUME: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/cogini-foo-dev-app-github-action
68+
# secrets.AWS_ROLE_TO_ASSUME: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/foo-${{ environment }}-github-action-role
6869
# S3 bucket where assets are deployed, e.g., for use with CloudFront CDN
6970
# vars.S3_BUCKET_ASSETS: cogini-foo-app-dev-app-assets
7071
# S3 bucket with data for testing

.github/workflows/otel.yml

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@ name: OpenTelemetry
55

66
on:
77
push:
8-
# branches:
9-
# - main
10-
# - qa
11-
# tags: [prod]
128
paths:
139
- .github/workflows/otel.yml
14-
- 'deploy/aws-otel-collector.Dockerfile'
10+
- deploy/aws-otel-collector.Dockerfile
1511
- 'otel/*'
1612
# pull_request:
1713
# # branches: [main]
@@ -24,22 +20,36 @@ env:
2420
IMAGE_NAME: aws-otel-collector
2521
# Name of org in GHCR Docker repository (must be lowercase)
2622
IMAGE_OWNER: ${{ github.repository_owner }}
27-
# IMAGE_OWNER: foo
28-
# ECR Docker repo org name (may be blank, otherwise must have trailing slash)
23+
# IMAGE_OWNER: cogini
24+
# AWS ECR Docker repo "org" name (may be blank, otherwise must have trailing slash)
2925
ECR_IMAGE_OWNER: cogini/
30-
# Tag for release images
26+
# ECR_IMAGE_OWNER: ''
27+
# Tag for release images, used to find the latest deployed image.
3128
# IMAGE_TAG: ${{ (github.ref == 'refs/heads/main' && 'staging') || (github.ref == 'refs/heads/qa' && 'qa') }}
3229
IMAGE_TAG: latest
33-
# Registry for test images
30+
IMAGE_VER: ${{ github.sha }}
31+
# Registry for internal images
3432
REGISTRY: ghcr.io/
35-
# Registry for public images, default is docker.io
36-
PUBLIC_REGISTRY: ''
33+
# Registry for public images, default (blank) is docker.io
34+
# PUBLIC_REGISTRY: ''
35+
# Assume that base image has been synced to local registry
36+
PUBLIC_REGISTRY: 'ghcr.io/'
37+
# Git "main" branch. This might be "master" for old repos
3738
MAIN_BRANCH: main
38-
# Give GitHub Actions access to AWS
39-
AWS_ENABLED: 1
40-
# AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
41-
# AWS_ROLE_TO_ASSUME: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/cogini-foo-dev-app-github-action
42-
# AWS_REGION: us-east-1
39+
# GitHub Environment secrets and variables
40+
# Docker Hub credentials to pull base images without rate limits
41+
# secrets.DOCKERHUB_USERNAME
42+
# secrets.DOCKERHUB_TOKEN
43+
# AWS Account
44+
# secrets.AWS_ACCOUNT_ID
45+
# AWS default region
46+
# vars.AWS_REGION
47+
# AWS role allowing GitHub Actions to access resources and deploy
48+
# secrets.AWS_ROLE_TO_ASSUME: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/foo-${{ environment }}-github-action-role
49+
# GitHub Advanced Security, free for open source, otherwise a paid feature
50+
# https://docs.github.com/en/get-started/learning-about-github/about-github-advanced-security
51+
# https://docs.github.com/en/code-security/code-scanning/integrating-with-code-scanning/sarif-support-for-code-scanning
52+
# https://docs.github.com/en/code-security/code-scanning/integrating-with-code-scanning/uploading-a-sarif-file-to-github
4353
# Docker
4454
DOCKER_BUILDKIT: '1'
4555
DOCKER_FILE: deploy/aws-otel-collector.Dockerfile
@@ -52,34 +62,36 @@ jobs:
5262
packages: write
5363
runs-on: ubuntu-latest
5464
environment: ${{ (github.ref_name == 'main' && 'staging') || (github.ref_name == 'qa' && 'qa') || (github.ref_name == 'prod' && 'production') }}
65+
env:
66+
AWS_ENABLED: '1'
5567
steps:
5668
- name: Log in to Docker Hub
57-
uses: docker/login-action@v3
69+
uses: docker/login-action@v4
5870
with:
5971
username: ${{ secrets.DOCKERHUB_USERNAME }}
6072
password: ${{ secrets.DOCKERHUB_TOKEN }}
6173

6274
- name: Configure AWS credentials
63-
if: ${{ env.AWS_ENABLED == 1 }}
64-
uses: aws-actions/configure-aws-credentials@v5
75+
if: env.AWS_ENABLED == '1'
76+
uses: aws-actions/configure-aws-credentials@v6
6577
with:
6678
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
6779
aws-region: ${{ vars.AWS_REGION }}
6880

6981
- name: Log in to Amazon ECR
70-
if: ${{ env.AWS_ENABLED == 1 }}
82+
if: env.AWS_ENABLED == '1'
7183
id: ecr-login
7284
uses: aws-actions/amazon-ecr-login@v2
7385

7486
- name: Set vars
75-
if: ${{ env.AWS_ENABLED == 1 }}
87+
if: env.AWS_ENABLED == '1'
7688
run: echo "ECR_REGISTRY=${{ steps.ecr-login.outputs.registry }}" >> "$GITHUB_ENV"
7789

7890
- name: Set vars
7991
run: echo "NOW=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_ENV"
8092

8193
- name: Check out source
82-
uses: actions/checkout@v4
94+
uses: actions/checkout@v6
8395

8496
- name: Set variables
8597
id: vars
@@ -100,11 +112,13 @@ jobs:
100112
driver-opts: network=host
101113

102114
- name: Build image and push
103-
if: ${{ env.AWS_ENABLED == 1 }}
115+
if: env.AWS_ENABLED == '1'
104116
uses: docker/build-push-action@v6
105117
env:
106-
REGISTRY: "${{ env.ECR_REGISTRY }}/"
118+
# REGISTRY: "${{ env.ECR_REGISTRY }}/"
107119
AWS_REGION: ${{ vars.AWS_REGION }}
120+
# https://hub.docker.com/r/amazon/aws-otel-collector/tags
121+
BASE_IMAGE_TAG: 'v0.47.0
108122
with:
109123
file: ${{ env.DOCKER_FILE }}
110124
context: .
@@ -121,6 +135,9 @@ jobs:
121135
org.opencontainers.image.created=${{ env.NOW }}
122136
org.opencontainers.image.revision=${{ github.sha }}
123137
org.opencontainers.image.version=${{ github.run_number }}
138+
app.kubernetes.io/name=${{ env.IMAGE_NAME }}
139+
app.kubernetes.io/part-of=${{ github.repository }}
140+
app.kubernetes.io/version=${{ github.run_number }}
124141
tags: |
125142
${{ env.ECR_REGISTRY }}/${{ env.ECR_IMAGE_OWNER }}${{ env.IMAGE_NAME }}:${{ github.sha }}
126143
${{ env.ECR_REGISTRY }}/${{ env.ECR_IMAGE_OWNER }}${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}

deploy/aws-otel-collector.Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Build AWS Distro for OpenTelemetry Collector image with custom configuration.
2+
13
# Docker registry for internal images, e.g., 123.dkr.ecr.ap-northeast-1.amazonaws.com/
24
# If blank, docker.io will be used. If specified, should have a trailing slash.
35
ARG REGISTRY=""
@@ -14,6 +16,7 @@ ARG AWS_REGION=us-east-1
1416
ARG BASE_IMAGE_TAG=v0.47.0
1517

1618
# FROM ${PUBLIC_REGISTRY}aws-observability/aws-otel-collector:${BASE_IMAGE_TAG}
19+
# https://hub.docker.com/r/amazon/aws-otel-collector/tags
1720
FROM ${PUBLIC_REGISTRY}${AWS_OTEL_COLLECTOR_REPO_ORG:-amazon}/aws-otel-collector:${BASE_IMAGE_TAG}
1821

1922
ARG AWS_REGION

0 commit comments

Comments
 (0)