Skip to content

Commit

Permalink
Merge pull request #881 from ucfopen/issue/851-docker-compose-v2
Browse files Browse the repository at this point in the history
Modifications to support Docker Compose V2
  • Loading branch information
bagofarms authored Jan 24, 2023
2 parents fdec883 + 2c1c0be commit def169e
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 50 deletions.
6 changes: 3 additions & 3 deletions .env → .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ APP_SECRET=eb2f09f8a21b0b7c57b9fc36eee250eb
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# For a PostgreSQL database, use: "postgresql://db_user:[email protected]:5432/db_name?serverVersion=11&charset=utf8"
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#DATABASE_URL=mysql://root:root@127.0.0.1:3306/udoit3
DATABASE_URL=mysql://root:root@db:3306/udoit3
###< doctrine/doctrine-bundle ###
### PRIVATE KEY PASSWORD: UDOIT3.0 ###

Expand Down Expand Up @@ -152,9 +152,9 @@ DATE_FORMAT="Y-m-d"

###> base url ###
# Base URL for client callbacks
BASE_URL=""
BASE_URL="http://127.0.0.1:8000/udoit3"
# Webpack public path
WEBPACK_PUBLIC_PATH="/build"
WEBPACK_PUBLIC_PATH="/udoit3/build"
###> base url ###

###> user name storage ###
Expand Down
14 changes: 0 additions & 14 deletions .env.local.example

This file was deleted.

10 changes: 4 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@ jobs:

