Skip to content

Commit

Permalink
add docker structure test config
Browse files Browse the repository at this point in the history
  • Loading branch information
digorgonzola committed Oct 13, 2023
1 parent 04a1441 commit eec8025
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/README-tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Docker Image Structural Testing
The configuration file `test/config.yaml` defines various "structural" checks to perform on the docker image created by `../Dockerfile`.

The test require the use of the [container-structure-test](https://github.com/GoogleContainerTools/container-structure-test) from Google.

Follow their documentation to install.

## Usage
Generate your docker image using your preferred method e.g.
```shell
docker build -t api .
```

To run the tests against the image, run the following:
```shell
container-structure-test test --image api --config tests/config.yaml
```
49 changes: 49 additions & 0 deletions tests/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
schemaVersion: 2.0.0

commandTests:
- name: check psql is installed
command: psql
args: ["--version"]
exitCode: 0
- name: check django is installed
command: pip
args: ["show", "-q", "Django"]
exitCode: 0
- name: check djangorestframework is installed
command: pip
args: ["show", "-q", "djangorestframework"]
exitCode: 0
- name: check psycopg2 is installed
command: pip
args: ["show", "-q", "psycopg2"]
exitCode: 0
- name: check Pillow is installed
command: pip
args: ["show", "-q", "Pillow"]
exitCode: 0
- name: check uwsgi is installed
command: pip
args: ["show", "-q", "uwsgi"]
exitCode: 0
- name: check flake8 is installed
command: pip
args: ["show", "-q", "flake8"]
exitCode: 0

fileExistenceTests:
- name: entrypoint
path: /scripts/entrypoint.sh
shouldExist: true
permissions: "-rwxr-xr-x"
- name: requirements
path: /requirements.txt
shouldExist: true
permissions: "-rw-r--r--"
- name: /vol/web/media
path: /vol/web/media
shouldExist: true
permissions: "drwxr-xr-x"
- name: /vol/web/static
path: /vol/web/static
shouldExist: true
permissions: "drwxr-xr-x"

0 comments on commit eec8025

Please sign in to comment.