Skip to content

Commit 518bec1

Browse files
authored
Merge pull request #1029 from devgateway/OCE-546-upgrade
Oce 546 upgrade
2 parents 4897d15 + 81dfcb5 commit 518bec1

File tree

984 files changed

+76897
-35454
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

984 files changed

+76897
-35454
lines changed

.env

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
JWT_SECRET=1321323232
2+
POSTGRES_USER=postgres
3+
POSTGRES_PASSWORD=1234
4+
MONGO_INITDB_ROOT_USERNAME=root
5+
MONGO_INITDB_ROOT_PASSWORD=1234
6+
RECAPTCHA_SECRET=431243325342
7+
INFOBIP_KEY=452789534289
8+
SMSGATEWAY_KEY=98459432897
9+
SMTP_PORT=25
10+
SMTP_HOST=host.docker.internal
11+
SERVER_URL=http://localhost:8090
12+
SPRING_DEVTOOLS_RESTART_ENABLED=false
13+
DISABLE_EMAIL_SENDING=false
14+
APP_IMAGE=ocportal-client/admin/dev
15+
TAG=latest
16+
PROJECT_NAME=ocmakueni
17+
18+
#Organization properties
19+
ORG_NAME=Wakanda
20+
ORG_SHORT_NAME=DOGEdd

.github/workflows/docker-image.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Docker Image CI
2+
3+
on:
4+
push:
5+
branches: [ "develop" ]
6+
pull_request:
7+
branches: [ "develop" ]
8+
9+
jobs:
10+
11+
build:
12+
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
- name: Build the Docker image
18+
run: docker compose build

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v14.15.2

