-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First working docker image for sigscale ocs
- Loading branch information
1 parent
17c88e0
commit de5d5f7
Showing
5 changed files
with
212 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
FROM erlang:20.3.2-alpine | ||
|
||
ARG ocs_ver=v3.0.7 | ||
# Download dependency packages | ||
RUN apk add --update --no-cache autoconf make gcc openssl-dev git automake libtool g++ nodejs nodejs-npm vim | ||
|
||
# Install Rebar3 | ||
RUN mkdir -p /buildroot/rebar3/bin | ||
ADD https://s3.amazonaws.com/rebar3/rebar3 /buildroot/rebar3/bin/rebar3 | ||
RUN chmod a+x /buildroot/rebar3/bin/rebar3 | ||
|
||
# Setup Environment | ||
ENV PATH=/buildroot/rebar3/bin:$PATH | ||
|
||
# Reset working directory | ||
#WORKDIR /buildroot | ||
|
||
WORKDIR /opt/ | ||
|
||
RUN git clone https://github.com/sigscale/ocs.git | ||
WORKDIR /opt/ocs | ||
|
||
#RUN git fetch --tags | ||
#RUN git checkout tags/$ocs_ver -b $ocs_ver | ||
|
||
ADD sys.config . | ||
ADD build.sh . | ||
|
||
RUN ./build.sh | ||
|
||
#CMD erl -pa ebin ../lib/mochiweb-2.17.0/ebin ../lib/radius-1.4.4/ebin -sname ocs -config sys —boot ocs | ||
|
||
WORKDIR /opt/ocs/.build/otp-20/ocs | ||
ADD entrypoint.sh . | ||
ENTRYPOINT ./entrypoint.sh | ||
#CMD /bin/bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Overview | ||
|
||
This is a simple docker file to run sigscale ocs. Nothing is tested except GUI. Use at your own risk. | ||
|
||
|
||
# Create Docker image using this command | ||
`docker build -t ocs:1.0 --build-arg ocs_ver=v3.0.4` | ||
|
||
|
||
# Run the docker using this command to directly attach to the erlang shell. | ||
`docker run -it -h ocsnode --name ocs -p8080:8080 ocs:1.0` | ||
or use *-d* switch to in docker run to detach and attach later to the shell | ||
|
||
# To attach to erlang shell if run as deamon with -d switch | ||
`docker exec -it ocs /bin/bash` | ||
once inside the docker container connect to the erlang node | ||
`erl -sname ocs1 -remsh ocs@ocsnode -setcookie ocsme` | ||
|
||
You will attach to erlang shell. | ||
To see if all ran successfully check with this command on erlang shell | ||
``` | ||
application:loaded_applications(). | ||
[{compiler,"ERTS CXC 138 10","7.1.5"}, | ||
{public_key,"Public key infrastructure","1.5.2"}, | ||
{ssl,"Erlang/OTP SSL application","8.2.5"}, | ||
{mochiweb,"MochiMedia Web Server","2.17.0"}, | ||
{ocs,"SigScale Online Charging System (OCS)","3.0.25"}, | ||
{mnesia,"MNESIA CXC 138 12","4.15.3"}, | ||
{radius,"RADIUS Protocol Stack","1.4.4"}, | ||
{sasl,"SASL CXC 138 11","3.1.1"}, | ||
{xmerl,"XML parser","1.3.16"}, | ||
{syntax_tools,"Syntax tools","2.1.4"}, | ||
{crypto,"CRYPTO","4.2.1"}, | ||
{inets,"INETS CXC 138 49","6.5"}, | ||
{diameter,"Diameter protocol","2.1.4"}, | ||
{stdlib,"ERTS CXC 138 10","3.4.5"}, | ||
{asn1,"The Erlang ASN1 compiler version 5.0.5","5.0.5"}, | ||
{kernel,"ERTS CXC 138 10","5.4.3"}] | ||
``` | ||
|
||
# Web GUI | ||
Browse to localhost:8080 on your machine and you should see the gui. the deafult user/pass is admin/admin | ||
|
||
# DB directory mounting. | ||
If we don't want to lose the DB that is created then mount the db directory like this | ||
`docker run -it --name ocs -p8080:8080 -v $(pwd)/db:/opt/ocs/db ocs:1.0` | ||
|
||
# Other notes | ||
* The docker image disables the SSL support for HTTP and sys.config should be updated for that accordingly. | ||
* The diameter and radius is not tested yet. Only GUI was tried out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/sh | ||
OTP_VERSION=20 | ||
CI_PROJECT_DIR=$(pwd) | ||
ERL_LIBS=/usr/local/Cellar/erlang/20.3.2/lib | ||
OPENSSL_LIB=/usr/local/Cellar//openssl/1.0.2j/lib | ||
export ERL_LIBS="${CI_PROJECT_DIR}/.build/otp-${OTP_VERSION}/lib" | ||
export ERLANG_INSTALL_LIB_DIR=${ERL_LIBS} | ||
aclocal | ||
autoheader | ||
autoconf | ||
libtoolize --automake | ||
automake --add-missing | ||
rm -rf .build/otp-$OTP_VERSION | ||
mkdir -p .build/otp-$OTP_VERSION/lib | ||
mkdir -p .build/otp-$OTP_VERSION/ocs | ||
cd .build/otp-$OTP_VERSION/ | ||
echo "Install mochiweb" | ||
git clone https://github.com/mochi/mochiweb.git | ||
cd mochiweb | ||
make all | ||
MOCHIWEB_VERSION=`grep vsn ebin/mochiweb.app | cut -d"\"" -f 2` | ||
cd ../../ | ||
if [ ! -d otp-$OTP_VERSION/lib/mochiweb-$MOCHIWEB_VERSION ]; then mv -v otp-$OTP_VERSION/mochiweb/ otp-$OTP_VERSION/lib/mochiweb-$MOCHIWEB_VERSION; fi | ||
echo "Install radierl" | ||
git clone https://github.com/sigscale/radierl.git | ||
cd radierl | ||
aclocal | ||
autoheader | ||
autoconf | ||
automake --add-missing | ||
#LD_FLAGS=$OPENSSL_LIB ./configure --with-ssl=$OPENSSL_LIB --prefix=$(pwd)/ocsinstall | ||
./configure | ||
make && make install | ||
echo "Install OCS" | ||
cd $CI_PROJECT_DIR/.build/otp-$OTP_VERSION/ocs | ||
../../../configure | ||
make | ||
echo "Installing OCS GUI" | ||
cd ../../../priv/www | ||
npm install -g bower | ||
bower --allow-root install | ||
mv bower_components/* ./ | ||
mv ./* $CI_PROJECT_DIR/.build/otp-$OTP_VERSION/ocs/priv/www/ | ||
mkdir -p $CI_PROJECT_DIR/.build/otp-$OTP_VERSION/ocs/log/http | ||
cd $CI_PROJECT_DIR/.build/otp-$OTP_VERSION/ocs | ||
cp $CI_PROJECT_DIR/sys.config ./ | ||
# go back to ocs main dir | ||
#if [ ! -d $CI_PROJECT_DIR/.build/otp-$OTP_VERSION/ocs/db ]; then | ||
# echo "Initialising DB" | ||
# erl -pa ebin ../lib/mochiweb-2.17.0/ebin ../lib/radius-1.4.4/ebin -sname ocs -config sys -s ocs_app install #-s init stop | ||
#fi | ||
#erl -pa ebin ../lib/mochiweb-2.17.0/ebin ../lib/radius-1.4.4/ebin -sname ocs -config sys -eval 'systools:make_script("ocs",[local])' # -s init stop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/sh | ||
INITDB=0 | ||
if [ -d /opt/ocs/db ]; then | ||
if [ ! "$(ls -A /opt/ocs/db)" ]; then | ||
INITDB=1 | ||
fi | ||
else | ||
INITDB=1 | ||
fi | ||
|
||
if [ $INITDB -eq 1 ]; then | ||
echo "Initialising DB" | ||
erl -pa ebin ../lib/mochiweb-2.17.0/ebin ../lib/radius-1.4.4/ebin -sname ocs -config sys -s ocs_app install -s init stop | ||
fi | ||
erl -pa ebin ../lib/mochiweb-2.17.0/ebin ../lib/radius-1.4.4/ebin -sname ocs -config sys -eval 'systools:make_script("ocs",[local])' -s init stop | ||
#erl -kernel inet_dist_listen_min 9001 inet_dist_listen_max 9005 -pa ebin ../lib/mochiweb-2.17.0/ebin ../lib/radius-1.4.4/ebin -boot ocs -sname ocs -setcookie ocsme -config sys | ||
erl -pa ebin ../lib/mochiweb-2.17.0/ebin ../lib/radius-1.4.4/ebin -boot ocs -sname ocs -setcookie ocsme -config sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
[{ocs, | ||
[{radius, | ||
[{auth, | ||
[{{0,0,0,0}, 1812, []}]}, | ||
{acct, | ||
[{{0,0,0,0}, 1813, []}]}]}, | ||
{diameter, | ||
[{acct, | ||
[{{0,0,0,0}, 3868, []}]}, | ||
{auth, | ||
[{{0,0,0,0}, 3869, []}]}]}, | ||
{acct_log_rotate, 1440}, | ||
{acct_log_rotate_time, {4,4,4}}, | ||
{acct_log_dir, "log/acct"}, | ||
{auth_log_dir, "log/auth"}, | ||
{abmf_log_dir, "log/abmf"}, | ||
{ipdr_log_dir, "log/ipdr"}, | ||
{export_dir, "log/export"}, | ||
{tls_key, "ssl/key.pem"}, | ||
{tls_cert, "ssl/cert.pem"}, | ||
{tls_cacert, "ssl/ca.pem"}]}, | ||
{radius, | ||
[{sock_opts, [{recbuf, 131072}, {sndbuf, 131072}]}]}, | ||
{mnesia, | ||
[{dir, "/opt/ocs/db"}]}, | ||
{sasl, | ||
[{sasl_error_logger, {file, "log/sasl/sasl.log"}}, | ||
{errlog_type, error}, | ||
{error_logger_mf_dir, "log/sasl"}, | ||
{error_logger_mf_maxbytes, 10485760}, | ||
{error_logger_mf_maxfiles, 10}]}, | ||
{inets, | ||
[{services, | ||
[{httpd, | ||
[{server_name, "ocs"}, | ||
{directory_index, ["index.html"]}, | ||
{directory, {"/", | ||
[{auth_type, mnesia}, | ||
{auth_name, "ocs.sigscale.org"}, | ||
{require_group, ["staff"]}]}}, | ||
{transfer_disk_log, "log/http/transfer"}, | ||
{security_disk_log, "log/http/security"}, | ||
{error_disk_log, "log/http/error"}, | ||
{transfer_disk_log_size, {10485760, 10}}, | ||
{error_disk_log_size, {10485760, 10}}, | ||
{error_disk_log_size, {10485760, 10}}, | ||
{security_disk_log_size, {10485760, 10}}, | ||
{disk_log_format, internal}, | ||
{modules, [mod_alias, mod_auth, mod_responsecontrol, | ||
mod_ocs_rest_lang, mod_ocs_rest_accepted_content, | ||
mod_ocs_rest_get, mod_get, mod_ocs_rest_post, | ||
mod_ocs_rest_put, mod_ocs_rest_patch, | ||
mod_ocs_rest_delete, mod_disk_log]}, | ||
{port, 8080}, | ||
{server_root, "./"}, | ||
{alias, {"/doc", "/opt/ocs/.build/otp-20/ocs/doc"}}, | ||
{document_root, "/opt/ocs/.build/otp-20/ocs/priv/www"}]}]}]}]. |