unstructured/scripts/docker-smoke-test.sh
Matt Robinson 9cd0e706ab
fix: reenable arm64 builds for docker (#3045)
### Summary

Closes #3034 and reenables ARM64 in the docker build and publish job.
This was taken out in #3039 because we've only build `libreoffice` for
AMD64 and not ARM64. If Chainguard publishes an `apk` for `libreoffice`,
we can support a Chainguard image for both architectures. The smoke test
now differs for both architectures, to reflect differences in the
directory structure.

### Testing

Build and publish ran successfully for ARM64 (job
[here](https://github.com/Unstructured-IO/unstructured/actions/runs/9129712470/job/25104907497))
and AMD64 (job
[here](https://github.com/Unstructured-IO/unstructured/actions/runs/9129712470/job/25104907826)).
2024-05-17 19:27:20 +00:00

54 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# Start the containerized repository and run ingest tests
# shellcheck disable=SC2317 # Shellcheck complains that trap functions are unreachable...
set -eux -o pipefail
CONTAINER_NAME=unstructured-smoke-test
DOCKER_IMAGE="${DOCKER_IMAGE:-unstructured:dev}"
# Change to the root of the repository
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
cd "$SCRIPT_DIR"/.. || exit 1
start_container() {
echo Starting container "$CONTAINER_NAME"
docker run -dt --rm --name "$CONTAINER_NAME" "$DOCKER_IMAGE"
}
await_container() {
echo Waiting for container to start
until [ "$(docker inspect -f '{{.State.Status}}' $CONTAINER_NAME)" == "running" ]; do
sleep 1
done
}
stop_container() {
echo Stopping container "$CONTAINER_NAME"
docker stop "$CONTAINER_NAME"
}
start_container
# Regardless of test result, stop the container
trap stop_container EXIT
await_container
# Run the tests
if [[ "$DOCKER_IMAGE" == *"arm64"* ]]; then
docker cp test_unstructured_ingest $CONTAINER_NAME:/home/notebook-user
docker exec -u root "$CONTAINER_NAME" /bin/bash -c "chown -R 1000:1000 /home/notebook-user/test_unstructured_ingest"
docker exec "$CONTAINER_NAME" /bin/bash -c "/home/notebook-user/test_unstructured_ingest/src/wikipedia.sh"
else
docker cp test_unstructured_ingest $CONTAINER_NAME:/app
docker cp requirements/ingest $CONTAINER_NAME:/app/requirements/ingest
docker exec -u root "$CONTAINER_NAME" /bin/bash -c "chown -R nonroot:nonroot /app/test_unstructured_ingest"
docker exec "$CONTAINER_NAME" /bin/bash -c "/app/test_unstructured_ingest/src/wikipedia.sh"
fi
result=$?
exit $result