Dockerfile

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Base image for compiling
2+
FROM maven:3.8-openjdk-17 as compiler
3+
4+
WORKDIR /tmp/build
5+
6+
# Install required tools
7+
RUN microdnf install zip
8+
9+
# Define a build argument for project name (default: ocportal)
10+
ARG PROJECT_NAME=ocportal
11+
12+
# Copy pom.xml files
13+
COPY forms/pom.xml forms/pom.xml
14+
COPY persistence/pom.xml persistence/pom.xml
15+
COPY persistence-mongodb/pom.xml persistence-mongodb/pom.xml
16+
COPY web/pom.xml web/pom.xml
17+
COPY pom.xml .
18+
19+
# Set Maven options
20+
ENV MAVEN_OPTS="-XX:-TieredCompilation -XX:TieredStopAtLevel=1"
21+
22+
# Use a cache-friendly Maven dependency resolution
23+
RUN --mount=type=cache,target=/root/.m2,id=${PROJECT_NAME}-m2 \
24+
find . -name pom.xml | xargs -I@ mvn -B -f @ dependency:go-offline dependency:resolve-plugins || true
25+
26+
# Copy all source code
27+
COPY . .
28+
#we compile the code then we explode the fat jar. This is useful to create a reusable layer and save image space/compile time
29+
RUN --mount=type=cache,target=/root/.m2,id=${PROJECT_NAME}-m2 \
30+
mvn -T 1C clean package -DskipTests -Dmaven.javadoc.skip=true -Dmaven.test.skip=true -Dmaven.gitcommitid.skip=true
31+
32+
# Extract compiled JAR to save space and improve caching
33+
RUN mkdir -p forms/target/deps \
34+
&& cd forms/target/deps \
35+
&& unzip -qo '../*.jar' || ( e=$? && if [ $e -ne 1 ]; then exit $e; fi ) \
36+
&& rm -f ../*.*
37+
38+
# Production image
39+
FROM openjdk:17-jdk-slim as prod
40+
41+
WORKDIR /opt/app
42+
43+
# Install required dependencies
44+
RUN apt-get update && apt-get install -y fontconfig libfreetype6 && rm -rf /var/lib/apt/lists/*
45+
#we copy artifacts from exploded jar, one by one, each COPY command will create a separate docker layer
46+
#this means that for example if lib folder gets unchanged in between builds (no jars were updated) the same layer is reused
47+
COPY --from=compiler /tmp/build/forms/target/deps/BOOT-INF/lib lib
48+
COPY --from=compiler /tmp/build/forms/target/deps/META-INF META-INF
49+
COPY --from=compiler /tmp/build/forms/target/deps/BOOT-INF/classes .
50+
51+
# Copy entrypoint script
52+
COPY --chmod=0755 entrypoint.sh .
53+
54+
# Expose application port
55+
EXPOSE 8090
56+
57+
# Wait for dependencies before starting app
58+
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.12.0/wait /wait
59+
RUN chmod +x /wait
60+
61+
# Start application
62+
CMD /wait && /opt/app/entrypoint.sh admin
63+
64+
# Development image
65+
FROM openjdk:17-jdk-slim as dev
66+
67+
WORKDIR /opt/app
68+
69+
# Install required dependencies
70+
RUN apt-get update && apt-get install -y fontconfig libfreetype6 && rm -rf /var/lib/apt/lists/*
71+
72+
# Copy compiled dependencies
73+
COPY --from=compiler /tmp/build/forms/target/deps/BOOT-INF/lib lib
74+
75+
# Remove development-specific JARs to avoid conflicts
76+
RUN rm -f lib/persistence*-SNAPSHOT.jar
77+
RUN rm -f lib/web*-SNAPSHOT.jar
78+
79+
# Copy entrypoint script
80+
COPY --chmod=0755 entrypoint.sh .
81+
82+
# Expose application and debug ports
83+
EXPOSE 8090
84+
EXPOSE 8000
85+
86+
# Enable remote debugging
87+
ENV JAVA_TOOL_OPTIONS "-agentlib:jdwp=transport=dt_socket,address=*:8000,server=y,suspend=n"
88+
89+
# Wait for database readiness before starting the app
90+
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.12.0/wait /wait
91+
RUN chmod +x /wait
92+
93+
# Start application in development mode
94+
CMD /wait && /opt/app/entrypoint.sh admin-dev

Jenkinsfile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
pipeline {
2+
agent any
3+
tools {
4+
maven 'Maven36'
5+
}
6+
7+
stages {
8+
stage('Build') {
9+
steps {
10+
sh 'mvn -T 4C clean package -Dmaven.javadoc.skip=true -Dmaven.compile.fork=true -Dmaven.junit.fork=true -DskipTests'
11+
archiveArtifacts artifacts: 'forms/target/forms*.jar', fingerprint: true
12+
}
13+
}
14+
}
15+
post {
16+
always {
17+
cleanWs(cleanWhenNotBuilt: false, deleteDirs: true)
18+
}
19+
}
20+
21+
}

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
[![Build Status](https://travis-ci.org/devgateway/oc-explorer.svg?branch=develop)](https://travis-ci.org/devgateway/oc-explorer)
44

5+
[![Docker Image CI](https://github.com/devgateway/ocportal-nandi/actions/workflows/docker-image.yml/badge.svg?branch=develop)](https://github.com/devgateway/ocportal-nandi/actions/workflows/docker-image.yml)
6+
57
## Presentation
68

79
OCE is a project that allows importing the public procurement data, available in the common MS Excel format, into a native [Open Contracting Data Standard (OCDS)](http://standard.open-contracting.org/) NoSQL storage, and then run visual data analytics (display a *live* dashboard with charts, maps and data tables as well as custom comparison charts). Since the data is natively stored in the OCDS format, it can be readily exported in this format without any transformation required, and with great throughput.

checkstyle.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
<metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" value="inherit"/>
123123
</module>
124124
<module name="SuppressionFilter">
125-
<property name="file" value="checkstyle-suppressions.xml"/>
125+
<property name="file" value="${checkstyle.config.path}checkstyle-suppressions.xml"/>
126126
<property name="optional" value="false"/>
127127
</module>
128128
</module>

docker-compose-dev.yml

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
version: '3.8'
2+
3+
services:
4+
5+
app:
6+
image: ${APP_IMAGE:-ocportal/admin/dev}:${TAG:-local}
7+
restart: 'no'
8+
extra_hosts:
9+
- "host.docker.internal:host-gateway" #required so docker connects to host interface (this is for sending emails)
10+
build:
11+
target: dev
12+
args:
13+
PROJECT_NAME: ${PROJECT_NAME:-ocportal}
14+
depends_on:
15+
- db
16+
- mongo
17+
ports:
18+
- "8090:8090"
19+
- "8000:8000"
20+
env_file:
21+
- .env
22+
environment:
23+
# Set environment variables that the app can use at runtime
24+
ORG_NAME: ${ORG_NAME:-Makueni County Government}
25+
ORG_SHORT_NAME: ${ORG_SHORT_NAME:-Makueni}
26+
#entrypoint: /bin/sh -c "while sleep 1000; do :; done"
27+
volumes:
28+
- ./forms/target/classes:/opt/app/forms/classes
29+
- ./persistence/target/classes:/opt/app/persistence/classes
30+
- ./persistence-mongodb/target/classes:/opt/app/persistence-mongodb/classes
31+
- ./web/target/classes:/opt/app/web/classes
32+
- ./ui:/opt/app/ui
33+
34+
db:
35+
image: postgis/postgis:11-3.3
36+
restart: 'no'
37+
volumes:
38+
- pgdata:/var/lib/postgresql/data
39+
ports:
40+
- "5432:5432"
41+
env_file:
42+
- .env
43+
44+
mongo:
45+
image: mongo:4.2
46+
restart: 'no'
47+
command: [--auth]
48+
volumes:
49+
- mongodata:/data/db
50+
ports:
51+
- "27017:27017"
52+
env_file:
53+
- .env
54+
55+
# pgbackups:
56+
# image: prodrigestivill/postgres-backup-local
57+
# restart: 'no'
58+
# volumes:
59+
# - /opt/pgbackups:/backups
60+
# env_file:
61+
# - .env
62+
# depends_on:
63+
# - db
64+
# environment:
65+
# - POSTGRES_HOST=db
66+
# - POSTGRES_DB=ocportal
67+
# - POSTGRES_USER=$POSTGRES_USER
68+
# - POSTGRES_PASSWORD=$POSTGRES_PASSWORD
69+
# - SCHEDULE=@daily
70+
# - BACKUP_KEEP_DAYS=30
71+
# - BACKUP_KEEP_WEEKS=12
72+
# - BACKUP_KEEP_MONTHS=24
73+
# - HEALTHCHECK_PORT=5432
74+
75+
volumes:
76+
pgdata:
77+
mongodata:

docker-compose.yml

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
version: '3.8'
2+
3+
services:
4+
5+
app:
6+
image: ${APP_IMAGE:-ocportal/admin/dev}:${TAG:-local}
7+
restart: always
8+
extra_hosts:
9+
- "host.docker.internal:host-gateway" #required so docker connects to host interface (this is for sending emails)
10+
build:
11+
target: prod
12+
args:
13+
PROJECT_NAME: ${PROJECT_NAME:-ocportal}
14+
depends_on:
15+
- db
16+
- mongo
17+
ports:
18+
- "127.0.0.1:8090:8090"
19+
env_file:
20+
- .env
21+
22+
db:
23+
image: postgis/postgis:11-3.3
24+
restart: always
25+
volumes:
26+
- pgdata:/var/lib/postgresql/data
27+
env_file:
28+
- .env
29+
30+
mongo:
31+
image: mongo:4.2
32+
restart: always
33+
command: [--auth]
34+
volumes:
35+
- mongodata:/data/db
36+
env_file:
37+
- .env
38+
39+
pgbackups:
40+
image: prodrigestivill/postgres-backup-local
41+
restart: always
42+
volumes:
43+
- /opt/pgbackups:/backups
44+
env_file:
45+
- .env
46+
depends_on:
47+
- db
48+
environment:
49+
- POSTGRES_HOST=db
50+
- POSTGRES_DB=ocportal
51+
- POSTGRES_USER=$POSTGRES_USER
52+
- POSTGRES_PASSWORD=$POSTGRES_PASSWORD
53+
- SCHEDULE=@daily
54+
- BACKUP_KEEP_DAYS=30
55+
- BACKUP_KEEP_WEEKS=12
56+
- BACKUP_KEEP_MONTHS=24
57+
- HEALTHCHECK_PORT=5432
58+
59+
volumes:
60+
pgdata:
61+
mongodata:

entrypoint.sh

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/sh
2+
3+
COMMON_JAVA_ARGS="$(tr '\n' ' ' <<-EOF
4+
-server
5+
-DjwtSecret=$JWT_SECRET
6+
-Dserver.address=0.0.0.0
7+
-Dwicket.configuration=deployment
8+
-Dfile.encoding=UTF-8
9+
-DserverURL=$SERVER_URL
10+
-DdisableEmailSending=$DISABLE_EMAIL_SENDING
11+
-Dspring.devtools.restart.enabled=$SPRING_DEVTOOLS_RESTART_ENABLED
12+
-Xms512m
13+
-Xmx6144m
14+
--add-opens=java.naming/jakarta.naming=ALL-UNNAMED
15+
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED
16+
--add-opens=java.base/java.lang.ref=ALL-UNNAMED
17+
--add-opens=java.base/java.lang=ALL-UNNAMED
18+
--add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED
19+
--add-opens=java.base/java.lang.invoke=ALL-UNNAMED
20+
--add-opens=java.base/java.io=ALL-UNNAMED
21+
--add-opens=java.base/java.security=ALL-UNNAMED
22+
--add-opens=java.base/java.util=ALL-UNNAMED
23+
--add-opens=java.management/jakarta.management=ALL-UNNAMED
24+
-Dspring.mail.port=$SMTP_PORT
25+
-Dspring.mail.host=$SMTP_HOST
26+
-XX:MaxMetaspaceSize=512m
27+
-XX:ReservedCodeCacheSize=256m
28+
-Dspring.jmx.enabled=true
29+
-Dspring.datasource.username=$POSTGRES_USER
30+
-Dspring.datasource.password=$POSTGRES_PASSWORD
31+
-DJava.awt.headless=true
32+
-XX:+UseG1GC
33+
-Dspring.data.mongodb.uri=mongodb://$MONGO_INITDB_ROOT_USERNAME:$MONGO_INITDB_ROOT_PASSWORD@mongo:27017/ocportal?authSource=admin
34+
-Dspring.datasource.url=jdbc:postgresql://db/ocportal
35+
-Dgoogle.recaptcha.secret=$RECAPTCHA_SECRET
36+
-Dinfobip.key=$INFOBIP_KEY
37+
-Dsmsgateway.key=$SMSGATEWAY_KEY
38+
EOF
39+
)"
40+
41+
case "$1" in
42+
admin)
43+
JAVA_ARGS="${COMMON_JAVA_ARGS} $(tr '\n' ' ' <<-EOF
44+
-cp .:lib/*
45+
org.devgateway.toolkit.forms.wicket.FormsWebApplication
46+
EOF
47+
)"
48+
exec java $JAVA_ARGS $@
49+
;;
50+
admin-dev)
51+
JAVA_ARGS="${COMMON_JAVA_ARGS} $(tr '\n' ' ' <<-EOF
52+
-Dspring.devtools.restart.additional-exclude=logs/**,META-INF/**,ehcache-disk-store/**
53+
-Dspring.devtools.restart.poll-interval=3s
54+
-Dspring.devtools.restart.quiet-period=2s
55+
-XX:+TieredCompilation
56+
-XX:TieredStopAtLevel=1
57+
-noverify
58+
-cp forms/classes:persistence-mongodb/classes:web/classes:persistence/classes:lib/*
59+
org.devgateway.toolkit.forms.wicket.FormsWebApplication
60+
EOF
61+
)"
62+
exec java $JAVA_ARGS $@
63+
;;
64+
*)
65+
exec "$@"
66+
;;
67+
esac

forms/.env

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ORG_NAME=Wakanda
2+
ORG_SHORT_NAME=REDDIT
3+
LOGO_PATH=assets/img/logo.png

forms/forms.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
JAVA_OPTS="-Dspring.profiles.active=default -Djava.awt.headless=true -Xmx4096M -Dwicket.configuration=deployment -Dderby.optimizer.optimizeJoinOrder=false -Dspringfox.documentation.swagger.v2.host=website.url"
1+
JAVA_OPTS="-Dspring.profiles.active=default -Djava.awt.headless=true -Xmx4096M -Dwicket.configuration=deployment -Dderby.optimizer.optimizeJoinOrder=false"

0 commit comments

Comments
 (0)