Install - Java Static Agent on a Containerized App
Installation Wizard
To help with the installation process, vFunction offers an Installation Wizard. This Wizard provides additional information about the Prerequisites as well as the Required and Optional Settings for installing the vFunction Server and Agents. This Wizard also walks you through each step in the Installation process.
Installation Steps
- Download the latest vFunction Sudoless Controller Installation TGZ
- Copy-and-paste the Dockerfile below
- Modify the Dockerfile following the file’s Comments
FROM almalinux:9
### Copy the Application's Binaries to the image
RUN mkdir -p /tmp/vfunction/binaries/
# Modify /artifact_repository/vfunction/app.war and app.war to be relevant for your application
COPY /artifact_repository/vfunction/app.war /tmp/vfunction/binaries/app.war
### vFunction Environment Variables
# See description in https://kb.vfunction.com/installations/configurable-settings/mono-static-agent/java/linux
ENV VF_CONTROLLER_VIPERINST_CONTROLLER_NAME="CHANGE_ME"
ENV VF_CONTROLLER_VIPERINST_CONTROLLER_HOST="CHANGE_ME"
ENV VF_CONTROLLER_VIPERINST_CONTROLLER_ORG_ID="CHANGE_ME"
ENV VF_CONTROLLER_VIPERINST_CONTROLLER_APP_ID="CHANGE_ME"
ENV VF_CONTROLLER_VIPERINST_CONTROLLER_CLIENT_ID="CHANGE_ME"
ENV VF_CONTROLLER_VIPERINST_CONTROLLER_CLIENT_SECRET="CHANGE_ME"
ENV VF_CONTROLLER_VIPERINST_CONTROLLER_INSTANCE_ID="CHANGE_ME"
ENV VF_CONTROLLER_VIPERINST_CONTROLLER_TAGS="CHANGE_ME"
ENV VF_CONTROLLER_VIPERINST_VIPER_JVM_MEMORY_PARAMS="CHANGE_ME"
ENV VF_CONTROLLER_VIPERINST_VIPER_ARCHIVES="/path/to/binaries/*.filetype"
### Sample Values
### ENV VF_CONTROLLER_VIPERINST_CONTROLLER_NAME="Viper-prod"
### ENV VF_CONTROLLER_VIPERINST_CONTROLLER_HOST="http://vf_server_fqdn.organization.com"
### ENV VF_CONTROLLER_VIPERINST_CONTROLLER_ORG_ID="1111-11-11-1111"
### ENV VF_CONTROLLER_VIPERINST_CONTROLLER_APP_ID="1111-11-11-1111"
### ENV VF_CONTROLLER_VIPERINST_CONTROLLER_CLIENT_ID="1111-11-11-1111"
### ENV VF_CONTROLLER_VIPERINST_CONTROLLER_CLIENT_SECRET="1111-11-11-1111"
### ENV VF_CONTROLLER_VIPERINST_CONTROLLER_INSTANCE_ID="viper"
### ENV VF_CONTROLLER_VIPERINST_CONTROLLER_TAGS="prod"
### ENV VF_CONTROLLER_VIPERINST_VIPER_JVM_MEMORY_PARAMS="-Xms300m -Xmx4g -Xss50m"
### ENV VF_CONTROLLER_VIPERINST_VIPER_ARCHIVES="/tmp/vfunction/binaries/app.war"
### vFunction Copy workflow
# Modify /artifact_repository to be relevant for your environment
COPY /artifact_repository/vfunction/vfunction-controller-sudo-less-installation*.tgz /tmp/vfunction-controller-sudo-less-installation.tgz
COPY /artifact_repository/vfunction/health-check.sh /usr/bin/health-check.sh
COPY /artifact_repository/vfunction/startup.sh /usr/bin/startup.sh
### vFunction Run workflow
RUN cd /tmp && tar -xvzf /tmp/vfunction-controller-sudo-less-installation.tgz && \
rm -f /tmp/vfunction-controller-sudo-less-installation.tgz && \
bash /tmp/vfunction/opt/vfunction/controller-installation/create-instance.sh -i viperinst -t java -v && \
bash /tmp/vfunction/opt/vfunction/controller-installation/install.sh -i viperinst -n -s && \
chmod +x /usr/bin/health-check.sh && \
chmod +x /usr/bin/startup.sh && \
chmod -R 777 /tmp/vfunction /usr/bin/
# vFunction Healtcheck
HEALTHCHECK --interval=5s --retries=12 \
CMD /usr/bin/health-check.sh
### vFunction CMD workflow
ENTRYPOINT ["/bin/sh"]
CMD ["/usr/bin/startup.sh"]
- Copy-and-paste the Health-check.sh below
#!/usr/bin/env bash
netstat -nlp | grep 8090 | grep tcp | grep -q LISTEN
exit $?
- Copy-and-paste the Startup.sh below
#!/usr/bin/env bash
set -x
get_process_pid(){
binary=viper.jar
INSTANCE=viperinst
ps aux >/dev/null 2>&1
if [[ $? -eq 0 ]]; then
ps aux | grep $binary | grep -v grep | awk -v x="--instance=$INSTANCE" '{for (i=1;i<=NF;i++) if ($i==x) {print $0; next}}' | awk '{print $2}'
else
for proc in /proc/[0-9]*/cmdline; do echo $(basename $(dirname $proc)) $(cat $proc | tr "\0" " "); done | grep $binary | grep -v grep | awk -v x="--instance=$INSTANCE" '{for (i=1;i<=NF;i++) if ($i==x) {print $0; next}}' | awk '{print $1}'
fi
}
echo "Restarting the controller"
bash /tmp/vfunction/opt/vfunction/controller-installation/restart-controller.sh -i default-java-viper || echo "Failed to restart the controller"
sleep 60
# loop until the viper process is not running - then kill the script
while true; do
pid=$(get_process_pid viper.jar)
if [[ -z $pid ]]; then
echo "Viper process is not running"
break
fi
sleep 5
done
- Create a folder for vFunction artifacts in the Artifact Repository accessible by the Docker Build
- Add the vFunction Sudoless Controller Installation TGZ, the health-check.sh, the startup.sh and the binaries for the Application to the Artifact Repository
- Create a vFunction Viper-specific project in your CI/CD Pipeline
- Build and deploy the Viper Container
- Confirm that the Viper comes up as expected in the vFunction Server UI