Skip to content

Commit 3d1a0c0

Browse files
committed
autoinstrumentation: install musl in Python Docker image
1 parent e9936df commit 3d1a0c0

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

autoinstrumentation/python/Dockerfile

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# To build one auto-instrumentation image for Python, please:
2-
# - Ensure the packages are installed in the `/autoinstrumentation` directory. This is required as when instrumenting the pod,
3-
# one init container will be created to copy all the content in `/autoinstrumentation` directory to your app's container. Then
2+
# - Ensure the packages are installed in the `/autoinstrumentation,{-musl}` directory. This is required as when instrumenting the pod,
3+
# one init container will be created to copy all the content in `/autoinstrumentation{,-musl}` directory to your app's container. Then
44
# update the `PYTHONPATH` environment variable accordingly. To achieve this, you can mimic the one in `autoinstrumentation/python/Dockerfile`
55
# by using multi-stage builds. In the first stage, install all the required packages in one custom directory with `pip install --target`.
6-
# Then in the second stage, copy the directory to `/autoinstrumentation`.
6+
# Then in the second stage, copy the directory to `/autoinstrumentation{,-musl}`.
77
# - Ensure you have `opentelemetry-distro` and `opentelemetry-instrumentation` or your customized alternatives installed.
88
# Those two packages are essential to Python auto-instrumentation.
9-
# - Grant the necessary access to `/autoinstrumentation` directory. `chmod -R go+r /autoinstrumentation`
9+
# - Grant the necessary access to `/autoinstrumentation{,-musl}` directory. `chmod -R go+r /autoinstrumentation`
1010
# - For auto-instrumentation by container injection, the Linux command cp is
1111
# used and must be availabe in the image.
1212
FROM python:3.11 AS build
@@ -17,8 +17,19 @@ ADD requirements.txt .
1717

1818
RUN mkdir workspace && pip install --target workspace -r requirements.txt
1919

20+
FROM python:3.11-alpine AS build-musl
21+
22+
WORKDIR /operator-build
23+
24+
ADD requirements.txt .
25+
26+
RUN apk add gcc python3-dev musl-dev linux-headers
27+
RUN mkdir workspace && pip install --target workspace -r requirements.txt
28+
2029
FROM busybox
2130

2231
COPY --from=build /operator-build/workspace /autoinstrumentation
32+
COPY --from=build-musl /operator-build/workspace /autoinstrumentation-musl
2333

2434
RUN chmod -R go+r /autoinstrumentation
35+
RUN chmod -R go+r /autoinstrumentation-musl

0 commit comments

Comments
 (0)