- name: Build Image
run: |
cp .env.local.example .env.local
docker-compose -f docker-compose.nginx.yml build
docker-compose -f docker-compose.nginx.yml run composer composer install --no-dev --no-interaction --no-progress --optimize-autoloader
docker-compose -f docker-compose.nginx.yml run yarn bash -c 'cd /app && yarn install && yarn build'
cp .env.example .env
docker compose -f docker-compose.nginx.yml build
docker compose -f docker-compose.nginx.yml run composer composer install --no-dev --no-interaction --no-progress --optimize-autoloader
docker compose -f docker-compose.nginx.yml run yarn bash -c 'cd /app && yarn install && yarn build'
docker build . -t udoit:latest -f build/nginx/Dockerfile.build
docker tag udoit:latest ${{ env.REGISTRY }}/${{ steps.case.outputs.lowercase }}:${{ steps.slash.outputs.value }}
docker push ${{ env.REGISTRY }}/${{ steps.case.outputs.lowercase }}:${{ steps.slash.outputs.value }}
3 changes: 3 additions & 0 deletions .github/workflows/udoit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ jobs:
key: php-${{ matrix.php-versions }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: php-${{ matrix.php-versions }}-composer-

- name: Create .env file
run: cp .env.example .env

- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ yarn-error.log
/phpunit.xml
.phpunit.result.cache
###< phpunit/phpunit ###

.env
18 changes: 9 additions & 9 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ We strongly recommend managing the source code through Git. The benefit of this
If you prefer not to use Git, you can download a zip file of the latest release from the [Releases Page](https://github.com/ucfopen/UDOIT/releases). Unzip it in the directory on your server where UDOIT will live.

## .ENV Setup
UDOIT uses a `.env.local` file for storing configuration variables. To create it:
UDOIT uses a `.env` file for storing configuration variables. To create it:

1. Copy the file `.env.local.example` to `.env.local` by running
1. Copy the file `.env.example` to `.env` by running
```
cp .env.local.example .env.local
cp .env.example .env
```
2. Leave `APP_ENV` set to `prod`
> If you are setting up a development environment, set this to `dev` and follow the steps in [Installing Composer Dependencies](#installing-composer-dependencies) without the `--no-dev` flag to obtain all of the development packages.
3. Add your database information to thie `DATABASE_URL` variable. (The default value of `mysql://root:root@db:3306/udoit3` is suitable for running it on your local computer using Docker.)
3. Add your database information to the `DATABASE_URL` variable. (The default value of `mysql://root:root@db:3306/udoit3` is suitable for running it on your local computer using Docker.)
4. Modify the `BASE_URL` to match the URL of your instance of UDOIT. (The default value of `http://127.0.0.1:8000/udoit3` is suitable for running it on your local computer using Docker.)
5. Modify the `WEBPACK_PUBLIC_PATH` to match the `BASE_URL` you set. (The default value of `/udoit3/build` is suitable for running it on your local computer usind Docker. Example: If your `BASE_URL` is set to `http://127.0.0.1:8000`, your `WEBPACK_PUBLIC_PATH` should be `/build`.)
6. Set `APP_LMS` to the name of your LMS.
* `canvas` if you are using the Canvas LMS.
* `d2l` if you are using the D2l Brightspace LMS.
7. (Optional) You can change the default language for your entire UDOIT instance by adding the `DEFAULT_LANG` variable. Currently supported languages are English (`en`) and Spanish (`es`).
8. (Optional) If you are using UDOIT with a self-hosted instance of Canvas, you can add the `JWK_BASE_URL` variable and set it to the URL of your instance of Canvas. (Example: `JWK_BASE_URL="https://canvas.dev.myschool.edu"`)
7. If you are using UDOIT with a self-hosted instance of Canvas, you can add the `JWK_BASE_URL` variable and set it to the URL of your instance of Canvas. (Example: `JWK_BASE_URL="https://canvas.dev.myschool.edu"`)
8. (Optional) You can change the default language for your entire UDOIT instance by adding the `DEFAULT_LANG` variable. Currently supported languages are English (`en`) and Spanish (`es`).

## Docker
We provide a fast and simple way of setting up a local UDOIT instance through the use of Docker containers.
Expand All @@ -54,15 +54,15 @@ To set up the docker containers, you must first install [Docker](https://docs.do
### 2. Build the Containers
If you prefer to build the containers yourself, or you are actively developing UDOIT and need to rebuild the containers to test your cahnges, run the following command from within the UDOIT directory:

docker-compose -f docker-compose.nginx.yml up
docker compose -f docker-compose.nginx.yml up

### 3. Wait
Wait for all of the containers to finish initializing. This can take over 15 minutes. You will know you are ready to proceed with the next step when you haven't seen any output in your terminal for a few minutes.

### 4. Set up the Database
The first time you start the containers, you will need to set up the database to handle all the information UDOIT generates as it runs. Run the following command:

docker-compose -f docker-compose.nginx.yml run php php bin/console doctrine:migrations:migrate
docker compose -f docker-compose.nginx.yml run php php bin/console doctrine:migrations:migrate

> You will also need to run that command whenever you update to a new version of UDOIT.
Expand All @@ -72,7 +72,7 @@ Skip to [Testing your Setup](#testing-your-setup) to continue.
### 6. Stopping the Containers
If you ever want to stop the containers, you can do so with the following command:

docker-compose -f docker-compose.nginx.yml down
docker compose -f docker-compose.nginx.yml down



Expand Down
6 changes: 3 additions & 3 deletions INSTALL_CANVAS.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ lms_api_domain=$Canvas.api.domain
* Click `ON` to enable the newly created key

---
## Docker-Compose Base URL
If you are setting up UDOIT for local development through docker-compose, <YOUR_UDOIT_BASE_URL> in both the API developer key and the LTI developer key above should be set to `http://127.0.0.1:8000/udoit3`.
## Docker Compose Base URL
If you are setting up UDOIT for local development through `docker compose`, <YOUR_UDOIT_BASE_URL> in both the API developer key and the LTI developer key above should be set to `http://127.0.0.1:8000/udoit3`.

---
## Update the Institutions Table
Expand Down Expand Up @@ -187,4 +187,4 @@ UDOIT now needs to be added to an account in Canvas. Follow these steps to add t
8. Paste the `Client ID` from the developer LTI Key you created earlier.
9. Click Submit.

You're done! "UDOIT" should now appear in the navigation menu of the course (or every course in the account) in which you installed it. If you installed it to an account, "UDOIT Admin" will also appear in the account navigation menu.
You're done! "UDOIT" should now appear in the navigation menu of the course (or every course in the account) in which you installed it. If you installed it to an account, "UDOIT Admin" will also appear in the account navigation menu.
24 changes: 9 additions & 15 deletions docker-compose.nginx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,45 +26,40 @@ services:
web:
image: nginx:latest
ports:
- "8000:80"
- "8000:80"
volumes:
- .:/var/www/html
- ./build/nginx/local.conf:/etc/nginx/conf.d/default.conf

- .:/var/www/html
- ./build/nginx/local.conf:/etc/nginx/conf.d/default.conf
links:
- php
env_file:
- .env
- .env.local
php:
build:
context: ./build/nginx
dockerfile: Dockerfile.php.pdo.mysql
volumes:
- ./:/var/www/html
- type: bind
source: ./build/nginx/php-custom.ini
target: /usr/local/etc/php/conf.d/php-custom.ini
- ./:/var/www/html
- type: bind
source: ./build/nginx/php-custom.ini
target: /usr/local/etc/php/conf.d/php-custom.ini
env_file:
- .env
- .env.local
composer:
build:
context: ./build/nginx
dockerfile: Dockerfile.composer
command: "composer install --no-dev --no-interaction --no-progress --optimize-autoloader"
volumes:
- ./:/app
- ./:/app
env_file:
- .env
- .env.local
yarn:
image: node:16
volumes:
- ./:/app
- ./:/app
env_file:
- .env
- .env.local
command: >
bash -c '
cd /app &&
Expand All @@ -74,4 +69,3 @@ services:
volumes:
web:
dbdata:

0 comments on commit def169e

Please sign in to comment.