Skip to content

Updated Docker configuration to support OpenTelemetry integration - #278

Open
Baibhab23 wants to merge 1 commit into
mainfrom
189-chore-profile-based-docker-build
Open

Baibhab23 wants to merge 1 commit into
mainfrom
189-chore-profile-based-docker-build

Conversation

@Baibhab23

Copy link
Copy Markdown
Collaborator

SUMMARY

What this pr is for?
Added a profile-based Docker build for pipeline-app so that the OpenTelemetry Java agent is only bundled when explicitly requested. Dev builds default to a leaner image with no agent overhead; the monitoring stack opts in via a build arg.

Issue Link

Link the Issue for which this PR was raised

Changes Summary

What changes has been done to solve the issue

Testing Done

How has the solution been tested?

yes

Pull Request Checklist

Tasks Yes/No
Issue Linked?
Timeline of the Issue is updated?
Do these changes affect local development in anyway? (if yes mention effects in additional comments)

Additional Comments

Anything else regarding this PR

@SuvabrataChowdhury SuvabrataChowdhury left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's prioritize it before the bazel PR as we need to unify different builds through bazel commands.

Instead of fragile if-else decisions, we can use native docker based target builds.

Comment thread pipeline/Dockerfile
WORKDIR /app
COPY --from=build /home/app/target/pipeline*.jar app.jar
COPY --from=build /home/app/target/agents/opentelemetry-javaagent.jar otel-agent.jar
RUN --mount=type=bind,from=build,source=/home/app/target,target=/build-output \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if it is a valid syntax.

Comment thread pipeline/Dockerfile
COPY --from=build /home/app/target/pipeline*.jar app.jar
COPY --from=build /home/app/target/agents/opentelemetry-javaagent.jar otel-agent.jar
RUN --mount=type=bind,from=build,source=/home/app/target,target=/build-output \
if [ "$ENABLE_OTEL" = "true" ] && [ -f /build-output/agents/opentelemetry-javaagent.jar ]; then \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to have a target build instead of this manual if-else routing. Docker natively supports target builds like this,

FROM node:22-alpine AS base
WORKDIR /app
COPY package*.json ./
RUN npm ci

FROM base AS dev
ENV NODE_ENV=development
COPY . .
CMD ["npm", "run", "dev"]

FROM base AS prod
ENV NODE_ENV=production
COPY . .
RUN npm run build
CMD ["node", "dist/server.js"]

The specific target can be provided like this,

docker build --target prod -t myapp:prod .
docker build --target dev -t myapp:dev .

Comment thread pipeline/entrypoint.sh

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not have unnecessary scripts for builds if it can be done natively with Docker.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[chore]: Profile based docker build

2 participants