Skip to content

Commit

Permalink
Merge pull request #8 from eeditiones/refactor
Browse files Browse the repository at this point in the history
Fix and simplify setup
  • Loading branch information
wolfgangmm authored Nov 2, 2023
2 parents c62bd79 + 9ee9dcd commit 2c8fe04
Show file tree
Hide file tree
Showing 11 changed files with 311 additions and 342 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
certbot
certbot
nginx/conf/default.*
nginx/conf/localhost.*
104 changes: 58 additions & 46 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,23 @@ FROM openjdk:8-jdk-slim as builder

USER root

ENV ANT_VERSION 1.10.12
ENV NODE_MAJOR 20
ENV ANT_VERSION 1.10.13
ENV ANT_HOME /etc/ant-${ANT_VERSION}

WORKDIR /tmp

RUN apt-get update && apt-get install -y \
git \
curl
curl \
ca-certificates \
gnupg

RUN mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_MAJOR}.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
apt-get update && \
apt-get install nodejs -y

RUN curl -L -o apache-ant-${ANT_VERSION}-bin.tar.gz http://www.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz \
&& mkdir ant-${ANT_VERSION} \
Expand All @@ -23,77 +32,80 @@ RUN curl -L -o apache-ant-${ANT_VERSION}-bin.tar.gz http://www.apache.org/dist/a

ENV PATH ${PATH}:${ANT_HOME}/bin

# Comment in if you need nodejs and npm to build, e.g. if you want to
# self-host the web components
# RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - \
# && apt-get install -y nodejs \
# && curl -L https://www.npmjs.com/install.sh | sh

FROM builder as tei

ARG TEMPLATING_VERSION=1.1.0
ARG PUBLISHER_LIB_VERSION=3.0.0
ARG PUBLISHER_LIB_VERSION=4.0.0
ARG ROUTER_VERSION=1.8.0
# replace with name of your edition repository and choose branch to build
ARG MY_EDITION_VERSION=master
ARG APP_NAME=tei-publisher-app
ARG APP_REPO=https://github.com/eeditiones/tei-publisher-app.git
ARG APP_TAG_OR_BRANCH=master

# add key
RUN mkdir -p ~/.ssh && ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts

