Skip to content

Commit

Permalink
Incorporating dev/10.3.0 history
Browse files Browse the repository at this point in the history
  • Loading branch information
clpetersonucf committed Nov 14, 2024
2 parents 1376564 + 28da569 commit 48fad22
Show file tree
Hide file tree
Showing 54 changed files with 422 additions and 403 deletions.
6 changes: 5 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,8 @@ LTI_KEY="materia-production-lti-key"
#GENERATION_API_KEY=
#GENERATION_API_VERSION=
#GENERATION_API_MODEL=
#GENERATION_LOG_STATS=true
#GENERATION_LOG_STATS=true

# webserver settings =======

#IS_SERVER_HTTPS=true
21 changes: 10 additions & 11 deletions .github/workflows/test_and_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,29 @@ jobs:
- name: Build App and Webserver Images
run: |
cd docker
docker compose build --no-cache webserver app
docker compose build --no-cache webserver app fakes3
- name: Push Dev App and Webserver Images
if: ${{ startsWith(github.ref, 'refs/tags/v') && (contains(github.ref, '-alpha') || contains(github.ref, '-rc')) }}
run: |
docker tag ucfopen/materia:app-dev ghcr.io/${{ github.repository_owner }}/materia:app-dev
docker tag ucfopen/materia:webserver-dev ghcr.io/${{ github.repository_owner }}/materia:webserver-dev
docker push ghcr.io/${{ github.repository_owner }}/materia:app-dev
docker push ghcr.io/${{ github.repository_owner }}/materia:webserver-dev
docker push ghcr.io/${{ github.repository_owner }}/materia:fake-s3-dev
- name: Push Stable App and Webserver Images
if: ${{ startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-alpha') && !contains(github.ref, '-rc') }}
run: |
docker tag ucfopen/materia:app-dev ghcr.io/${{ github.repository_owner }}/materia:app-stable
docker tag ucfopen/materia:webserver-dev ghcr.io/${{ github.repository_owner }}/materia:webserver-stable
docker push ghcr.io/${{ github.repository_owner }}/materia:app-dev
docker push ghcr.io/${{ github.repository_owner }}/materia:webserver-dev
docker tag ghcr.io/${{ github.repository_owner }}/materia:app-dev ghcr.io/${{ github.repository_owner }}/materia:app-stable
docker tag ghcr.io/${{ github.repository_owner }}/materia:webserver-dev ghcr.io/${{ github.repository_owner }}/materia:webserver-stable
docker push ghcr.io/${{ github.repository_owner }}/materia:app-stable
docker push ghcr.io/${{ github.repository_owner }}/materia:webserver-stable
- name: Push Versioned App and Webserver Images
run: |
docker tag ucfopen/materia:app-dev ghcr.io/${{ github.repository_owner }}/materia:app-${{ github.sha }}
docker tag ucfopen/materia:app-dev ghcr.io/${{ github.repository_owner }}/materia:app-${{ steps.tag_name.outputs.GIT_TAG }}
docker tag ucfopen/materia:webserver-dev ghcr.io/${{ github.repository_owner }}/materia:webserver-${{ github.sha }}
docker tag ucfopen/materia:webserver-dev ghcr.io/${{ github.repository_owner }}/materia:webserver-${{ steps.tag_name.outputs.GIT_TAG }}
docker tag ghcr.io/${{ github.repository_owner }}/materia:app-dev ghcr.io/${{ github.repository_owner }}/materia:app-${{ github.sha }}
docker tag ghcr.io/${{ github.repository_owner }}/materia:app-dev ghcr.io/${{ github.repository_owner }}/materia:app-${{ steps.tag_name.outputs.GIT_TAG }}
docker tag ghcr.io/${{ github.repository_owner }}/materia:webserver-dev ghcr.io/${{ github.repository_owner }}/materia:webserver-${{ github.sha }}
docker tag ghcr.io/${{ github.repository_owner }}/materia:webserver-dev ghcr.io/${{ github.repository_owner }}/materia:webserver-${{ steps.tag_name.outputs.GIT_TAG }}
docker push ghcr.io/${{ github.repository_owner }}/materia:app-${{ github.sha }}
docker push ghcr.io/${{ github.repository_owner }}/materia:app-${{ steps.tag_name.outputs.GIT_TAG }}
docker push ghcr.io/${{ github.repository_owner }}/materia:webserver-${{ github.sha }}
Expand Down
55 changes: 28 additions & 27 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
We publish production ready docker containers for each release in the [Materia GitHub Docker Repository](https://github.com/orgs/ucfopen/packages/container/package/materia). These images are built and published automatically using GitHub Actions on every tagged release.

```
docker pull ghcr.io/ucfopen/materia:webserver-v8.0.0
docker pull ghcr.io/ucfopen/materia:app-v8.0.0
docker pull ghcr.io/ucfopen/materia:webserver-stable
docker pull ghcr.io/ucfopen/materia:app-stable
```

## Container Architecture

1. [webserver (Nginx)](https://www.nginx.com/) as a web server (proxies to phpfpm for app and serves static files directly)
3. [app (PHP-FPM)](https://php-fpm.org/) manages the PHP processes for the application
4. [mysql](https://www.mysql.com/) for storing relational application data
5. [memcached](https://memcached.org/) for caching data and sessions
6. [fakeS3](https://github.com/jubos/fake-s3) mocks AWS S3 behavior for asset uploading
1. [webserver (Nginx)](https://www.nginx.com/) as a web server (proxies to phpfpm for app and serves static files directly).
3. [app (PHP-FPM)](https://php-fpm.org/) manages the PHP processes for the application.
4. [mysql](https://www.mysql.com/) for storing relational application data.
5. [memcached](https://memcached.org/) for caching data and sessions.
6. [fakeS3](https://github.com/jubos/fake-s3) mocks AWS S3 behavior for asset uploading. This should not be used in production.

## Setup

Expand All @@ -25,15 +25,15 @@ Please take note of the user accounts that are created for you in the install pr

* Run the containers after ./run_first.sh has finished
```
docker-compose up
docker compose up
```
* Run the servers in background
```
docker-compose up -d
docker compose up -d
```
* Tail logs from background process
```
docker-compose logs -f app
docker compose logs -f app
```
* Run commands on the app container (like php, composer, or fuelphp oil commands)
```
Expand All @@ -43,16 +43,17 @@ Please take note of the user accounts that are created for you in the install pr
```
* Stop containers (db data is retained)
```
docker-compose stop
docker compose stop
```
* Stop and destroy the containers (deletes database data!, first_run.sh required after)
```
docker-compose down
docker compose down
```
* Compile the javascript and sass
```
./run_build_assets.sh
```
_Note:_ this is more easily accomplished by running `yarn dev` from the root Materia directory locally.
* Install composer libraries
```
./run.sh composer install
Expand All @@ -65,25 +66,25 @@ Please take note of the user accounts that are created for you in the install pr
```
./run_tests.sh
```
* Run Tests for as like the CI server
```
./run_tests_ci.sh
```
* Run Tests with code coverage
```
./run_tests_coverage.sh
```
* Create a user based on your docker host machine's current user
```
$ iturgeon@ucf: ./run_create_me.sh
User Created: iturgeon password: kogneato
iturgeon now in role: super_user
iturgeon now in role: basic_author
$ kogneato@ucf: ./run_create_me.sh
User Created: kogneato password: max_power
kogneato now in role: super_user
kogneato now in role: basic_author
```
* Create the [default users outlined in the config](https://github.com/ucfopen/Materia/blob/master/fuel/app/config/materia.php#L56-L78)
```
./run_create_default_users.sh
```
* Create a user manually
```
./run.sh php oil r admin:new_user username firstname mi lastname email password
```
* Build a deployable materia package (zip w/ compiled assets, and dependencies; see [assets on our releases](https://github.com/ucfopen/Materia/releases))
```
./run_build_github_release_package.sh
Expand Down Expand Up @@ -112,13 +113,13 @@ If you wish to log into Materia, there are [3 default accounts created for you b
If you're wanting to update a php or mysql version, this can be done locally for testing before updating the global image.

1. finish your edits.
2. Execute `docker-compose build` to rebuild any images.
4. Removing any existing running container using that image: `docker-compose stop app` and `docker-compose rm app`
5. Start the desired container: `docker-compose up app`
2. Execute `docker compose build` to rebuild any images.
4. Removing any existing running container using that image: `docker compose stop app` and `docker compose rm app`
5. Start the desired container: `docker compose up app`

## Production Ready Docker Compose

If you plan on deploying a production server using these docker images, we suggest using docker-compose. You will probably want to have an external database service (like AWS's RDS), and you'll need a place to keep backups of any uploaded files.
If you plan on deploying a production server using these docker images, we suggest using docker compose. You will probably want to have an external database service (like AWS's RDS), and you'll need a place to keep backups of any uploaded files.

### Dynamic Files to Backup

Expand All @@ -137,7 +138,7 @@ version: '3.5'

services:
webserver:
image: ghcr.io/ucfopen/materia:webserver-v8.0.0
image: ghcr.io/ucfopen/materia:webserver-stable
ports:
# 443 would be terminated at the load balancer
# Some customization required to terminate 443 here (see dev nginx config)
Expand All @@ -153,7 +154,7 @@ services:
- app

app:
image: ghcr.io/ucfopen/materia:app-v8.0.0
image: ghcr.io/ucfopen/materia:app-stable
env_file:
# View Materia Readme for ENV vars
- .env
Expand Down Expand Up @@ -200,6 +201,6 @@ volumes:

### Troubleshooting

#### Table Not Found
#### Table Not Found or PDO Exceptions During Installation

When running fuelphp's install, it uses fuel/app/config/development/migrations.php file to know the current state of your database. Fuel assumes this file is truth, and won't create tables even on an empty database. You probably need to delete the file and run the setup scripts again. run_first.sh does this for you if needed.
3 changes: 1 addition & 2 deletions fuel/app/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
'Cache' => $materia_path.'/fuel/core/cache.php',
'Fuel\\Core\\Errorhandler' => $materia_path.'/fuel/core/errorhandler.php',
'Log' => $materia_path.'/fuel/core/log.php',
'TestCase' => $materia_path.'/fuel/core/testcase.php',
'Cookie' => $materia_path.'/fuel/core/cookie.php'
'TestCase' => $materia_path.'/fuel/core/testcase.php'
// TODO: build task that will resolve/populate all the classes in materia here
]);

Expand Down
1 change: 1 addition & 0 deletions fuel/app/classes/basetest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ protected function make_disposable_widget(string $name = 'TestWidget', bool $res
'is_editable' => true,
'in_catalog' => true,
'is_generable' => false,
'uses_prompt_generation' => false,
'restrict_publish' => $restrict_publish,
'api_version' => 2,
],
Expand Down
28 changes: 28 additions & 0 deletions fuel/app/classes/materia/api/v1.php
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,34 @@ static public function question_set_generate($inst_id, $widget_id, $topic, $incl
}
}

/**
* Endpoint to facilitate AI text generation for widgets
*
* @param string $prompt The prompt to generate.
* @return array An array to be passed back to the widget containing the response string
*/
static public function widget_prompt_generate($prompt)
{
// verify eligibility
if ( ! Widget_Question_Generator::is_enabled()) return Msg::failure();
if (\Service_User::verify_session() !== true) return Msg::no_login();

// prompt generation & response handling
$result = Widget_Question_Generator::generate_from_prompt($prompt);
if ( ! $result instanceof Msg && is_string($result))
{
return [
'success' => true,
'response' => $result
];
}
else
{
\Log::error(print_r($result, true));
return $result;
}
}

/**
* Gets the question with the given QID or an array of questions
* with the given ids (passed as an array)
Expand Down
97 changes: 0 additions & 97 deletions fuel/app/classes/materia/fuel/core/cookie.php

This file was deleted.

Loading

0 comments on commit 48fad22

Please sign in to comment.