Skip to content

Commit

Permalink
Merge branch '4.2.0_staging' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
jcreel committed May 8, 2023
2 parents 1511d2c + 681a4ae commit 8ff079b
Show file tree
Hide file tree
Showing 62 changed files with 1,230 additions and 539 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
/.nb-gradle/


### VS ###
.vs

### VS Code ###
.vscode/

Expand Down Expand Up @@ -80,7 +83,7 @@ replay_pid*
logs/
target/

.classpth
.classpath
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
.project
Expand Down
79 changes: 39 additions & 40 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
# Settings.
# Build arguments.
ARG USER_ID=3001
ARG USER_NAME=vireo
ARG SOURCE_DIR=/$USER_NAME/source
ARG HOME_DIR=/$USER_NAME
ARG SOURCE_DIR=$HOME_DIR/source
ARG APP_PATH=/var/vireo
ARG NODE_ENV=production

# Maven stage.
FROM maven:3-openjdk-11-slim as maven
FROM maven:3-eclipse-temurin-11-alpine as maven
ARG USER_ID
ARG USER_NAME
ARG HOME_DIR
ARG SOURCE_DIR
ARG APP_PATH
ARG NODE_ENV

ENV NODE_ENV=$NODE_ENV

# Create the user and group (use a high ID to attempt to avoid conflicts).
RUN groupadd --non-unique -g $USER_ID $USER_NAME && \
useradd --non-unique -d /$USER_NAME -m -u $USER_ID -g $USER_ID $USER_NAME
# Create the group (use a high ID to attempt to avoid conflits).
RUN addgroup -g $USER_ID $USER_NAME

# Install stable Nodejs and npm.
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y nodejs npm iproute2 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
npm cache clean -f && \
npm install -g n && \
n stable
# Create the user (use a high ID to attempt to avoid conflits).
RUN adduser -h $HOME_DIR -u $USER_ID -G $USER_NAME -D $USER_NAME

# Ensure source directory exists and has appropriate file permissions.
RUN mkdir -p $SOURCE_DIR && \
chown $USER_ID:$USER_ID $SOURCE_DIR && \
chmod g+s $SOURCE_DIR

# Upgrade the system and install dependencies.
RUN apk -U upgrade && \
apk add --update --no-cache nodejs npm make g++ py3-pip

# Set deployment directory.
WORKDIR $SOURCE_DIR

Expand All @@ -43,7 +43,7 @@ COPY ./src ./src
COPY ./build ./build
COPY ./package.json ./package.json

# Assign file permissions.
# Change ownership of source directory.
RUN chown -R $USER_ID:$USER_ID $SOURCE_DIR

# Login as user.
Expand All @@ -52,48 +52,47 @@ USER $USER_NAME
# Build.
RUN mvn package -Pproduction

# Switch to Normal JRE Stage.
FROM openjdk:11-jre-slim
# JRE Stage.
FROM eclipse-temurin:11-alpine
ARG USER_ID
ARG USER_NAME
ARG HOME_DIR
ARG SOURCE_DIR
ARG APP_PATH

ENV APP_PATH=$APP_PATH

# Create the group (use a high ID to attempt to avoid conflits).
RUN addgroup -g $USER_ID $USER_NAME

RUN apt-get update && \
apt-get upgrade -y && \
apt-get -y install gettext-base && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Create the user (use a high ID to attempt to avoid conflits).
RUN adduser -h $HOME_DIR -u $USER_ID -G $USER_NAME -D $USER_NAME

# Ensure app path directory exists and has appropriate file permissions.
RUN mkdir -p $APP_PATH && \
chown $USER_ID:$USER_ID $APP_PATH && \
chmod g+s $APP_PATH

# Update the system and install gettext for envsubst.
RUN apk -U upgrade && \
apk add --update --no-cache gettext

# Copy files from outside docker to inside.
COPY build/appConfig.js.template /usr/local/app/templates/appConfig.js.template
COPY build/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh

# Enable execute of docker entrypoint for root user.
RUN chmod ugo+r /usr/local/app/templates/appConfig.js.template && \
chmod ugo+rx /usr/local/bin/docker-entrypoint.sh