# Replace git URL below to point to your git repository
RUN git clone https://github.com/eeditiones/tei-publisher-app.git \
# Build tei-publisher-lib if version=master
RUN if [ "${PUBLISHER_LIB_VERSION}" = "master" ]; then \
git clone https://github.com/eeditiones/tei-publisher-lib.git \
&& cd tei-publisher-lib \
&& ant \
&& cp build/*.xar /tmp; \
else \
curl -L -o /tmp/tei-publisher-lib-${PUBLISHER_LIB_VERSION}.xar https://exist-db.org/exist/apps/public-repo/public/tei-publisher-lib-${PUBLISHER_LIB_VERSION}.xar; \
fi

# Build the main app configured in the docker-compose.yml
RUN git clone ${APP_REPO} \
# replace my-edition with name of your app
&& cd tei-publisher-app \
&& echo Checking out ${MY_EDITION_VERSION} \
&& git checkout ${MY_EDITION_VERSION} \
&& cd ${APP_NAME} \
&& echo Checking out ${APP_TAG_OR_BRANCH} \
&& git checkout ${APP_TAG_OR_BRANCH} \
&& ant

RUN curl -L -o /tmp/roaster-${ROUTER_VERSION}.xar http://exist-db.org/exist/apps/public-repo/public/roaster-${ROUTER_VERSION}.xar
RUN curl -L -o /tmp/tei-publisher-lib-${PUBLISHER_LIB_VERSION}.xar http://exist-db.org/exist/apps/public-repo/public/tei-publisher-lib-${PUBLISHER_LIB_VERSION}.xar
RUN curl -L -o /tmp/templating-${TEMPLATING_VERSION}.xar http://exist-db.org/exist/apps/public-repo/public/templating-${TEMPLATING_VERSION}.xar

FROM eclipse-temurin:11-jre-alpine
FROM duncdrum/existdb:6.2.0-debug-j8

ARG APP_NAME=tei-publisher-app
ARG EXIST_VERSION=6.2.0

RUN apk add curl

RUN curl -L -o /tmp/exist-distribution-${EXIST_VERSION}-unix.tar.bz2 https://github.com/eXist-db/exist/releases/download/eXist-${EXIST_VERSION}/exist-distribution-${EXIST_VERSION}-unix.tar.bz2 \
&& tar xfj /tmp/exist-distribution-${EXIST_VERSION}-unix.tar.bz2 -C /tmp \
&& rm /tmp/exist-distribution-${EXIST_VERSION}-unix.tar.bz2 \
&& mv /tmp/exist-distribution-${EXIST_VERSION} /exist

# replace my-edition with name of your app
COPY --from=tei /tmp/tei-publisher-app/build/*.xar /exist/autodeploy/
COPY --from=tei /tmp/${APP_NAME}/build/*.xar /exist/autodeploy/
COPY --from=tei /tmp/*.xar /exist/autodeploy/

WORKDIR /exist

ARG ADMIN_PASS=none

ARG HTTP_PORT=8080
ARG HTTPS_PORT=8443

ENV NER_ENDPOINT=http://localhost:8001
ENV CONTEXT_PATH=auto
ENV PROXY_CACHING=false

ENV JAVA_OPTS \
-Djetty.port=${HTTP_PORT} \
-Djetty.ssl.port=${HTTPS_PORT} \
-Dfile.encoding=UTF8 \
-Dsun.jnu.encoding=UTF-8 \
-XX:+UseG1GC \
-XX:+UseStringDeduplication \
-XX:+UseContainerSupport \
-XX:MaxRAMPercentage=${JVM_MAX_RAM_PERCENTAGE:-75.0} \
-XX:+ExitOnOutOfMemoryError
ARG CONTEXT_PATH=auto
ARG NER_ENDPOINT=http://localhost:8001
ARG PROXY_CACHING=false

ENV JAVA_TOOL_OPTIONS \
-Dfile.encoding=UTF8 \
-Dsun.jnu.encoding=UTF-8 \
-Djava.awt.headless=true \
-Dorg.exist.db-connection.cacheSize=${CACHE_MEM:-256}M \
-Dorg.exist.db-connection.pool.max=${MAX_BROKER:-20} \
-Dlog4j.configurationFile=/exist/etc/log4j2.xml \
-Dexist.home=/exist \
-Dexist.configurationFile=/exist/etc/conf.xml \
-Djetty.home=/exist \
-Dexist.jetty.config=/exist/etc/jetty/standard.enabled-jetty-configs \
-Dteipublisher.ner-endpoint=${NER_ENDPOINT} \
-Dteipublisher.context-path=${CONTEXT_PATH} \
-Dteipublisher.proxy-caching=${PROXY_CACHING} \
-XX:+UseG1GC \
-XX:+UseStringDeduplication \
-XX:+UseContainerSupport \
-XX:MaxRAMPercentage=${JVM_MAX_RAM_PERCENTAGE:-75.0} \
-XX:+ExitOnOutOfMemoryError

# pre-populate the database by launching it once
RUN bin/client.sh -l --no-gui --xpath "system:get-version()"

RUN if [ "${ADMIN_PASS}" != "none" ]; then bin/client.sh -l --no-gui --xpath "sm:passwd('admin', '${ADMIN_PASS}')"; fi

EXPOSE ${HTTP_PORT}
RUN [ "java", "org.exist.start.Main", "client", "--no-gui", "-l" ]

ENTRYPOINT JAVA_OPTS="${JAVA_OPTS} -Dteipublisher.ner-endpoint=${NER_ENDPOINT} -Dteipublisher.context-path=${CONTEXT_PATH}" /exist/bin/startup.sh
EXPOSE ${HTTP_PORT} ${HTTPS_PORT}
99 changes: 0 additions & 99 deletions Dockerfile.tmpl

This file was deleted.

Loading

0 comments on commit 2c8fe04

Please sign in to comment.