Skip to content

Commit

Permalink
fixup:Ensure that all the output on bootstrap goes to stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Oct 5, 2023
1 parent 3ed298e commit 8ab626a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 76 deletions.
83 changes: 12 additions & 71 deletions .github/workflows/test_buildx_and_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,86 +20,27 @@ jobs:

- name: Run tests
run: |
set -x
set +e
# Verify that CLI execution only includes the expected output (if we discard stderr).
echo zero
docker run --rm --name test1 moodle-php-apache php /var/www/html/check-stderr.php 2>/dev/null
docker run --rm --name test1 stronk7/moodle-php-apache:dev php /var/www/html/check-stderr.php 2>/dev/null
echo one
stdout=$(docker run --rm --name test1 moodle-php-apache php /var/www/html/check-stderr.php 2>/dev/null)
stdout=$(docker run --rm --name test1 stronk7/moodle-php-apache:dev php /var/www/html/check-stderr.php 2>/dev/null)
echo two
[[ ${stdout} == "Hello World!" ]] && echo "OK" || echo "Fail"
echo three
# Verify that stderr still contains information about the bootstrap.
stdout=$(docker run --rm --name test1 moodle-php-apache php /var/www/html/check-stderr.php 2>&1)
stdout=$(docker run --rm --name test1 stronk7/moodle-php-apache:dev php /var/www/html/check-stderr.php 2>&1)
echo four
[[ ${stdout} =~ "Checking for php configuration" ]] && echo "OK" || echo "Fail"
echo five
- name: Display container logs on failure
if: failure()
run: |
docker logs test0
docker logs test1
- name: Cleanup docker images
run: |
docker rm -f test0
Publish:
# Completely avoid forks and pull requests to try this job.
if: github.repository_owner == 'moodlehq' && contains(fromJson('["push", "workflow_dispatch", "workflow_call"]'), github.event_name)
# Requires Test to pass
needs: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

# Calculate the tags to be pussed to the registries.
- name: Calculate image tag names
id: calculatetags
uses: docker/metadata-action@v4
with:
images: |
${{ env.DOCKERHUB_OWNER }}/${{ env.REPOSITORY }}
ghcr.io/${{ env.GH_OWNER }}/${{ env.REPOSITORY }}
flavor: |
latest=false
tags: |
type=raw,value=dev
# https://github.com/docker/setup-qemu-action#usage
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

# https://github.com/marketplace/actions/docker-setup-buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# https://github.com/docker/login-action#docker-hub
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# https://github.com/docker/login-action#github-container-registry
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# https://github.com/docker/build-push-action#multi-platform-image
- name: Build and publish to Docker Hub and Github registries
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.calculatetags.outputs.tags }}

# https://github.com/peter-evans/dockerhub-description
# Note that we only update the description with the master branch version.
- name: Set Docker Hub description from README.md
if: github.ref == 'refs/heads/master'
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ env.DOCKERHUB_OWNER }}/${{ env.REPOSITORY }}
docker rm -f test1
5 changes: 0 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ RUN apt-get update && apt-get install -y \
# For an example of php80-rc5 near complete, using pickle instead of pear/pecl, look to:
# https://github.com/stronk7/moodle-php-apache/tree/8.0-buster-pickle-version

# Generate all the UTF-8 locales.
ARG DEBIAN_FRONTEND=noninteractive
ADD root/tmp/setup/locales-gen.sh /tmp/setup/locales-gen.sh
RUN /tmp/setup/locales-gen.sh

# Setup the required extensions.
ADD root/tmp/setup/php-extensions.sh /tmp/setup/php-extensions.sh
RUN /tmp/setup/php-extensions.sh
Expand Down

0 comments on commit 8ab626a

Please sign in to comment.