Skip to content

Commit

Permalink
Create submodule (#1)
Browse files Browse the repository at this point in the history
* build(docker): Docker file created

* build(script): Build script DONE

* fix(gitignore): removign unecessary directories

* fix(comments): Removing unecessary comments
  • Loading branch information
vrjuliao authored Nov 13, 2020
1 parent b01ebe4 commit 01c123e
Show file tree
Hide file tree
Showing 11 changed files with 140 additions and 415 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
node_modules
package-lock.json
hapi/
output/
bin/
44 changes: 44 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
FROM openjdk:8-jdk-alpine
RUN apk add --no-cache curl tar bash procps git npm

# Downloading and installing Gradle
# 1- Define a constant with the version of gradle you want to install
ARG GRADLE_VERSION=5.6.2

# 2- Define the URL where gradle can be downloaded from
ARG GRADLE_BASE_URL=https://services.gradle.org/distributions

# 3- Define the SHA key to validate the gradle download
# obtained from here https://gradle.org/release-checksums/
ARG GRADLE_SHA=32fce6628848f799b0ad3205ae8db67d0d828c10ffe62b748a7c0d9f4a5d9ee0


# 4- Create the directories, download gradle, validate the download, install it, remove downloaded file and set links
RUN mkdir -p /usr/share/gradle /usr/share/gradle/ref \
&& echo "Downlaoding gradle hash" \
&& curl -fsSL -o /tmp/gradle.zip ${GRADLE_BASE_URL}/gradle-${GRADLE_VERSION}-bin.zip \
\
&& echo "Checking download hash" \
&& echo "${GRADLE_SHA} /tmp/gradle.zip" | sha256sum -c - \
\
&& echo "Unziping gradle" \
&& unzip -d /usr/share/gradle /tmp/gradle.zip \
\
&& echo "Cleaning and setting links" \
&& rm -f /tmp/gradle.zip \
&& ln -s /usr/share/gradle/gradle-${GRADLE_VERSION} /usr/bin/gradle

# 5- Define environmental variables required by gradle
ENV GRADLE_VERSION 4.0.1
ENV GRADLE_HOME /usr/bin/gradle
ENV GRADLE_USER_HOME /cache

ENV PATH $PATH:$GRADLE_HOME/bin

WORKDIR /hapi-visualizer/

COPY . /hapi-visualizer/
RUN bash build.sh --from-scratch
EXPOSE 8080
ENTRYPOINT [ "bash", "build.sh"]
CMD ["run"]
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
# hapi-visualizer

with docker
```bash
docker build -t hapi-visualizer .
docker run -p <local port>:8080 -d --rm hapi-visualizer
```

without docker
```
/bin/bash build.sh run --from-scratch
```
Binary file removed bin/hapi.jar
Binary file not shown.
82 changes: 82 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#! /bin/bash

dependencies=(git gradle java npm node)
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

check (){
for i in "${dependencies[@]}";
do
if ! command -v "$i" &> /dev/null; then
echo "$i could not be found"
exit
fi
done
}

update_jar () {
cd $DIR
cd hapi
git checkout -B visualizer origin/visualizer
git pull origin visualizer

gradle build-all-tools --no-daemon

cd $DIR
mv hapi/build/libs/* bin/
}

from_scratch () {
cd $DIR
rm yes | rm -r hapi
git clone https://github.com/lac-dcc/hapi.git
cd hapi
git checkout -b visualizer origin/visualizer
update_jar
}

help_msg () {
echo "Hapi visualizer builder."
echo
echo "Usage: bash build.sh <[COMMAND] | [FLAG]>"
echo "COMMAND":
echo "run Starts the nodejs server"
echo
echo "FLAG:"
echo "--update Pull code from the lastest version of hapi repo and rebuild"
echo " the .jar ."
echo "--from-scratch First build of the hapi visualizer."
echo
exit
}

start_nodejs () {
cd $DIR
npm install
npm start
}

flags () {
case $1 in
--update) update_jar ;;
--from-scratch) from_scratch;;
*) help_msg ;;
esac
}

main () {
check dependencies

# frist argument is not null
if [ "$1" = "run" ]; then
if ! [ -z "$2" ]; then
flags $2
fi
start_nodejs
elif ! [ -z "$1" ]; then
flags $1
else
help_msg
fi
}

main $@
5 changes: 0 additions & 5 deletions static/output/actions.dot

This file was deleted.

9 changes: 0 additions & 9 deletions static/output/actors.dot

This file was deleted.

40 changes: 0 additions & 40 deletions static/output/main.hp

This file was deleted.

Loading

0 comments on commit 01c123e

Please sign in to comment.