Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding files to docker image generated by AshScriptPlugin #1502

Closed
mgralle opened this issue Apr 13, 2022 · 2 comments
Closed

Adding files to docker image generated by AshScriptPlugin #1502

mgralle opened this issue Apr 13, 2022 · 2 comments

Comments

@mgralle
Copy link

mgralle commented Apr 13, 2022

Expected behaviour

An additional jar file (for automatic instrumentation) should be placed in the docker image. I have tried two ways:

  1. By adding files through dockerCommands:
...,
Cmd("WORKDIR", "/opt/"),
ExecCmd("RUN", "wget", "https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar"),
...

Those of my targets that don't include AshScriptPlugin create docker images as indicated. However, those that do include AshScriptPlugin completely ignore the modified dockerCommands.

  1. As static alternative, I copied the downloaded opentelemetry-javaagent.jar directly into the folder <my-service>-impl/src/universal, since the documentation says "By default, all files found in the src/universal directory are included in the distribution". However, the file is again not included in the docker images generated with the AshScriptPlugin.

Actual behaviour

The docker image contains only the default AshScriptPlugin-generated content, not the opentelemetry-javaagent.jar.

Information

  • What sbt-native-packager are you using: 1.9.7
  • What sbt version: 1.5.8
  • What is your build system (e.g. Ubuntu, MacOS, Windows, Debian ): MacOS 12.2.1
  • What package are you building (e.g. docker, rpm, ...): docker
  • What version has your build tool (find out with e.g. rpm --version): Docker version 20.10.13, build a224086
  • What is your target system (e.g. Ubuntu 16.04, CentOS 7): NA
@mgralle
Copy link
Author

mgralle commented Apr 13, 2022

I am aware that this may not be a bug, but an intended feature of the plugin. Please indicate any workarounds!

@mgralle
Copy link
Author

mgralle commented Apr 13, 2022

I have found my mistake, it was about sbt scopes. The dockerCommands for the microservices that use AshScriptPlugin are not copied in from the other microservices, but created by AshScriptPlugin. So I had to edit the dockerCommands generated by AshScriptPlugin directly. FWIW, I did it this way:

lazy val otelCommands = Seq(
  Cmd("WORKDIR", "/opt/"),
  ExecCmd("RUN", "wget", "https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar"),
  Cmd("ENV", "JAVA_TOOL_OPTIONS=-javaagent:/opt/opentelemetry-javaagent.jar"),
  Cmd("ENV", "OTEL_TRACES_EXPORTER=jaeger"),
  Cmd("ENV", "OTEL_EXPORTER_JAEGER_ENDPOINT=collector.linkerd-jaeger.svc.cluster.local:55678")
)
...
dockerCommands := {
    dockerCommands.value.flatMap {
      // insert instrumentation commands in mainstage right before losing root privileges
      case down@Cmd("USER", "daemon") => otelCommands :+ down
      case other => Seq(other)
    }
  }

@mgralle mgralle closed this as completed Apr 13, 2022
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

No branches or pull requests

1 participant