Skip to content

Commit

Permalink
Merge pull request #95 from serlo/development
Browse files Browse the repository at this point in the history
Staging deployment
  • Loading branch information
LarsTheGlidingSquirrel authored Oct 16, 2024
2 parents b217aef + 5b30777 commit 5e2e6a0
Show file tree
Hide file tree
Showing 45 changed files with 11,718 additions and 1,578 deletions.
25 changes: 0 additions & 25 deletions .env-template

This file was deleted.

27 changes: 27 additions & 0 deletions .env.local.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Template - Copy content to `.env` file and add missing (secret) values

# Set this to 'local' in local development.
# - sets origin to localhost
# - configures cookie handling
ENVIRONMENT=local

EDITOR_URL=http://localhost:3000/

# Secret to enable media upload
SERLO_EDITOR_TESTING_SECRET=

# Symmetric HS256 key used by ltijs to sign ltik and database entries & to sign the jwt access token
LTIJS_KEY=DONOTUSETHISKEYINPRODUCTION

MYSQL_URI=mysql://root:secret@mariadb:3306/serlo

# https://www.mongodb.com/docs/drivers/go/current/fundamentals/connections/connection-guide/#connection-uri
MONGODB_URI=mongodb://mongo:27017/

# LTI platform: https://saltire.lti.app/platform
ALLOW_SALTIRE=true

# LTI platform: edu-sharing mock
ALLOW_EDUSHARING_MOCK=true

# Keep an empty line at the end
31 changes: 31 additions & 0 deletions .env.uberspace.edtr.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Template - Copy content to `.env` file and add missing (secret) values

EDITOR_URL=https://edtr.uber.space/

# Secret to enable media upload
SERLO_EDITOR_TESTING_SECRET=

# Symmetric HS256 key used by ltijs to sign ltik and database entries & to sign the jwt access token
LTIJS_KEY=

# LTI platform: itslearning
ITSLEARNING_URL=
ITSLEARNING_NAME=
SERLO_EDITOR_CLIENT_ID_ON_ITSLEARNING=
ITSLEARNING_AUTHENTICATION_ENDPOINT=
ITSLEARNING_ACCESS_TOKEN_ENDPOINT=
ITSLEARNING_KEYSET_ENDPOINT=

# LTI platform: edu-sharing (RLP)
EDUSHARING_RLP_URL=
EDUSHARING_RLP_NAME=
SERLO_EDITOR_CLIENT_ID_ON_EDUSHARING_RLP=
EDUSHARING_RLP_AUTHENTICATION_ENDPOINT=
EDUSHARING_RLP_ACCESS_TOKEN_ENDPOINT=
EDUSHARING_RLP_KEYSET_ENDPOINT=

# LTI tool: edu-sharing (RLP)
EDUSHARING_RLP_LOGIN_ENDPOINT=
EDUSHARING_RLP_LAUNCH_ENDPOINT=
EDUSHARING_RLP_CLIENT_ID_ON_SERLO_EDITOR=
EDUSHARING_RLP_DETAILS_ENDPOINT=
12 changes: 12 additions & 0 deletions .env.uberspace.edtrdev.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Template - Copy content to `.env` file and add missing (secret) values

EDITOR_URL=https://edtrdev.uber.space/

# Secret to enable media upload
SERLO_EDITOR_TESTING_SECRET=

# Symmetric HS256 key used by ltijs to sign ltik and database entries & to sign the jwt access token
LTIJS_KEY=DONOTUSETHISKEYINPRODUCTION

# LTI platform: https://saltire.lti.app/platform
ALLOW_SALTIRE=true
34 changes: 34 additions & 0 deletions .env.uberspace.edtrstag.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Template - Copy content to `.env` file and add missing (secret) values

EDITOR_URL=https://edtrstag.uber.space/

# Secret to enable media upload
SERLO_EDITOR_TESTING_SECRET=

# Symmetric HS256 key used by ltijs to sign ltik and database entries & to sign the jwt access token
LTIJS_KEY=DONOTUSETHISKEYINPRODUCTION

# LTI platform: https://saltire.lti.app/platform
ALLOW_SALTIRE=true

# LTI platform: itslearning (staging)
ITSLEARNING_URL=
ITSLEARNING_NAME=
SERLO_EDITOR_CLIENT_ID_ON_ITSLEARNING=
ITSLEARNING_AUTHENTICATION_ENDPOINT=
ITSLEARNING_ACCESS_TOKEN_ENDPOINT=
ITSLEARNING_KEYSET_ENDPOINT=

# LTI platform: edu-sharing (RLP) (staging)
EDUSHARING_RLP_URL=
EDUSHARING_RLP_NAME=
SERLO_EDITOR_CLIENT_ID_ON_EDUSHARING_RLP=
EDUSHARING_RLP_AUTHENTICATION_ENDPOINT=
EDUSHARING_RLP_ACCESS_TOKEN_ENDPOINT=
EDUSHARING_RLP_KEYSET_ENDPOINT=

# LTI tool: edu-sharing (RLP) (staging)
EDUSHARING_RLP_LOGIN_ENDPOINT=
EDUSHARING_RLP_LAUNCH_ENDPOINT=
EDUSHARING_RLP_CLIENT_ID_ON_SERLO_EDITOR=
EDUSHARING_RLP_DETAILS_ENDPOINT=
21 changes: 21 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,24 @@ jobs:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-node
- run: yarn lint:tsc

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-node
- run: yarn build

