A third party tool which enables an author to record coding tasks by using an interactive C-Language Compiler
. This tool can help you embed and showcase the recorded tasks in any learning platform such as Open edX
through an iframe link
.
- MySql
- Node (Version: 12.x.x is recommended)
Make sure to update distribution:
# apt-get update && apt-get dist-upgrade
Create a user to run CodeCast:
# adduser codecast
Install NodeJS as follows:
# curl -sL https://deb.nodesource.com/setup_12.x | bash -
# apt-get install -y nodejs build-essential libasound2-dev mysql-server
Create database as follows:
CREATE DATABASE codecast;
GRANT ALL ON codecast.* TO 'codecast'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
Switch to codecast user to perform further setup steps.
Add the following environment variables to the end of ~/.bashrc
:
# set NPM directory
NPM_DIR="$HOME/.npm"
# set PATH to include local NPM directory
PATH="$NPM_DIR/bin:$PATH"
# Unset manpath so we can inherit from /etc/manpath via the `manpath` command
unset MANPATH # delete if you already modified MANPATH elsewhere in your configuration
MANPATH="$NPM_DIR/share/man:$(manpath)"
# Tell Node about these packages
NODE_PATH="$NPM_DIR/lib/node_modules:$NODE_PATH"
Create ~/.npmrc
with following content:
prefix = ${HOME}/.npm
For the above environment changes to be effective:
source ~/.bashrc
Switch to codecast user to perform further setup steps.
Clone CodeCast from git repo:
$ git clone https://github.com/edly-io/codecast.git
Restore user management schema as follows:
$ cd codecast
$ mysql -u codecast -p codecast < user_management_schema.sql
The schema creates a table named buckets. Add your S3 bucket configuration after logging into MySQL:
USE codecast
INSERT INTO buckets (bucket_id, value) values (0,'{ \"s3AccessKeyId\": \"<YOUR S3 ACCESS KEY ID>\", \"s3SecretAccessKey\": \"<YOUR S3 SECRET ACCESS KEY>\", \"s3Region\": \"<YOUR S3 REGION>\", \"s3Bucket\": \"<YOUR S3 BUCKET NAME>\", \"uploadPath\": \"uploads\" }');
Replace:
<YOUR S3 ACCESS KEY ID>
and<YOUR S3 SECRET ACCESS KEY>
with Access Key ID and Secret Access Key, preferably of an IAM user who has access to the S3 bucket only.<YOUR S3 REGION>
with the AWS region where S3 bucket has been created.<YOUR S3 BUCKET NAME>
name of the S3 bucket.
Generate password hash for admin user:
$ echo -n password | md5sum
Use the password hash generated by the above command to add admin user via SQL query:
USE codecast
INSERT INTO users (username, email_id, password, is_active, is_admin, bucket_id) values ('<YOUR USERNAME>', '<YOUR ADMIN EMAIL ADDRESS>', '<MD5 PASSWORD HASH>', 1, 1, 0);
Replace:
<YOUR ADMIN EMAIL ADDRESS>
with admin email address.<MD5 PASSWORD HASH>
with the password hash generated previously.
Create config.json
under the codecast cloned directory:
{
"host": "127.0.0.1",
"port": 8001,
"baseUrl": "http://IP_ADDRESS",
"mountPath": "/",
"database": {
"host": "localhost",
"port": "3306",
"user": "codecast",
"password": "password",
"database": "codecast"
},
"session": {
"secret": "RANDOM_SESSION_SECRET",
"resave": false,
"saveUninitialized": true,
"cookie": {
"secure": false,
"maxAge": 60480000
}
},
"enableOauth": false
}
Replace IP_ADDRESS
with either your IP address or host name matching NGINX server block configuration.
To install its required packages, run:
$ npm install
If you see any error something like that is given below, JUST IGNORE IT and proceed to next step:
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/home/umar/.nvm/versions/node/v12.10.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:196:23)
gyp ERR! stack at ChildProcess.emit (events.js:209:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Linux 4.15.0-20-generic
gyp ERR! command "/home/umar/.nvm/versions/node/v12.10.0/bin/node" "/home/umar/.nvm/versions/node/v12.10.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/umar/Documents/Work/codecast/node_modules/speaker
gyp ERR! node -v v12.10.0
gyp ERR! node-gyp -v v5.0.3
gyp ERR! not ok
Compile assets using:
$ npm run build
Write a startup script /home/codecast/codecast.sh
for CodeCast:
#!/bin/bash
source ~/.bashrc
export NODE_ENV=production
npm run start
Change the script permissions to executable:
$ chmod +x /home/codecast/codecast.sh
Install and configure supervisor
as root:
# apt-get install -y supervisor
Create a supervisor configuration file /etc/supervisor/conf.d/codecast.conf
for CodeCast:
[program:codecast]
command=/home/codecast/codecast.sh
user=codecast
directory=/home/codecast/codecast
stdout_logfile=/var/log/supervisor/%(program_name)s-stdout.log
stderr_logfile=/var/log/supervisor/%(program_name)s-stderr.log
killasgroup=true
autorestart=true
CodeCast runs as a foreground process. Hence the above supervisor configuration file ensures that CodeCast is restarted if it crashes or quits for some reason.
Restart supervisor:
# systemctl restart supervisor
Install NGINX:
# echo -e "deb https://nginx.org/packages/debian/ stretch nginx" > /etc/apt/sources.list.d/nginx.list
# curl -O https://nginx.org/keys/nginx_signing.key && apt-key add ./nginx_signing.key
# apt-get update && apt-get install -y nginx
# rm -rf /etc/nginx/conf.d/default.conf # Remove default server block
Configure NGINX server block for CodeCast in /etc/nginx/conf.d/codecast.conf
:
upstream codecast {
server 127.0.0.1:8001;
}
server {
listen 80 default_server;
server_tokens off;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_pass http://codecast;
proxy_redirect off;
}
}
Check if NGINX configuration is valid and restart NGINX:
# nginx -t && /etc/init.d/nginx restart
Go to http://IP_ADDRESS/login link and login using your admin credentials.
For development "npm run build" is not needed as webpack is configured to watch the source files:
NODE_ENV=development npm start
rm -rf build
BUILD=offline NODE_ENV=production npm run build
zip -r offline.zip build assets