fix: close #6 - find and build all Dockerfiles in subdirectories
CI docker-build job only checked root Dockerfile, but all Dockerfiles live in subdirs (scraper/, articleServer/, etc.). Now uses find to locate all Dockerfile/dockerfile variants and builds each in its directory context.
This commit is contained in:
parent
db7bbf5907
commit
930189ac4f
@ -92,13 +92,27 @@ jobs:
|
|||||||
git clone --depth 1 $GITEA_URL/$GITHUB_REPOSITORY $GITHUB_WORKSPACE
|
git clone --depth 1 $GITEA_URL/$GITHUB_REPOSITORY $GITHUB_WORKSPACE
|
||||||
git -C $GITHUB_WORKSPACE checkout $GITHUB_SHA 2>/dev/null || true
|
git -C $GITHUB_WORKSPACE checkout $GITHUB_SHA 2>/dev/null || true
|
||||||
|
|
||||||
- name: Build Docker image
|
- name: Build Docker images
|
||||||
if: always()
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
if [[ -f Dockerfile ]]; then
|
DOCKERFILES=$(find . -type f \( -name "Dockerfile" -o -name "dockerfile" \) 2>/dev/null)
|
||||||
docker build -t $GITHUB_REPOSITORY:test .
|
if [ -z "$DOCKERFILES" ]; then
|
||||||
else
|
|
||||||
echo "No Dockerfile found, skipping docker build"
|
echo "No Dockerfile found, skipping docker build"
|
||||||
|
else
|
||||||
|
echo "Found Dockerfiles:"
|
||||||
|
echo "$DOCKERFILES"
|
||||||
|
FAIL=0
|
||||||
|
while IFS= read -r df; do
|
||||||
|
DIR=$(dirname "$df")
|
||||||
|
NAME=$(basename "$DIR")
|
||||||
|
echo "Building $DIR/dockerfile as ${NAME}:test..."
|
||||||
|
docker build -t "${NAME}:test" "$DIR/" || FAIL=1
|
||||||
|
done <<< "$DOCKERFILES"
|
||||||
|
if [ $FAIL -ne 0 ]; then
|
||||||
|
echo "One or more Docker builds failed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "All Docker images built successfully"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
security:
|
security:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user