Skip to content

Commit

Permalink
fix(docker): adding in docker image building
Browse files Browse the repository at this point in the history
  • Loading branch information
bassrock committed Oct 7, 2024
1 parent a9ab0e5 commit 13a7e68
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 10 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/docker-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Docker Images
on:
pull_request:
push:
branches:
- main
schedule: # Rebuild images nightly
- cron: '0 0 * * *'

jobs:
otel:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Base
uses: docker/build-push-action@v6
with:
push: ${{ github.ref == 'refs/heads/main' && true || false}}
platforms: linux/amd64,linux/arm64
tags: pocket/opentelemetry-collector-contrib
context: "{{defaultContext}}:images/otel"
13 changes: 8 additions & 5 deletions images/otel/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
FROM alpine:latest
# Use an alpine image as our base image, this allows us to define our own entry point script and have access to sh or bash, which the otel image does not have
FROM alpine:3

COPY --from=otel/opentelemetry-collector-contrib:latest /otelcol-contrib /otelcol-contrib
# Copy the otelcol-contrib binary from the official image
COPY --from=otel/opentelemetry-collector-contrib:0.111.0 /otelcol-contrib /otelcol-contrib

COPY otel-collector-config.yaml /etc/otelcol-contrib/config.yaml
COPY entrypont.sh /entrypont.sh
RUN chmod a+x /entrypont.sh
COPY entrypoint.sh /entrypoint.sh
RUN chmod a+x /entrypoint.sh

#Set the ENV variable for the google credentials that will be used by the google cloud exporter and mounted via an environment variable that will be saved to this file via our entrypoint script
ENV GOOGLE_APPLICATION_CREDENTIALS=/etc/otelcol-contrib/key.json
WORKDIR /

ENTRYPOINT [ "./entrypont.sh" ]
ENTRYPOINT [ "./entrypoint.sh" ]

CMD [ "/otelcol-contrib", "--config", "/etc/otelcol-contrib/config.yaml" ]
File renamed without changes.
4 changes: 4 additions & 0 deletions images/otel/otel-collector-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ processors:
- key: host.id
from_attribute: aws.ecs.task.id
action: upsert
# https://opentelemetry.io/docs/specs/semconv/resource/deployment-environment/
- key: deployment.environment.name
value: ${env:DEPLOYMENT_ENVIRONMENT_NAME}
action: upsert

service:
pipelines:
Expand Down
6 changes: 6 additions & 0 deletions infrastructure/client-api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,12 @@ class ClientAPI extends TerraformStack {
containerPort: 55681,
},
],
envVars: [
{
name: 'DEPLOYMENT_ENVIRONMENT_NAME',
value: config.tags.env_code,
},
],
secretEnvVars: [
{
name: 'GOOGLE_APPLICATION_CREDENTIALS_JSON',
Expand Down
6 changes: 6 additions & 0 deletions infrastructure/list-api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,12 @@ class ListAPI extends TerraformStack {
containerPort: 55681,
},
],
envVars: [
{
name: 'DEPLOYMENT_ENVIRONMENT_NAME',
value: config.tags.env_code,
},
],
secretEnvVars: [
{
name: 'GOOGLE_APPLICATION_CREDENTIALS_JSON',
Expand Down
6 changes: 6 additions & 0 deletions infrastructure/parser-graphql-wrapper/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,12 @@ class ParserGraphQLWrapper extends TerraformStack {
containerPort: 55681,
},
],
envVars: [
{
name: 'DEPLOYMENT_ENVIRONMENT_NAME',
value: config.tags.env_code,
},
],
secretEnvVars: [
{
name: 'GOOGLE_APPLICATION_CREDENTIALS_JSON',
Expand Down
11 changes: 6 additions & 5 deletions infrastructure/user-api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ class UserAPI extends TerraformStack {
containerPort: 55681,
},
],
envVars: [
{
name: 'DEPLOYMENT_ENVIRONMENT_NAME',
value: config.tags.env_code,
},
],
secretEnvVars: [
{
name: 'GOOGLE_APPLICATION_CREDENTIALS_JSON',
Expand Down Expand Up @@ -282,11 +288,6 @@ class UserAPI extends TerraformStack {
'logs:CreateLogStream',
'logs:DescribeLogStreams',
'logs:DescribeLogGroups',
'xray:PutTraceSegments',
'xray:PutTelemetryRecords',
'xray:GetSamplingRules',
'xray:GetSamplingTargets',
'xray:GetSamplingStatisticSummaries',
],
resources: ['*'],
effect: 'Allow',
Expand Down
5 changes: 5 additions & 0 deletions infrastructure/user-list-search/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ module "otel" {
}
}

environment = [{
name = "DEPLOYMENT_ENVIRONMENT_NAME",
value = local.tags.env_code,
}]

secrets = [{
name = "GOOGLE_APPLICATION_CREDENTIALS_JSON"
valueFrom = "${local.secret_path_shared}GCP_SA_TRACES:::"
Expand Down
6 changes: 6 additions & 0 deletions infrastructure/v3-proxy-api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ class Stack extends TerraformStack {
containerPort: 55681,
},
],
envVars: [
{
name: 'DEPLOYMENT_ENVIRONMENT_NAME',
value: config.tags.env_code,
},
],
secretEnvVars: [
{
name: 'GOOGLE_APPLICATION_CREDENTIALS_JSON',
Expand Down

0 comments on commit 13a7e68

Please sign in to comment.