Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dockerize recogito #711

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ libraryDependencies ++= Seq(

"org.jooq" % "joox" % "1.5.0",

"org.postgresql" % "postgresql" % "9.4.1208.jre7",
//"org.postgresql" % "postgresql" % "9.4.1208.jre7",
"org.postgresql" % "postgresql" % "42.6.0",

"org.webjars" %% "webjars-play" % "2.6.2",

Expand Down
2 changes: 1 addition & 1 deletion conf/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
}]
}
},
"/api/place/{uri}" : {
":9000/api/place/{uri}" : {
"get": {
"tags": [ "Authorities" ],
"summary": "Get place information and coordinates for a specific gazetteeer URI.",
Expand Down
2 changes: 2 additions & 0 deletions notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
it works with node 21 and postgress 16
added trust just for recogito database in hba file. -check for the right encryption method!-
81 changes: 81 additions & 0 deletions ops/cdhu-docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# We need JDK 8 and SBT 1.0.x
FROM sbtscala/scala-sbt:eclipse-temurin-jammy-8u392-b08_1.9.7_2.13.12 As build

# Based on https://github.com/Wadjetz/scala-sbt-nodejs/blob/master/Dockerfile

# install node
RUN apt-get update && apt-get install -y ca-certificates curl gnupg
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
RUN apt-get update && apt-get install nodejs -y
RUN apt-get install unzip
RUN apt-get clean

# Install livips and jre

RUN apt-get install libvips-tools -y
RUN apt-get install openjdk-8-jre -y


# For now we work with the master branch
RUN git clone https://github.com/Maen1/recogito.git /usr/share/recogito


# Move to workdir
WORKDIR /usr/share/recogito

#Copy application.conf ./conf/
RUN npm install -g webpack webpack-cli
RUN npm install
# We expect one failure due to jai_core being wrongly resolved
RUN sbt compile; exit 0
RUN sbt compile

# END OF SETUP
# For a development image, uncomment the following two lines, and remove or
# comment out the rest of the file. You probably want to mount a
# configuration file to /usr/share/recogito/conf/application.conf unless
# you want to redo all the configuration on each container reset
#EXPOSE 9000
#CMD ["sbt", "run"]
#CMD ["/bin/recogito2"]
# Let's create an actual distribution
RUN sbt dist

# And unzip it somewhere useful
RUN unzip target/universal/recogito2-2.2.zip -d /opt/

RUN ls -AlFh /opt

# END OF BUILD STAGE
# To slim down the final production image, we begin a new stage

FROM openjdk:8-jre

# This is the dist stage

# We still need libvips
RUN apt-get update && \
apt-get install -y libvips-tools sendmail && \
apt-get clean

RUN ls -AlFh /opt

# But we don't need any of the other build artifacts - just grab the dist
COPY --from=build /opt/recogito2-2.2/ /opt/recogito/

WORKDIR /opt/recogito/

# You want to mount a configuration in /opt/recogito/conf/application.conf

# For production use, you also want to mount the relevant upload directory
# for persistance - by default that would be /opt/recogito/uploads
# though it is configurable in application.conf

# This line added by JvB to enable logging
RUN mkdir /var/log/recogito

# Open the port we're running on
EXPOSE 9000
CMD ["/opt/recogito/bin/recogito2"]

127 changes: 127 additions & 0 deletions ops/cdhu-docker/application.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# This is the main configuration file for the application.
# ~~~~~
admin.email="admin@recogito.abm.uu.se"

# Secret key
# ~~~~~
# The secret key is used to secure cryptographics functions.
#
# This must be changed for production, but we recommend not changing it in this file.
#
# See http://www.playframework.com/documentation/latest/ApplicationSecret for more details.
play.http.secret.key = "goox0Oe7Shee5Uuso2SheeLaekuthiep"

# The application languages
# ~~~~~
play.i18n.langs = [ "en", "bn", "de", "el", "es", "fa", "fr", "he", "it", "ja", "nl", "tr" ]

# Maximum size for file uploads
# ~~~~~
play.http.parser.maxDiskBuffer=500MB
play.http.parser.maxMemoryBuffer=20MB


# Server request timeout value (default = 20s)
# ~~~~~
# play.server.akka.requestTimeout=180s

# Set to true if running Recogito over HTTPS
auth.cookie.secure=false

# Router
# ~~~~~
# Define the Router object to use for this application.
# This router will be looked up first when the application is starting up,
# so make sure this is the entry point.
# Furthermore, it's assumed your route file is named properly.
# So for an application router like `my.application.Router`,
# you may need to define a router file `conf/my.application.routes`.
# Default to Routes in the root package (and conf/routes)
# play.http.router = my.application.Routes

# Uploads location
recogito.upload.dir = /opt/recogito/uploads

# Default max. disk space per user in MB
recogito.upload.quota = 200

# Temp directory location
# No need to set this normally. Only use this if you want Recogito to use a different
# directory than the OS default.
# recogito.temp.dir = /tmp

# E-Mail encryption key (optional)
recogito.email.key = "my secret key"

# Database configuration
# ~~~~~
# You can declare as many datasources as you want.
# By convention, the default datasource is named `default`
#
db.default.driver="org.postgresql.Driver"
db.default.url="jdbc:postgresql://postgres:5432/recogito"
db.default.username="USERNAME"
db.default.password="PASSWORD"

# ElasticSearch configuration
# ~~~~~
es.host = elasticsearch
es.port = 9300
es.cluster.name = docker-cluster

# Evolutions
# ~~~~~
# You can disable evolutions if needed
# play.evolutions.enabled=false

# You can disable evolutions for a specific datasource if necessary
# play.evolutions.db.default.enabled=false

# Modules
play.modules {
enabled += controllers.SilhouetteSecurity

enabled += services.entity.builtin.EntityServiceModule

enabled += storage.db.DBModule
enabled += storage.es.ESModule

disabled += com.mohiva.play.silhouette.api.actions.SecuredErrorHandlerModule
}

akka {
jvm-exit-on-fatal-error = off
}

contexts {
database {
fork-join-executor {
parallelism-max = 9
}
}

background-workers {
type = Dispatcher
executor = "thread-pool-executor"
thread-pool-executor {
fixed-pool-size = 16
}
throughput = 1
}
}

play.mailer {
host = smtp.uu.se
port = 25
ssl = no
tls = no
user = "admin@recogito.abm.uu.se"
password = false
mock = false
}


# Recogito plugins
# plugins {
# python.executable = python3 # in case your system uses a different python executable alias
# }
22 changes: 22 additions & 0 deletions ops/cdhu-docker/backup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
START_TIME=$SECONDS

TODAY="$(date +'%Y%m%d')"

LOG_FILE="./backup$TODAY.log"

echo "Creating PostgreSQL DB dump" | tee -a "$LOG_FILE"

docker exec -i postgres pg_dump -U recogito_backup recogito > ./backup$TODAY.sql


echo "Zipping all" | tee -a "$LOG_FILE"

backup_date=$(date +"%Y%m%d")
source_folder="./recogito-server"
backup_destination="./recogito-backup"

tar -czvf "$backup_destination/recogito-backup-latest.tar.gz" "$source_folder"


ELAPSED_TIME=$(($SECONDS - $START_TIME))
echo "Done. Took $ELAPSED_TIME seconds" | tee -a "$LOG_FILE"
33 changes: 33 additions & 0 deletions ops/cdhu-docker/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
server {
listen 80;
listen 443 ssl;
server_name recogito.abm.uu.se;
client_max_body_size 200m;

error_page 502 503 504 = @maintenance;

ssl_certificate ssl_cert.cer;
ssl_certificate_key private_key.key;

location / {
proxy_http_version 1.1;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

proxy_pass http://{{ ip:port}};
}

location @maintenance {
expires 0;
add_header Pragma "no-cache";
add_header Cache-Control "no-cache, no-store, must-revalidate";

root /var/www/html;
try_files $uri /50x.html =502;
}

}

71 changes: 71 additions & 0 deletions ops/cdhu-docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
version: '3.4'
services:

elasticsearch:
image: elasticsearch:5.6.16
container_name: elasticsearch
volumes:
- ./elasticsearch/esdata:/usr/share/elasticsearch/data
- ./recogito/elasticsearch/logs:/usr/share/elasticsearch/logs
- ./elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
environment:
- cluster.name=docker-cluster
- xpack.security.enabled=false
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms12g -Xmx12g"
ulimits:
memlock:
soft: -1
hard: -1
networks:
- intranet
ports:
- 9200:9200
- 9300:9300

recogito:
#image: cdhu1/recogito:latest
image: recogito:1.0
container_name: recogito
volumes:
- ./recogito/application.conf:/opt/recogito/conf/application.conf
- ./recogito/data:/opt/recogito/uploads
- ./recogito/plugins:/opt/recogito/plugins
- ./recogito/logback.xml:/opt/recogito/conf/logback.xml
- ./recogito/logs:/var/log/recogito
ports:
- 9333:9000
networks:
- intranet
command: sh -c "sleep 60 && bin/recogito2"

nginx:
image: nginx:stable
container_name: nginx
volumes:
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
- ./nginx/ssl/recogito_abm_uu_se_cert.cer:/etc/nginx/recogito_abm_uu_se_cert.cer
- ./nginx/ssl/recogito_private.key:/etc/nginx/recogito_private.key
ports:
- 80:80
- 443:443 # Expose port 443 for SSL
networks:
- intranet

postgres:
image: postgres:14.10
container_name: postgres
environment:
POSTGRES_USER: {{ username }}
POSTGRES_PASSWORD: {{ password }}
POSTGRES_DB: {{ dbname }}
volumes:
- ./postgres/data:/var/lib/postgresql/data
ports:
- 5432:5432
networks:
- intranet

networks:
intranet:

17 changes: 17 additions & 0 deletions ops/cdhu-docker/elasticsearch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cluster.name: docker-cluster
node.name: elasticsearch-node
network.host: 0.0.0.0
discovery.type: single-node

# Heap size settings (adjust as needed)
# Remember that these settings depend on your system resources.
# It's recommended to set the heap size based on available RAM.
# For example, for a system with 16GB RAM, you might set it to 8GB.
# Be cautious not to allocate all available RAM to Elasticsearch.
# See Elasticsearch documentation for more guidance.

# -Xms specifies the initial heap size
# -Xmx specifies the maximum heap size

# ES_JAVA_OPTS: "-Xms8g -Xmx8g"

Loading