# TODO: this is just a basic check to see if it is set up and running
# change for real tests later
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-node
- run: cp .env.local.template .env
- run: yarn dev -d
- run: yarn build
- run: sleep 15
- run: yarn playwright install
- run: HEADLESS=true yarn test
43 changes: 43 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Deploy to Uberspace

on:
push:
branches:
- staging
- development

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Set environment variables for development
if: ${{ github.ref_name == 'development' }}
run: |
echo "REMOTE_HOST=${{ secrets.REMOTE_HOST_DEV }}" >> $GITHUB_ENV
echo "REMOTE_USER=${{ secrets.REMOTE_USER_DEV }}" >> $GITHUB_ENV
echo "DOMAIN=https://editor.serlo.dev/" >> $GITHUB_ENV
- name: Set environment variables for staging
if: ${{ github.ref_name == 'staging' }}
run: |
echo "REMOTE_HOST=${{ secrets.REMOTE_HOST_STAGING }}" >> $GITHUB_ENV
echo "REMOTE_USER=${{ secrets.REMOTE_USER_STAGING }}" >> $GITHUB_ENV
echo "DOMAIN=https://editor.serlo-staging.dev/" >> $GITHUB_ENV
- name: Deploy to Server
uses: appleboy/[email protected]
with:
host: ${{ env.REMOTE_HOST }}
username: ${{ env.REMOTE_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
cd /home/${{ env.REMOTE_USER }}/serlo-editor-as-lti-tool/
git checkout --force ${{ github.ref_name }}
git pull
yarn
yarn build
supervisorctl restart serlo-app
- name: Test deployment successful
run: sleep 2 && curl ${{ env.DOMAIN }} | grep NO_LTIK_OR_IDTOKEN_FOUND
64 changes: 0 additions & 64 deletions .github/workflows/push-docker-image.yml

This file was deleted.

5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# .env - Should not be added because it contains private keys used for encryption
# output folder of e2e tests
output

# .env - Should not be added because they might contain secrets
.env

# Logs
Expand Down
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM node:20.18.0 as build
WORKDIR /usr/src/app

COPY . .
RUN yarn install --immutable

RUN yarn build

FROM node:20.18.0 as production

WORKDIR /usr/src/app

COPY --from=build /usr/src/app/dist dist

EXPOSE 3000

ENTRYPOINT ["node", "dist/backend/index.cjs"]
6 changes: 2 additions & 4 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# syntax=docker/dockerfile:1

FROM node:20.17.0
FROM node:20.18.0
WORKDIR /usr/src/app

RUN apt update && apt install neovim nano -y

COPY . .
RUN yarn install --immutable

RUN yarn build

EXPOSE 3000

ENTRYPOINT ["yarn", "start:dev"]
ENTRYPOINT ["yarn", "start"]
26 changes: 18 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
Serlo editor as LTI tool Status: Early prototype
Prototype: Serlo editor as LTI tool

# Local dev setup

Requirements:

- Docker & Docker Compose
- Docker 26.0.0 or later

1. Create file `.env` and copy content from `.env-template`
2. `yarn` to install dependencies
3. `yarn dev` to start docker containers (hot reload)
4. Go to https://saltire.lti.app/platform, sign in, navigate to "Advanced
1. Create a copy of `.env.local.template` as `.env`
2. (optional) Add secret values to `.env`
3. `yarn` to install dependencies
4. `yarn dev` to start docker containers

Now, the editor is running locally. It will automatically restart when files get
modified.

## Launch through Saltire

1. Go to https://saltire.lti.app/platform, sign in, navigate to "Advanced
options" and upload file `saltire-platform_[TYPE].config` of the
[`saltire-configs/`](./saltire-configs) directory. `TYPE=LTIDeepLinking`
shows flow of creating a new Serlo Editor element.
`TYPE=LTIResourceLink_Instructor` shows flow of opening an existing Serlo
Editor element as Instructor (editable). `TYPE=LTIResourceLink_Learner` shows
flow of opening an existing Serlo Editor element as Learner (non-editable).
5. Click "Connect"
2. Click "Connect"

## Launch through edu-sharing mock

The editor should open in a new tab.
1. `yarn dev:edusharing` to start the edu-sharing mock
2. Open `http://localhost:8100`

# Technical details

Expand Down
22 changes: 22 additions & 0 deletions codecept.conf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { setHeadlessWhen, setCommonPlugins } from '@codeceptjs/configure'

setHeadlessWhen(process.env.HEADLESS)

// enable all common plugins https://github.com/codeceptjs/configure#setcommonplugins
setCommonPlugins()

export const config: CodeceptJS.MainConfig = {
tests: 'e2e/tests/**/*.ts',
output: './output',
helpers: {
Playwright: {
browser: 'chromium',
url: 'http://localhost:3000',
show: true,
},
},
include: {
I: './e2e/steps_file',
},
name: 'serlo-editor-as-lti-tool',
}
Loading

0 comments on commit 5e2e6a0

Please sign in to comment.