# Create the user and group (use a high ID to attempt to avoid conflicts).
RUN groupadd --non-unique -g $USER_ID $USER_NAME && \
useradd --non-unique -d /$USER_NAME -m -u $USER_ID -g $USER_ID $USER_NAME
RUN chmod ugo+x /usr/local/bin/docker-entrypoint.sh

# Login as user.
USER $USER_NAME

# Set deployment directory.
WORKDIR /$USER_NAME
WORKDIR $HOME_DIR


# Copy over the built artifact and library from the maven image.
COPY --from=maven $SOURCE_DIR/target/vireo-*.war ./vireo.war
COPY --from=maven $SOURCE_DIR/target/libs ./libs

ENV AUTH_STRATEGY=weaverAuth

ENV STOMP_DEBUG=false

ENV AUTH_SERVICE_URL=http://localhost:9001/auth

ENV APP_CONFIG_PATH=file:/$USER_NAME/appConfig.js

EXPOSE 9000

# Entrypoint performs environment substitution on appConfig.js.
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ $ mvn clean spring-boot:run -Dproduction
$ mvn clean package -DskipTests -Dproduction -Dassets.uri=file:/opt/vireo/ -Dconfig.uri=file:/opt/vireo/config/
```

If build succeeds, you should have both a `vireo-4.1.5.war` and a `vireo-4.1.5-install.zip` in the `target/` directory. When building for production required static assets are copied into the packaged war file and the index.html template is optimized for production. For development a symlink is used to allow the application to access required static assets.
If build succeeds, you should have both a `vireo-4.2.0.war` and a `vireo-4.2.0-install.zip` in the `target/` directory. When building for production required static assets are copied into the packaged war file and the index.html template is optimized for production. For development a symlink is used to allow the application to access required static assets.

#### Apache Reverse Proxy Config

Expand Down Expand Up @@ -117,7 +117,7 @@ Unzip package into preferred directory (or any directory you choose):

```bash
$ cd /opt/vireo
$ unzip vireo-4.1.5-install.zip
$ unzip vireo-4.2.0-install.zip
```

### Directory Structure of installed package
Expand Down Expand Up @@ -190,13 +190,13 @@ ln -s /opt/vireo/webapp /opt/tomcat/webapps/ROOT
Copy war file into Tomcat webapps directory (your location may vary -- this is an example):

```bash
$ cp ~/vireo-4.1.5.war /usr/local/tomcat/webapps/vireo.war
$ cp ~/vireo-4.2.0.war /usr/local/tomcat/webapps/vireo.war
```

or as root:

```bash
$ cp ~/vireo-4.1.5.war /usr/local/tomcat/webapps/ROOT.war
$ cp ~/vireo-4.2.0.war /usr/local/tomcat/webapps/ROOT.war
```

**if not specifying assets.uri during build the assets will be stored under the vireo webapp's classpath, /opt/tomcat/webapps/vireo/WEB-INF/classes**
Expand All @@ -209,7 +209,7 @@ $ cp ~/vireo-4.1.5.war /usr/local/tomcat/webapps/ROOT.war
## Running WAR as a stand-alone Spring Boot application

```bash
java -jar target/vireo-4.1.5.war
java -jar target/vireo-4.2.0.war
```

<div align="right">(<a href="#readme-top">back to top</a>)</div>
Expand Down
2 changes: 1 addition & 1 deletion build/appConfig.js.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var appConfig = {

'version': '4.1.5',
'version': '4.2.0',

'allowAnonymous': true,
'anonymousRole': 'ROLE_ANONYMOUS',
Expand Down
83 changes: 48 additions & 35 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,50 @@
version: '3.7'
version: '3.8'

networks:
net:

networks:
weaver:

services:

vireo_db:
container_name: vireo_db
hostname: vireo_db
image: postgres
environment:
POSTGRES_DB: vireo
POSTGRES_USER: vireo
POSTGRES_PASSWORD: vireo
volumes:
- ${LOCAL_VIREO_PGDATA}:/var/lib/postgresql/data
networks:
weaver:

vireo:
volumes:
pgdata:
assets:

services:

db:
image: postgres
environment:
- POSTGRES_DB=vireo
- POSTGRES_USER=vireo
- POSTGRES_PASSWORD=vireo
volumes:
- pgdata:/var/lib/postgresql/data
ports:
- 5432:5432
networks:
- net

adminer:
image: adminer
ports:
- 8080:8080
depends_on:
- db
networks:
- net

vireo:
container_name: vireo
hostname: vireo
build:
dockerfile: Dockerfile
context: './'
image: ${IMAGE_HOST}/${SERVICE_PROJECT}${SERVICE_PATH}:${IMAGE_VERSION}
ports:
- 9000:9000
env_file:
- .env
volumes:
- ${LOCAL_VIREO_PATH}:${APP_PATH}
depends_on:
- vireo_db
networks:
weaver:
hostname: vireo
image: ${IMAGE_HOST}/${SERVICE_PROJECT}/${SERVICE_PATH}:${IMAGE_VERSION}
build:
dockerfile: Dockerfile
context: './'
env_file:
- .env
volumes:
- assets:${APP_PATH}
ports:
- 9000:9000
depends_on:
- db
networks:
- net
31 changes: 17 additions & 14 deletions example.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,35 @@
##############################

IMAGE_HOST=127.0.0.1
IMAGE_VERSION=4.2.0
SERVICE_PROJECT=tdl
SERVICE_PATH=vireo

IMAGE_VERSION=0.0.1
NODE_ENV=production

SERVICE_PROJECT=vireo
STOMP_DEBUG=false

# Must have leading slash.
SERVICE_PATH=/vireo
AUTH_STRATEGY=weaverAuth

LOCAL_VIREO_PATH=/var/vireo/
LOCAL_VIREO_PGDATA=/var/vireo/pgdata/
AUTH_SERVICE_URL="window.location.protocol + '//' + window.location.host + window.location.base + '/mock/auth'"

NODE_ENV=production

STOMP_DEBUG=false
#SPRING_JPA_DATABASE_PLATFORM=org.hibernate.dialect.H2Dialect
SPRING_JPA_DATABASE_PLATFORM=org.hibernate.dialect.PostgreSQLDialect

AUTH_SERVICE_URL="window.location.protocol + '//' + window.location.host + window.location.base + '/mock/auth'"
SPRING_JPA_HIBERNATE_DDL_AUTO=update

#SPRING_DATASOURCE_URL=jdbc:h2:mem:AZ;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
#SPRING_DATASOURCE_DRIVERCLASSNAME=org.h2.Driver
SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/vireo
SPRING_DATASOURCE_DRIVERCLASSNAME=org.postgresql.Driver

SPRING_DATASOURCE_URL=jdbc:h2:mem:AZ;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
SPRING_DATASOURCE_DRIVERCLASSNAME=org.h2.Driver
SPRING_DATASOURCE_USERNAME=vireo
SPRING_DATASOURCE_PASSWORD=vireo
SPRING_JPA_DATABASE_PLATFORM=org.hibernate.dialect.H2Dialect
SPRING_JPA_HIBERNATE_DDL_AUTO=update


# location to place templated appConfig.js
APP_PATH=/var/vireo/
APP_PATH=/var/vireo
# must match directory of APP_PATH
APP_CONFIG_URI=file:/var/vireo/appConfig.js
APP_ASSETS_URI=file:/var/vireo/
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vireo",
"private": false,
"version": "4.1.5",
"version": "4.2.0",
"description": "Vireo 4",
"homepage": "https://github.com/TexasDigitalLibrary/Vireo",
"repository": {
Expand All @@ -22,7 +22,7 @@
"build": "wvr build --clean"
},
"dependencies": {
"@wvr/core": "2.2.4",
"@wvr/core": "2.2.5-rc.3",
"angular-ui-tinymce": "0.0.19",
"file-saver": "2.0.5",
"ng-csv": "0.3.6",
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.tdl</groupId>
<artifactId>vireo</artifactId>
<version>4.1.5</version>
<version>4.2.0</version>

<name>Vireo</name>
<description>Vireo Thesis and Dissertation Submission System</description>
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/org/tdl/vireo/config/VireoDatabaseConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.tdl.vireo.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

@Configuration
public class VireoDatabaseConfig {

@Value("${spring.sql.init.platform:''}")
private String platform;

public String getPlatform() {
return platform;
}

public void setPlatform(String platform) {
this.platform = platform;
}

}
Loading

0 comments on commit 8ff079b

Please sign in to comment.