Skip to content

Commit

Permalink
Merge pull request #41 from dzdidi/main
Browse files Browse the repository at this point in the history
Add Installation guide for Ubuntu.
  • Loading branch information
G8XSU authored Dec 12, 2024
2 parents cb4b915 + 2c582b9 commit ebb9118
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 1 deletion.
130 changes: 130 additions & 0 deletions java/INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Installation guide without docker

## Ubuntu

### Install Java

```sh
sudo apt update
sudo apt install openjdk-17-jdk
java -version
```

### Install and configure PostgreSQL

```sh
sudo apt install postgresql

sudo -u postgres psql
ALTER USER postgres with encrypted password '<password>';
quit
sudo systemctl restart postgresql.service
```

#### Verify
```sh
psql postgresql://postgres:<password>@localhost:5432/postgres`
quit
```

### Install Gradle

```
sudo apt intall unzip
wget https://services.gradle.org/distributions/gradle-8.11.1-bin.zip -P /tmp
sudo mkdir /opt/gradle
sudo unzip -d /opt/gradle /tmp/gradle-8.11.1-bin.zip
export PATH=$PATH:/opt/gradle/gradle-8.11.1/bin
```
### Install Tomcat
```
sudo useradd -m -U -d /opt/tomcat -s /bin/false tomcat
VERSION=10.1.4
wget https://www-eu.apache.org/dist/tomcat/tomcat-10/v${VERSION}/bin/apache-tomcat-${VERSION}.tar.gz -P /tmp
sudo tar -xf /tmp/apache-tomcat-${VERSION}.tar.gz -C /opt/tomcat/
sudo ln -s /opt/tomcat/apache-tomcat-${VERSION} /opt/tomcat/latest
sudo chown -R tomcat: /opt/tomcat
sudo sh -c 'chmod +x /opt/tomcat/latest/bin/*.sh'
```
#### Systemd for tomcat
location:
```
/etc/systemd/system/tomcat.service
```
content:
```
[Unit]
Description=Tomcat 10 servlet container
After=network.target

[Service]
Type=forking

User=tomcat
Group=tomcat

Environment="JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64"
Environment="JAVA_OPTS=-Djava.security.egd=file:///dev/urandom -Djava.awt.headless=true"

Environment="CATALINA_BASE=/opt/tomcat/latest"
Environment="CATALINA_HOME=/opt/tomcat/latest"
Environment="CATALINA_PID=/opt/tomcat/latest/temp/tomcat.pid"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"

ExecStart=/opt/tomcat/latest/bin/startup.sh
ExecStop=/opt/tomcat/latest/bin/shutdown.sh

[Install]
WantedBy=multi-user.target
```
#### Enable and start tomcat
```
sudo systemctl daemon-reload
sudo systemctl enable --now tomcat
sudo systemctl status tomcat
```
### Clone repo
```
git clone https://github.com/lightningdevkit/vss-server.git
cd vss-server/java
```
### Configure by editing password for postgres in this file for the same one used in step 2
```
./app/src/main/resources/application.properties
```
### Build
```
gradle wrapper --gradle-version 8.1.1
./gradlew build -x test # Running tests requires docker-engine to be running.
```
### Deploy
```
sudo cp app/build/libs/vss-1.0.war /opt/tomcat/latest/webapps/vss.war
```
### Verify deployment
```
curl --data-binary "$(echo "0A0773746F726549641A150A026B3110FFFFFFFFFFFFFFFFFF011A046B317631" | xxd -r -p)" http://localhost:8080/vss/putObjects

curl --data-binary "$(echo "0A0773746F7265496412026B31" | xxd -r -p)" http://localhost:8080/vss/getObject
```
### Enable vss in nginx by adding:
```
location /vss/ {
proxy_pass http://localhost:8080/vss/;
}
```
Restart nginx and try previous step from the external host machine
7 changes: 6 additions & 1 deletion java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ This directory hosts the Java-based implementation of the Versioned Storage Serv
- Install Docker (https://docs.docker.com/desktop/).
- Install PostgreSQL 15 (https://www.postgresql.org/download/).


### Installation without docker

see [here](./INSTALL.md)

### Building

```
Expand Down Expand Up @@ -46,7 +51,7 @@ gradle wrapper --gradle-version 8.1.1
#### To run just the VSS-server:
1. **Edit Configuration**: Modify the Dockerfile or application.properties to set application configurations and
1. **Edit Configuration**: Modify the Dockerfile or `./app/src/main/resources/application.properties` to set application configurations and
environment variables as needed. Add PostgreSQL endpoint configuration.
2. Create table in PostgreSQL using `./app/src/main/java/org/vss/impl/postgres/sql/`
3. **Build the Docker Image**:
Expand Down

0 comments on commit ebb9118

Please sign in to comment.