Skip to content

Commit

Permalink
Finalize the Docker image and scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
mk-mxp committed Aug 10, 2024
1 parent b2a299e commit 15974db
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ tests/
# Ignore build details
.dockerignore
Dockerfile
vendor/*
composer.lock

# Ignore old PHPUnit log post-processor
junit-handler/
14 changes: 9 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,27 @@ RUN curl -L -o install-php-extensions \
&& install-php-extensions intl

COPY --from=composer:2.7.7 /usr/bin/composer /usr/local/bin/composer
RUN php --modules \
&& composer --version

WORKDIR /opt/test-runner
COPY . .
# composer warns about missing a "root version" to resolve dependencies. Fake to stop warning
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" \
&& php --modules \
&& composer --version \
&& COMPOSER_ROOT_VERSION=1.0.0 composer install --no-cache --no-dev --no-interaction --no-progress

FROM php:8.3.10-cli-alpine3.20 AS runtime

COPY --from=build /usr/bin/jo /usr/bin/jo
COPY --from=build /usr/local/lib/php/extensions /usr/local/lib/php/extensions
COPY --from=build /opt/test-runner /opt/test-runner

# Use the default production configuration
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" \
&& apk add --no-cache bash \
&& adduser -Ds /bin/bash appuser

WORKDIR /opt/test-runner
COPY . .
# composer warns about missing a "root version" to resolve dependencies. Fake to stop warning
# RUN COMPOSER_ROOT_VERSION=1.0.0 composer install --no-interaction --no-dev

USER appuser

Expand Down
2 changes: 1 addition & 1 deletion bin/run-tests-in-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ docker run \
--rm \
--network none \
--read-only \
--mount type=bind,src="${PWD}/tests",dst=/opt/test-runner/tests \
--mount type=tmpfs,dst=/tmp \
--volume "${PWD}/tests:/opt/test-runner/tests" \
--volume "${PWD}/bin/run-tests.sh:/opt/test-runner/bin/run-tests.sh" \
--workdir /opt/test-runner \
--entrypoint /opt/test-runner/bin/run-tests.sh \
Expand Down
9 changes: 0 additions & 9 deletions bin/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,6 @@ function main {
jo version=3 status=error message="${output//"$solution_dir/"/""}" tests="[]" > "${output_dir%/}/${EXERCISM_RESULTS}"
return 0;
fi

# # This catches runtime errors in "global student code" (during `require_once`)
# if [[ "${phpunit_exit_code}" -eq 2 ]]; then
# if ! grep -q '<testcase' "${output_dir%/}/${JUNIT_RESULTS}"; then
# output="${output#*" MB"}"
# jo version=3 status=error message="${output//"$solution_dir/"/""}" tests="[]" > "${output_dir%/}/${EXERCISM_RESULTS}"
# return 0;
# fi
# fi
}

function installed {
Expand Down

0 comments on commit 15974db

Please sign in to comment.