Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update actions versions and add tag for security scanning #166

Merged
merged 5 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions .github/workflows/build_docker_hub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ jobs:
build_for_docker_hub:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
Expand All @@ -31,8 +28,10 @@ jobs:
run: echo "${{ steps.yaml-data.outputs.data }}"

- name: Build and push
uses: docker/build-push-action@v3
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: uclalibrary/terra:${{ steps.yaml-data.outputs.data }}
tags: |
uclalibrary/terra:${{ steps.yaml-data.outputs.data }}
uclalibrary/terra:scan
4 changes: 2 additions & 2 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Check out code
uses: actions/checkout@v3
- name: Build and run containers
uses: isbang/compose-action@v1.4.1
uses: hoverkraft-tech/compose-action@v2.0.1
with:
compose-file: "./docker-compose.yml"
# --build to use current code, not pull image... may not work
Expand All @@ -21,4 +21,4 @@ jobs:
run: sleep 10
- name: Run tests
# Use exec -T to avoid creating unusable pseudo-TTY
run: docker-compose exec -T django python manage.py test
run: docker compose exec -T django python manage.py test
53 changes: 0 additions & 53 deletions .travis/build_and_test.sh

This file was deleted.

34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,22 @@ Travel & Entertainment Requests & Reports Application

3. Rebuild docker environment. This will pull images from Docker Hub.

$ docker-compose build
$ docker compose build

4. Start docker containers, running in the background.

$ docker-compose up -d
$ docker compose up -d

***Note:*** Steps 3-4 can be combined, as

$ docker-compose up --build -d
$ docker compose up --build -d

***Note:*** Starting the containers applies any pending migrations and loads the `sample_data` fixture.
It may take 15-20 seconds from the time the containers start until the application is available.

5. Create a django superuser if desired, or run any other manage.py command the same way.

$ docker-compose exec django python manage.py createsuperuser
$ docker compose exec django python manage.py createsuperuser

6. Connect to the application as usual, though if running docker in a VM you may need to forward ports to your host OS.

Expand All @@ -84,7 +84,7 @@ It may take 15-20 seconds from the time the containers start until the applicati

7. Stop containers - shut down django and mysql

$ docker-compose down
$ docker compose down

***Note:*** Database changes are not retained when the containers are stopped.

Expand All @@ -96,50 +96,50 @@ It may take 15-20 seconds from the time the containers start until the applicati

1. Create a superuser

$ docker-compose exec django python manage.py createsuperuser
$ docker compose exec django python manage.py createsuperuser

2. Work with the underlying database (does not currently work in Docker environment)

$ docker-compose exec django python manage.py dbshell
$ docker compose exec django python manage.py dbshell

#### Migrations

When you change the Django models, you need to update the tables in the database by:

1. Creating a migration file

$ docker-compose exec django python manage.py makemigrations
$ docker compose exec django python manage.py makemigrations

2. Running that migration

$ docker-compose exec django python manage.py migrate
$ docker compose exec django python manage.py migrate

***Note:*** Always remember to check for new migrations when you pull down code from master. Or restart the Docker containers to apply all migrations.

### Testing Your Work

1. Use the Django REPL

$ docker-compose exec django python manage.py shell
$ docker compose exec django python manage.py shell

2. Validate your code

$ docker-compose exec django python manage.py check
$ docker compose exec django python manage.py check

3. Functional tests: Run the terra test suite

$ docker-compose exec django python manage.py test terra
$ docker compose exec django python manage.py test terra

4. Static code analysis: Run pyflakes

$ docker-compose exec django pyflakes terra
$ docker compose exec django pyflakes terra

5. Load different data (sample data is loaded automatically if working in Docker environment)

$ docker-compose exec django python manage.py flush
$ docker-compose exec django python manage.py loaddata data_file (must be in terra/fixtures directory)
$ docker compose exec django python manage.py flush
$ docker compose exec django python manage.py loaddata data_file (must be in terra/fixtures directory)

6. View the logs

$ docker-compose logs django (or docker-compose logs db)
$ docker-compose logs -f django (to tail the logs continuously; press CTRL-C to exit)
$ docker compose logs django (or docker compose logs db)
$ docker compose logs -f django (to tail the logs continuously; press CTRL-C to exit)
2 changes: 1 addition & 1 deletion charts/prod-terra-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ replicaCount: 1

image:
repository: uclalibrary/terra
tag: v1.1.2
tag: v1.1.3
pullPolicy: Always

nameOverride: ""
Expand Down
Loading