Skip to content

Commit

Permalink
Add config and build scripts (#1)
Browse files Browse the repository at this point in the history
* Add default ala config template

* Update config from production

* Add config files from ala-install

* Update configs from prod

* Update config. Add Makefile, docker-compose and Dockerfile

* Add build workflow and readme

* Removed log4j.xml

* Update config

* Update docker compose
  • Loading branch information
matsbov committed Nov 15, 2023
1 parent 2a572a5 commit 37364e6
Show file tree
Hide file tree
Showing 17 changed files with 4,524 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Build

on:
push:
branches:
- '*'
tags:
- '*'

jobs:

build:

runs-on: ubuntu-latest
steps:
- name: Checkout project sources
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Run build with Gradle Wrapper
run: ./gradlew build -x test

- name: Upload war
uses: actions/upload-artifact@v3
with:
name: package
path: build/libs

- name: Log in to the Container registry
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}

- name: Build and push Docker image
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM tomcat:9.0-jdk11-temurin

ENV TZ=Europe/Stockholm

RUN mkdir -p \
/data/biocache/config \
/data/biocache/heatmap \
/data/biocache/tmp \
/data/biocache-load \
/data/biocache-media \
/data/biocache-upload \
/data/biocache-delete \
/data/biocache-download/tmp \
/data/cache \
/data/offline/exports \
/data/logger-client/config

COPY sbdi/data/config/*.json /data/biocache/config/
COPY sbdi/data/config/*.xml /data/biocache/config/
COPY sbdi/data/config/*.html /data/biocache/config/

COPY build/libs/biocache-service-*.war $CATALINA_HOME/webapps/ws.war

ENV DOCKERIZE_VERSION v0.7.0

RUN apt-get update \
&& apt-get install -y wget \
&& wget -O - https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz | tar xzf - -C /usr/local/bin \
&& apt-get autoremove -yqq --purge wget && rm -rf /var/lib/apt/lists/*
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
run:
docker compose up cassandra solr --detach
./gradlew bootRun

# Change cassandra and solr connections in biocache-config.properties for this to work
# Replace localhost with cassandra and solr respectively
# Also, the service may fail on startup if cassandra isn't ready. Just restart the service if that happens.
run-docker:
./gradlew clean build -x test
docker compose build --no-cache
docker compose up --detach

release:
../sbdi-install/utils/make-release.sh
40 changes: 40 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: '3.8'

services:

cassandra:
image: cassandra:3.11
environment:
MAX_HEAP_SIZE: 128M
HEAP_NEWSIZE: 24M
ports:
- 9042:9042
volumes:
- db_cassandra:/var/lib/cassandra

solr:
image: ghcr.io/biodiversitydata-se/biocache-solr:1.0.0
#image: sbdi/biocache-solr-dev
environment:
SOLR_HEAP: 4g
SOLR_OPTS: "-Dlog4j2.formatMsgNoLookups=true"
#build:
# context: ../biocache-solr
ports:
- "8983:8983"
volumes:
- data_solr:/var/solr

biocache-service:
image: sbdi/biocache-service-dev
build:
context: .
ports:
- 8080:8080
volumes:
- ./sbdi/data/config/biocache-config.properties:/data/biocache/config/biocache-config.properties
- ./sbdi/data/config/logger-client.properties:/data/logger-client/config/logger-client.properties

volumes:
db_cassandra:
data_solr:
54 changes: 54 additions & 0 deletions sbdi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Biocache-service

## Setup
This service requires a rather elaborate directory and file structure in `/data/`:
```
mats@xps-13:/data$ tree biocache* cache offline logger-client
biocache
├── config
│ ├── applicationContext.xml -> /home/mats/src/biodiversitydata-se/biocache-service/sbdi/data/config/applicationContext.xml
│ ├── biocache-config.properties -> /home/mats/src/biodiversitydata-se/biocache-service/sbdi/data/config/biocache-config.properties
│ ├── download-csdm-email.html -> /home/mats/src/biodiversitydata-se/biocache-service/sbdi/data/config/download-csdm-email.html
│ ├── download-doi-email.html -> /home/mats/src/biodiversitydata-se/biocache-service/sbdi/data/config/download-doi-email.html
│ ├── download-doi-readme.html -> /home/mats/src/biodiversitydata-se/biocache-service/sbdi/data/config/download-doi-readme.html
│ ├── download-email.html -> /home/mats/src/biodiversitydata-se/biocache-service/sbdi/data/config/download-email.html
│ ├── download-readme.html -> /home/mats/src/biodiversitydata-se/biocache-service/sbdi/data/config/download-readme.html
│ ├── facets.json -> /home/mats/src/biodiversitydata-se/biocache-service/sbdi/data/config/facets.json
│ ├── groups.json -> /home/mats/src/biodiversitydata-se/biocache-service/sbdi/data/config/groups.json
│ ├── pipelines-field-config.json -> /home/mats/src/biodiversitydata-se/biocache-service/sbdi/data/config/pipelines-field-config.json
│ └── subgroups.json -> /home/mats/src/biodiversitydata-se/biocache-service/sbdi/data/config/subgroups.json
├── heatmap
└── tmp
biocache-delete
biocache-download
biocache-load
biocache-media
biocache-upload
cache
offline
└── exports
logger-client
└── config
└── logger-client.properties -> /home/mats/src/biodiversitydata-se/biocache-service/sbdi/data/config/logger-client.properties
```

## Usage

Run locally:
```
make run
```

Build and run in Docker (using Tomcat):
```
make run-docker
```

Make a release. This will create a new tag and push it. A new Docker container will be built on Github.
```
mats@xps-13:~/src/biodiversitydata-se/biocache-service (master *)$ make release
Current version: 1.0.1. Enter the new version (or press Enter for 1.0.2):
Updating to version 1.0.2
Tag 1.0.2 created and pushed.
```
36 changes: 36 additions & 0 deletions sbdi/data/config/applicationContext.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jms="http://www.springframework.org/schema/jms"
xmlns:amq="http://activemq.apache.org/schema/core"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jms
http://www.springframework.org/schema/jms/spring-jms.xsd
http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core.xsd">

<!-- Example ActiveMQ JMS settings
<bean id="jmsMessageListener" class="org.ala.jms.service.JmsMessageListener" />
<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61616" />
<property name="userName" value="system" />
<property name="password" value="manager" />
</bean>
<bean id="pooledJmsConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory"
destroy-method="stop">
<property name="connectionFactory" ref="jmsConnectionFactory" />
</beans>
<jms:listener-container container-type="default"
connection-factory="pooledJmsConnectionFactory"
acknowledge="auto">
<jms:listener destination="au.org.ala.cs" ref="jmsMessageListener" />
</jms:listener-container>
</beans>
-->

</beans>
Loading

0 comments on commit 37364e6

Please sign in to comment.