Skip to content

Commit

Permalink
Add support for building the docker image
Browse files Browse the repository at this point in the history
* support local image build.

* Test tripaldocker build clause.

* Add build-image and dockerfile options.
  • Loading branch information
laceysanderson authored May 19, 2023
1 parent 890d01a commit 80f85d8
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 5 deletions.
57 changes: 55 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
on: [push]

jobs:
test_action_job:
test_all_defaults:
name: "Run using all defaults"
runs-on: ubuntu-latest
steps:
# To use this repository's private action,
Expand All @@ -20,4 +21,56 @@ jobs:
with:
directory-name: tripal
modules: tripal
phpunit-command-options: '--testsuite tripal'
phpunit-command-options: '--filter testTripalAdminPages'
test_all_provided:
name: "Run providing all inputs"
runs-on: ubuntu-latest
steps:
# To use this repository's private action,
# you must check out the repository
- name: Checkout
uses: actions/checkout@v3
- name: Clone Tripal for testing purposes
run: |
git clone https://github.com/tripal/tripal.git tmp
cd tmp
git checkout 4.x
mv * ../
ls ../
- name: Run the action step
uses: ./ # Uses an action in the root directory
with:
directory-name: tripal
modules: tripal
php-version: "8.1"
pgsql-version: "13"
drupal-version: "10.0.x"
phpunit-command-options: '--filter testTripalAdminPages'
build-image: true
dockerfile: "tripaldocker/Dockerfile-php8.1-pgsql13"
test_dockfile_tripaldocker:
name: "Run Build Tripaldocker"
runs-on: ubuntu-latest
steps:
# To use this repository's private action,
# you must check out the repository
- name: Checkout
uses: actions/checkout@v3
- name: Clone Tripal for testing purposes
run: |
git clone https://github.com/tripal/tripal.git tmp
cd tmp
git checkout 4.x
mv * ../
ls ../
- name: Run the action step
uses: ./ # Uses an action in the root directory
with:
directory-name: tripal
modules: tripal
php-version: "8.1"
pgsql-version: "13"
drupal-version: "10.0.x"
phpunit-command-options: '--filter testTripalAdminPages'
build-image: true
dockerfile: "UseTripalDockerBackupClause"
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ A string to be appended to the end of the PHPUnit command. See the following exa

For a full listing of options for the PHPUnit [see the docs](https://docs.phpunit.de/en/9.6/textui.html).

### `build-image`

Indicates whether you would like to build the docker based on your code (true) or pull an existing image (false).

**Default Value:** false

### `dockerfile`

The path and file name for the dockerfile (relative to the root of your checkedout module code) to use with the build-image. If build-image is false, then this option will simply be ignored.

Additionally, there is a backup clause for use with the Tripal core repository that will use the other options to choose a docker image at tripaldocker/ and provide the options needed for core. This will only be triggered if the value passed to this option does not exist and the composed tripaldocker dockerfile does.

**Default Value:** Dockerfile

## Outputs

*None yet implemented.*
Expand Down
29 changes: 26 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,48 @@ inputs:
description: "A string providing any options you would like added to the phpunit command."
required: false
default: ' '
build-image:
description: "Indicates whether you would like to build the docker based on your code (true) or pull an existing image (false)."
required: true
default: false
dockerfile:
description: "The relative path and file name for the dockerfile to use with build-image."
required: true
default: 'Dockerfile'
runs:
using: "composite"
steps:
# Here we pull the development tripaldocker image for this combo
- name: Pull TripalDocker Image
if: ${{ inputs.build-image == 'false' }}
shell: bash
env:
IMAGE_TAG: "drupal${{ inputs.drupal-version }}-php${{ inputs.php-version }}-pgsql${{ inputs.pgsql-version }}"
run: |
docker pull tripalproject/tripaldocker:$IMAGE_TAG
docker image tag tripalproject/tripaldocker:$IMAGE_TAG testing:localdocker
- name: Build Local Docker Image
if: ${{ inputs.build-image == 'true' }}
shell: bash
run: |
TRIPALDOCKER="tripaldocker/Dockerfile-php${{ inputs.php-version }}-pgsql${{ inputs.pgsql-version }}"
if [ -f "${{ inputs.dockerfile }}" ]; then
docker build --tag=testing:localdocker \
--build-arg drupalversion="${{ inputs.drupal-version }}" \
--build-arg chadoschema='testchado' ./
elif [ -f "$TRIPALDOCKER" ]; then
docker build --tag=testing:localdocker \
--build-arg drupalversion="${{ inputs.drupal-version }}" \
--build-arg chadoschema='testchado' ./ \
--file $TRIPALDOCKER
fi
# Just spin up docker the good ol' fashion way
# mounting our currently checked out package inside the docker container.
- name: Spin up Docker locally
shell: bash
env:
IMAGE_TAG: "drupal${{ inputs.drupal-version }}-php${{ inputs.php-version }}-pgsql${{ inputs.pgsql-version }}"
run: |
docker run --publish=80:80 --name=tripaldocker -tid \
--volume=`pwd`:/var/www/drupal9/web/modules/contrib/${{ inputs.directory-name }} tripalproject/tripaldocker:$IMAGE_TAG
--volume=`pwd`:/var/www/drupal9/web/modules/contrib/${{ inputs.directory-name }} testing:localdocker
# Install the modules
- name: Install our package in Docker
if: "${{ inputs.modules != '' }}"
Expand Down

0 comments on commit 80f85d8

Please sign in to comment.