18.4.0 released Sep 25, 2023
|
Example: docker
The following is a bash script that will create a base Vely image as well as a base image for a Vely application, and setup Apache server and MariaDB database. To run this example, you must have Docker, Apache and MariaDB installed on Ubuntu 20 and up or Red Hat 9 or up. You can use docker or podman (substitute podman for docker).
To run this example on Ubuntu:
tar xvf /usr/share/vely/examples/velydocker.tar.gz
cd velydocker
export DBROOTPWD="<mariadb root database pwd>"
export VV_APACHE_CONFIG="/etc/apache2/apache2.conf"
export VV_APACHE_SERVICE="apache2"
./runvelydocker
DBROOTPWD environment variable should have a MariaDB root database password (or empty if passwordless). VV_APACHE_CONFIG should be the location of Apache configuration file, and VV_APACHE_SERVICE the name of Apache service. You must have sudo privilege to run this example. The settings above are for Ubuntu/Debian, but you can change them for other distros.
The script will create a container with your application installed. You can remove the application source code from the container in "runit" script in order to distribute only the application binaries. You can then run this container on any machine.
Note that Vely demo application source code being containerized is in "docker" directory. You can replace it with your own source code; see application-setup on building application with Vely.
Once the image is built and container started, use the following link(s) to run it, or if you can't, use curl to see the demo application response (the demo is example-stock):
http://127.0.0.1/velydemo/docker_stock?action=add&stock_name=XYZ&stock_price=450
http://127.0.0.1/velydemo/docker_stock?action=show
File Dockerfile:
FROM ubuntu:20.04
ENV TZ=America/Phoenix
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt update
RUN apt install -y apt-transport-https ca-certificates wget sudo
RUN wget -qO - https://vely.dev//pkg/OPENPGP|sudo tee /usr/share/keyrings/vely.asc >/dev/null
ARG arch
RUN sudo bash -c "echo 'deb [signed-by=/usr/share/keyrings/vely.asc] https://vely.dev//pkg/ubuntu_20_$arch/latest ubuntu_20_$arch vely' >/etc/apt/sources.list.d/vely.list"
RUN sudo apt update
RUN sudo apt install -y vely
File velyapp.dockerfile:
FROM vely
RUN useradd -ms /bin/bash vely && echo "vely:vely" | chpasswd
RUN echo "vely ALL=(ALL) NOPASSWD: /usr/bin/vf" >> /etc/sudoers
USER vely
WORKDIR /home/vely
EXPOSE 2300
COPY ./docker/* /home/vely/
ENTRYPOINT [ "./runit" ]
File runvelydocker:
CACHE=""
set -eE -o functrace
trap 'echo "Error: status $?, $(caller), line ${LINENO}"' ERR
sudo docker build --build-arg arch=$(uname -m) $CACHE -t vely .
sudo docker volume create velyhome
sudo docker stop velyapp || true
sudo docker rmi --force velyapp || true
sudo docker build $CACHE -t velyapp -f velyapp.dockerfile .
sudo sed -i "/^ProxyPass \"\/velydemo\" .*$/d" $VV_APACHE_CONFIG
echo 'ProxyPass "/velydemo" fcgi://127.0.0.1:2300/' | sudo tee -a $VV_APACHE_CONFIG >/dev/null
sudo a2enmod proxy || true
sudo a2enmod proxy_fcgi || true
sudo service $VV_APACHE_SERVICE restart
MKDB=$(echo "create database if not exists velydb;
create user if not exists velyuser identified by 'pwd';
grant create,alter,drop,select,insert,delete,update on velydb.* to velyuser;
use velydb;
source docker/setup.sql;")
if [ "$DBROOTPWD" == "" ]; then
echo $MKDB | sudo mysql
else
echo $MKDB | sudo mysql -u root -p$DBROOTPWD
fi
mkdir -p $HOME/libvv
sudo docker run --name velyapp -d -v velyhome:/var/lib/vv --network="host" --rm velyapp
exit 0
File runit:
sudo vf -i -u $(whoami) velydemo
vv -c
vv -q --db=mariadb:db -s
vv -c
vf -f -w3 -p2300 velydemo > demout
Examples
example-client-API
example-cookies
example-create-table
example-distributed-servers
example-docker
example-encryption
example-file-manager
example-form
example-hash-server
example-hello-world
example-how-to-design-application
example-json
example-multitenant-SaaS
example-postgres-transactions
examples
example-sendmail
example-shopping
example-stock
example-uploading-files
example-using-mariadb-mysql
example-utility
example-write-report
See all
documentation
You are free to copy, redistribute and adapt this web page (even commercially), as long as you give credit and provide a link back to this page (dofollow) - see full license at
CC-BY-4.0. Copyright (c) 2019-2023 Dasoftver LLC. Vely and elephant logo are trademarks of Dasoftver LLC. The software and information on this web site are provided "AS IS" and without any warranties or guarantees of any kind.