Skip to content

Commit f6cb22b

Browse files
authored
Set container ENTRYPOINT. (#368)
Set the `imagecustomizer` executable as the default ENTRYPOINT for the container. Technically, the telemetry hopper is already the entrypoint. So, this change is actually just having the telemetry hopper call `imagecustomizer`, instead of requiring the user to pass in the command name. But when the telemetry hopper is removed, `imagecustomizer` will become the entrypoint. Also, update the `run.sh` script to include a copy of the telemetry hopper logic. Now, to use the `run.sh` script, the user must pass `--entrypoint /usr/local/bin/run.sh` to docker to override the default command.
1 parent 5a01237 commit f6cb22b

File tree

8 files changed

+32
-16
lines changed

8 files changed

+32
-16
lines changed

docs/imagecustomizer/how-to/azure-vm.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,13 @@ in front of any HTTP endpoints.
152152
5. Run Image Customizer to create the new image:
153153
154154
```bash
155-
IMG_CUSTOMIZER_TAG="mcr.microsoft.com/azurelinux/imagecustomizer:0.17.0"
155+
IMG_CUSTOMIZER_TAG="mcr.microsoft.com/azurelinux/imagecustomizer:0.18.0"
156156
docker run \
157157
--rm \
158158
--privileged=true \
159159
-v /dev:/dev \
160160
-v "$STAGE_DIR:/mnt/staging:z" \
161161
"$IMG_CUSTOMIZER_TAG" \
162-
imagecustomizer \
163162
--image-file "/mnt/staging/image.vhd" \
164163
--config-file "/mnt/staging/image-config.yaml" \
165164
--build-dir "/mnt/staging/build" \

docs/imagecustomizer/quick-start/quick-start.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The container is published to both:
2020
For example:
2121

2222
```text
23-
mcr.microsoft.com/azurelinux/imagecustomizer:0.17.0
23+
mcr.microsoft.com/azurelinux/imagecustomizer:0.18.0
2424
```
2525

2626
You can use the MCR REST API to query available and latest tags:
@@ -38,7 +38,7 @@ The container is published to both:
3838
For example:
3939

4040
```text
41-
ghcr.io/microsoft/imagecustomizer:0.17.0
41+
ghcr.io/microsoft/imagecustomizer:0.18.0
4242
```
4343

4444
## Prerequisites
@@ -74,8 +74,7 @@ The container is published to both:
7474
--privileged=true \
7575
-v /dev:/dev \
7676
-v "$HOME/staging:/mnt/staging:z" \
77-
mcr.microsoft.com/azurelinux/imagecustomizer:0.17.0 \
78-
imagecustomizer \
77+
mcr.microsoft.com/azurelinux/imagecustomizer:0.18.0 \
7978
--image-file "/mnt/staging/image.vhdx" \
8079
--config-file "/mnt/staging/image-config.yaml" \
8180
--build-dir "/build" \
@@ -101,7 +100,7 @@ The container is published to both:
101100
- `-v $HOME/staging:/mnt/staging:z`: Mounts a host directory (`$HOME/staging`) into the
102101
container. This can be used to easily pass files in and out of the container.
103102

104-
- `mcr.microsoft.com/azurelinux/imagecustomizer:0.17.0`: The container to run.
103+
- `mcr.microsoft.com/azurelinux/imagecustomizer:0.18.0`: The container to run.
105104

106105
- `imagecustomizer`: Specifies the executable to run within the container.
107106

@@ -118,15 +117,15 @@ The container is published to both:
118117
- `--output-image-file "/mnt/staging/out/image.vhdx"`: Output the customized image to
119118
the host's `$HOME/staging/out/image.vhdx` file path.
120119

121-
5. Use the customized image.
120+
4. Use the customized image.
122121

123122
The customized image is placed in the file that you specified with the
124123
`--output-image-file` parameter. You can now use this image as you see fit.
125124
(For example, boot it in a Hyper-V VM.)
126125

127126
## Helper script
128127

129-
`run-container.sh`
128+
Link: [run-container.sh](https://github.com/microsoft/azure-linux-image-tools/blob/main/toolkit/tools/imagecustomizer/container/run-container.sh)
130129

131130
This script wraps the Docker call. It is intended to make using the Image Customizer
132131
container a little easier.
@@ -135,7 +134,7 @@ For example, this is the equivalent call to the above example:
135134

136135
```bash
137136
run-container.sh \
138-
-t mcr.microsoft.com/azurelinux/imagecustomizer:0.17.0 \
137+
-t mcr.microsoft.com/azurelinux/imagecustomizer:0.18.0 \
139138
-i "$HOME/staging/image.vhdx" \
140139
-c "$HOME/staging/image-config.yaml" \
141140
-f vhdx \

docs/imagecustomizer/telemetry.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ docker run \
3131
--privileged=true \
3232
-v /dev:/dev \
3333
-v "$HOME/staging:/mnt/staging:z" \
34-
mcr.microsoft.com/azurelinux/imagecustomizer:0.17.0 \
35-
imagecustomizer \
34+
mcr.microsoft.com/azurelinux/imagecustomizer:0.18.0 \
3635
--image-file "/mnt/staging/image.vhdx" \
3736
--config-file "/mnt/staging/image-config.yaml" \
3837
--build-dir "/build" \

test/vmtests/vmtests/utils/imagecustomizer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ def run_image_customizer(
4949
container_output_image_path = container_output_image_dir.joinpath(output_image_path.name)
5050

5151
args = [
52-
"imagecustomizer",
5352
"--image-file",
5453
str(container_base_image_path),
5554
"--config-file",

toolkit/tools/imagecustomizer/container/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ if [[ "$ENABLE_TELEMETRY" == "true" ]] && [[ -n "$AZURE_MONITOR_CONNECTION_STRIN
2626
sleep 1
2727
fi
2828

29-
exec "$@"
29+
imagecustomizer "$@"

toolkit/tools/imagecustomizer/container/run-container.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ docker run --rm \
9292
-v $outputImageDir:$containerOutputDir:z \
9393
-v /dev:/dev \
9494
"$containerTag" \
95-
imagecustomizer \
9695
--image-file $containerInputImage \
9796
--config-file $containerInputConfig \
9897
--build-dir $containerBuildDir \

toolkit/tools/imagecustomizer/container/run.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ if [[ -z "$ARG_VERSION" ]]; then
6363
exit_with_usage "missing required argument: 'VERSION'"
6464
fi
6565

66+
ENABLE_TELEMETRY="${ENABLE_TELEMETRY:-true}"
67+
68+
# Check if --disable-telemetry flag is present in arguments
69+
for arg in "$@"; do
70+
if [[ "$arg" == "--disable-telemetry" ]]; then
71+
ENABLE_TELEMETRY=false
72+
break
73+
fi
74+
done
75+
6676
PLATFORM="linux/amd64"
6777
case "$(uname -m)" in
6878
aarch64|arm64)
@@ -136,4 +146,15 @@ else
136146
fi
137147
fi
138148

149+
# Start telemetry service if enabled and connection string is set
150+
if [[ "$ENABLE_TELEMETRY" == "true" ]] && [[ -n "$AZURE_MONITOR_CONNECTION_STRING" ]]; then
151+
152+
export OTEL_PORT=4317
153+
export OTEL_EXPORTER_OTLP_PROTOCOL="grpc"
154+
export OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:${OTEL_PORT}"
155+
156+
/opt/telemetry-venv/bin/python /usr/local/bin/telemetry_hopper.py --port $OTEL_PORT > /var/log/image_customizer_telemetry.log 2>&1 || true &
157+
sleep 1
158+
fi
159+
139160
imagecustomizer --image-file "$ARTIFACT_DIR/$IMAGE_FILE_NAME" "$@"

toolkit/tools/imagecustomizer/container/test-container.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ docker run --rm \
2828
-v "$inputConfigDir":"$containerInputConfigDir":z \
2929
-v "$outputImageDir":"$containerOutputDir":z \
3030
-v /dev:/dev \
31+
--entrypoint /usr/local/bin/run.sh \
3132
"$containerTag" \
32-
/usr/local/bin/run.sh \
3333
"3.0.latest" \
3434
--config-file "$containerInputConfig" \
3535
--build-dir "$containerBuildDir" \

0 commit comments

Comments
 (0)