Skip to content

Commit 5f4e268

Browse files
authored
Add webapi-3.0 ci (#2477)
* cleanup * add ci to publish docker image * fix * fix * fix * fix * fix * fix * update trexsql * readd migrations for broadsea * update
1 parent 28c58e4 commit 5f4e268

191 files changed

Lines changed: 4227 additions & 219 deletions

File tree

Some content is hidden

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

.github/workflows/ci.yaml

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ on:
88
pull_request:
99
branches: [ master, webapi-3.0 ]
1010

11-
env:
12-
DOCKER_IMAGE: ohdsi/webapi
13-
1411
jobs:
1512
# Build and test the code
1613
build:
@@ -23,7 +20,7 @@ jobs:
2320
# Steps represent a sequence of tasks that will be executed as part of the job
2421
steps:
2522
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
26-
- uses: actions/checkout@v2
23+
- uses: actions/checkout@v4
2724

2825
- uses: actions/setup-java@v4
2926
with:
@@ -47,15 +44,24 @@ jobs:
4744
run: mvn -B -P${{ env.MAVEN_PROFILE }} test
4845

4946
# Check that the docker image builds correctly
50-
# Push to ohdsi/atlas:master for commits on master.
47+
# Push to ghcr.io for commits on master or webapi-3.0.
5148
docker:
5249
# The type of runner that the job will run on
5350
runs-on: ubuntu-latest
5451

5552
# Steps represent a sequence of tasks that will be executed as part of the job
5653
steps:
5754
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
58-
- uses: actions/checkout@v2
55+
- uses: actions/checkout@v4
56+
57+
- name: Set Docker image name
58+
run: |
59+
REPO="${GITHUB_REPOSITORY:-ohdsi/webapi}"
60+
DOCKER_IMAGE="ghcr.io/$(echo "${REPO}" | tr '[:upper:]' '[:lower:]')"
61+
echo "DOCKER_IMAGE=${DOCKER_IMAGE}" >> $GITHUB_ENV
62+
63+
- name: Debug Docker image name
64+
run: echo "DOCKER_IMAGE=${DOCKER_IMAGE}"
5965

6066
- name: Cache Docker layers
6167
uses: actions/cache@v4
@@ -68,40 +74,54 @@ jobs:
6874
# Add Docker labels and tags
6975
- name: Docker meta
7076
id: docker_meta
71-
uses: crazy-max/ghaction-docker-meta@v1
77+
uses: docker/metadata-action@v5
7278
with:
7379
images: ${{ env.DOCKER_IMAGE }}
80+
tags: |
81+
type=raw,value=dev,enable=${{ github.ref == 'refs/heads/master' }}
82+
type=raw,value=3.0-dev,enable=${{ github.ref == 'refs/heads/webapi-3.0' }}
83+
type=sha,prefix=pr-,enable=${{ github.event_name == 'pull_request' }}
84+
type=ref,event=branch,prefix=branch-,enable=${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/webapi-3.0' }}
85+
86+
- name: Debug Docker metadata
87+
run: |
88+
echo "Docker metadata outputs:"
89+
echo "version: ${{ steps.docker_meta.outputs.version }}"
90+
echo "tags: ${{ steps.docker_meta.outputs.tags }}"
91+
echo "labels: ${{ steps.docker_meta.outputs.labels }}"
92+
echo "json: ${{ steps.docker_meta.outputs.json }}"
7493
7594
# Setup docker build environment
7695
- name: Set up QEMU
77-
uses: docker/setup-qemu-action@v1
96+
uses: docker/setup-qemu-action@v3
7897
- name: Set up Docker Buildx
79-
uses: docker/setup-buildx-action@v1
98+
uses: docker/setup-buildx-action@v3
8099

81100
- name: Set build parameters
82101
id: build_params
83102
run: |
84-
echo "::set-output name=sha8::${GITHUB_SHA::8}"
85-
if [ "${{ github.event_name }}" != "pull_request" ] && [ "${{ github.ref }}" == "refs/heads/master" ]; then
86-
echo "::set-output name=push::true"
87-
echo "::set-output name=load::false"
88-
echo "::set-output name=platforms::linux/amd64,linux/arm64"
103+
echo "sha8=${GITHUB_SHA::8}" >> $GITHUB_OUTPUT
104+
if [ "${{ github.event_name }}" != "pull_request" ] && ( [ "${{ github.ref }}" == "refs/heads/master" ] || [ "${{ github.ref }}" == "refs/heads/webapi-3.0" ] ); then
105+
echo "push=true" >> $GITHUB_OUTPUT
106+
echo "load=false" >> $GITHUB_OUTPUT
107+
echo "platforms=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT
89108
else
90-
echo "::set-output name=push::false"
91-
echo "::set-output name=load::true"
92-
echo "::set-output name=platforms::linux/amd64"
109+
echo "push=false" >> $GITHUB_OUTPUT
110+
echo "load=true" >> $GITHUB_OUTPUT
111+
echo "platforms=linux/amd64" >> $GITHUB_OUTPUT
93112
fi
94113
95-
- name: Login to DockerHub
96-
uses: docker/login-action@v1
114+
- name: Login to GitHub Container Registry
115+
uses: docker/login-action@v3
97116
if: steps.build_params.outputs.push == 'true'
98117
with:
99-
username: ${{ secrets.DOCKER_HUB_USERNAME }}
100-
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
118+
registry: ghcr.io
119+
username: ${{ github.actor }}
120+
password: ${{ secrets.GITHUB_TOKEN }}
101121

102122
- name: Build and push
103123
id: docker_build
104-
uses: docker/build-push-action@v2
124+
uses: docker/build-push-action@v5
105125
with:
106126
context: ./
107127
file: ./Dockerfile
@@ -113,6 +133,7 @@ jobs:
113133
build-args: |
114134
GIT_BRANCH=${{ steps.docker_meta.outputs.version }}
115135
GIT_COMMIT_ID_ABBREV=${{ steps.build_params.outputs.sha8 }}
136+
MAVEN_PROFILE=webapi-docker,tcache
116137
tags: ${{ steps.docker_meta.outputs.tags }}
117138
# Use runtime labels from docker_meta as well as fixed labels
118139
labels: |

Dockerfile

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
FROM maven:3.9-eclipse-temurin-21 as builder
1+
FROM maven:3.9-eclipse-temurin-21 AS builder
22

33
WORKDIR /code
44

5-
ARG MAVEN_PROFILE=webapi-docker
5+
ARG MAVEN_PROFILE=webapi-docker,tcache
66
ARG MAVEN_PARAMS="" # can use maven options, e.g. -DskipTests=true -DskipUnitTests=true
77

88
ARG OPENTELEMETRY_JAVA_AGENT_VERSION=1.17.0
@@ -29,7 +29,7 @@ RUN mvn package ${MAVEN_PARAMS} \
2929
# OHDSI WebAPI running as a Spring Boot executable JAR with Java 21
3030
FROM index.docker.io/library/eclipse-temurin:21-jre
3131

32-
MAINTAINER Lee Evans - www.ltscomputingllc.com
32+
LABEL maintainer="Lee Evans - www.ltscomputingllc.com"
3333

3434
# Any Java options to pass along, e.g. memory, garbage collection, etc.
3535
ENV JAVA_OPTS=""
@@ -41,14 +41,20 @@ ENV DEFAULT_JAVA_OPTS="-Djava.security.egd=file:///dev/./urandom"
4141
# set working directory to a fixed WebAPI directory
4242
WORKDIR /var/lib/ohdsi/webapi
4343

44+
RUN apt-get update && apt-get install -y unzip && rm -rf /var/lib/apt/lists/*
45+
4446
COPY --from=builder /code/opentelemetry-javaagent.jar .
4547
COPY --from=builder /code/target/WebAPI.jar .
4648

49+
RUN mkdir -p /tmp/trexsql && \
50+
unzip -j WebAPI.jar 'BOOT-INF/lib/trexsql-ext-*.jar' -d /tmp && \
51+
unzip -j /tmp/trexsql-ext-*.jar 'libtrexsql_java.so_linux_amd64' -d /tmp/trexsql 2>/dev/null || true && \
52+
mv /tmp/trexsql/libtrexsql_java.so_linux_amd64 /tmp/trexsql/libtrexsql_java.so 2>/dev/null || true && \
53+
rm -f /tmp/trexsql-ext-*.jar
54+
4755
EXPOSE 8080
4856

4957
USER 101
5058

51-
# Run the executable JAR
52-
CMD exec java ${DEFAULT_JAVA_OPTS} ${JAVA_OPTS} \
53-
--add-opens java.naming/com.sun.jndi.ldap=ALL-UNNAMED \
54-
-jar WebAPI.jar
59+
# Run the executable JAR with TrexSQL native library path
60+
CMD ["sh", "-c", "exec java ${DEFAULT_JAVA_OPTS} ${JAVA_OPTS} -Dorg.duckdb.lib_path=/tmp/trexsql/libtrexsql_java.so --add-opens java.naming/com.sun.jndi.ldap=ALL-UNNAMED -jar WebAPI.jar"]

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,26 @@ mvn clean package -DskipTests -Dpackaging.type=jar
3636
java -jar target/WebAPI.jar --spring.profiles.active=webapi-postgresql
3737
```
3838

39+
## Database configuration (single source of truth)
40+
41+
Set your datasource and schema once; the packaged properties reuse the shared schema key.
42+
43+
Minimal local run example (PostgreSQL):
44+
45+
```bash
46+
export WEBAPI_SCHEMA=webapi # optional; defaults to webapi
47+
export SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/postgres
48+
export SPRING_DATASOURCE_USERNAME=postgres
49+
export SPRING_DATASOURCE_PASSWORD=your_password
50+
51+
java -jar target/WebAPI.jar \
52+
--spring.profiles.active=webapi-postgresql \
53+
--datasource.ohdsi.schema=${WEBAPI_SCHEMA:-webapi}
54+
```
55+
56+
Notes:
57+
- Batch uses a table prefix and the security datasource can be overridden if you choose a separate connection, but both are optional when you keep everything on the main datasource/schema.
58+
3959
## SAML Auth support
4060

4161
The following parameters are used:

0 commit comments

Comments
 (0)