-
Notifications
You must be signed in to change notification settings - Fork 0
celements-webapp docker build #543
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
Open
msladek
wants to merge
7
commits into
dev
Choose a base branch
from
docker-build
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f1a71a8
celements-webapp docker build
msladek 3d6e881
PR fixes
msladek cfc85bb
standardise docker config names
msladek dfc953d
deploy exploded war
msladek d235d94
mvnrepo cache mount
msladek dbf4acd
.env.local
msladek 2f5ec2e
harmonise config
msladek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| .env.local |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| @Library('synventis') _ | ||
|
|
||
| dockerImagePipeline( | ||
| org: 'celements', | ||
| image: 'celements-webapp', | ||
| appDir: 'celements-webapp', | ||
| mode: 'mvn' | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # Celements Webapp | ||
|
|
||
| `celements-webapp` is the WAR application deployed into Tomcat. | ||
|
|
||
| ## Local Development | ||
|
|
||
| Create the local runtime configuration: | ||
|
|
||
| ```sh | ||
| cp .env.sample .env.local && vim .env.local | ||
| ``` | ||
|
|
||
| Build the exploded WAR for the local mounted-webapp setup: | ||
|
|
||
| ```sh | ||
| mvn clean install -P local | ||
| ``` | ||
|
|
||
| Start the sqlserver first, then the rest: | ||
|
|
||
| ```sh | ||
| docker compose up -d sqlserver | ||
| docker compose up -d | ||
| ``` | ||
|
|
||
| Open `http://localhost:2080`. | ||
|
|
||
| For remote development, forward the Tomcat port: | ||
|
|
||
| ```sh | ||
| ssh -N -L 2080:localhost:2080 myremotehost | ||
| ``` | ||
|
|
||
| ## Local Image Builds | ||
|
|
||
| Local image builds use `compose.build.yml`. The build requires an untracked `mvn-settings.xml` in | ||
| this directory with access to private Maven artifacts. | ||
|
|
||
| ```sh | ||
| docker compose -f compose.build.yml build | ||
| ``` | ||
|
|
||
| This builds the same image shape as Jenkins: Maven build stage, Tomcat runtime stage, and | ||
| the exploded `target/celements-web/` webapp copied into `webapps/ROOT/`. | ||
|
|
||
| ## Image builds | ||
|
|
||
| The image is published by `Jenkinsfile`. | ||
|
|
||
| The pipeline extracts the Maven project version from `pom.xml` and publishes: | ||
|
|
||
| - `ghcr.io/celements/celements-webapp:<version>` | ||
| - `ghcr.io/celements/celements-webapp:<version>-<git-sha>` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| services: | ||
| webserver: | ||
| image: celements-webapp | ||
| build: | ||
| context: . | ||
| dockerfile: docker/Dockerfile | ||
| args: | ||
| MVN_CACHE_KEY: "${MVN_CACHE_KEY:-none}" | ||
| secrets: | ||
| - mvnsettings | ||
|
|
||
| secrets: | ||
| mvnsettings: | ||
| file: ./mvn-settings.xml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # syntax=docker/dockerfile:1 | ||
|
|
||
| FROM maven:3-eclipse-temurin-21 AS build | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| ARG MVN_CACHE_KEY=none | ||
|
|
||
| COPY . . | ||
| RUN --mount=type=secret,id=mvnsettings,required=true,target=/root/.m2/settings.xml \ | ||
| --mount=type=cache,id=mvnrepo,target=/root/.m2/repository,sharing=locked \ | ||
| echo "MVN_CACHE_KEY: ${MVN_CACHE_KEY}" && \ | ||
| mvn -B -U \ | ||
| -s /root/.m2/settings.xml \ | ||
| -Dmaven.repo.local=/root/.m2/repository \ | ||
| clean prepare-package war:exploded | ||
|
|
||
| FROM tomcat:10-jdk21-temurin AS execute | ||
|
|
||
| ARG VERSION | ||
| ARG REVISION | ||
|
|
||
| LABEL org.opencontainers.image.source="https://github.com/celements/celements-web" \ | ||
| org.opencontainers.image.description="Celements web application" \ | ||
| org.opencontainers.image.version="${VERSION}" \ | ||
| org.opencontainers.image.revision="${REVISION}" | ||
|
|
||
| ENV APP_DATA=/usr/local/celements \ | ||
| CONF_DIR=/usr/local/conf | ||
|
|
||
| COPY docker/tomcat/entrypoint.sh /usr/local/bin/start | ||
| COPY docker/tomcat/conf "${CONF_DIR}" | ||
|
|
||
| RUN apt-get update \ | ||
| && apt-get --no-install-recommends -y install \ | ||
| gettext-base \ | ||
| && rm -rf /var/lib/apt/lists/* "${CATALINA_HOME}/webapps/"* \ | ||
| && mkdir -p \ | ||
| "${APP_DATA}" \ | ||
| "${CATALINA_HOME}/temp" \ | ||
| "${CATALINA_HOME}/conf/Catalina/localhost" \ | ||
| && cp "${CONF_DIR}/setenv.sh" "${CATALINA_HOME}/bin/" \ | ||
| && cp "${CONF_DIR}/jakarta.converter.xml" "${CATALINA_HOME}/conf/Catalina/localhost/ROOT.xml" \ | ||
| && chmod +x /usr/local/bin/start | ||
|
|
||
| COPY --from=build /app/target/celements-web/ "${CATALINA_HOME}/webapps/ROOT/" | ||
|
|
||
| EXPOSE 8080 9090 | ||
|
|
||
| ENTRYPOINT ["start"] | ||
| CMD ["catalina.sh", "run"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| .env | ||
| *.local | ||
| .git | ||
| .gitignore | ||
| .settings | ||
| .vscode | ||
| compose.local.yml | ||
| compose.build.yml | ||
| docker/sqlserver | ||
| docker/Dockerfile.local | ||
| node_modules | ||
| target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Dockerfile.dockerignore |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <Server port="8005" shutdown="SHUTDOWN"> | ||
| <Listener className="org.apache.catalina.startup.VersionLoggerListener" /> | ||
| <Listener className="org.apache.catalina.core.AprLifecycleListener" /> | ||
| <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /> | ||
| <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> | ||
| <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" /> | ||
|
|
||
| <GlobalNamingResources> | ||
| <Resource name="UserDatabase" auth="Container" | ||
| type="org.apache.catalina.UserDatabase" | ||
| description="User database that can be updated and saved" | ||
| factory="org.apache.catalina.users.MemoryUserDatabaseFactory" | ||
| pathname="conf/tomcat-users.xml" /> | ||
| </GlobalNamingResources> | ||
|
|
||
| <Service name="Catalina"> | ||
| <Connector port="8080" | ||
| protocol="HTTP/1.1" | ||
| enableLookups="false" | ||
| connectionTimeout="20000" | ||
| compression="on" | ||
| URIEncoding="UTF-8" /> | ||
| <Connector port="9090" | ||
| protocol="HTTP/1.1" | ||
| enableLookups="false" | ||
| connectionTimeout="4000" | ||
| keepAliveTimeout="1000" | ||
| maxThreads="5" | ||
| minSpareThreads="1" | ||
| maxConnections="10" | ||
| acceptCount="5" | ||
| compression="off" | ||
| URIEncoding="UTF-8" /> | ||
|
|
||
| <Engine name="Catalina" defaultHost="localhost" jvmRoute="${NODE_NAME}"> | ||
| <Realm className="org.apache.catalina.realm.LockOutRealm"> | ||
| <Realm className="org.apache.catalina.realm.UserDatabaseRealm" | ||
| resourceName="UserDatabase"/> | ||
| </Realm> | ||
|
|
||
| <Host name="localhost" appBase="webapps" | ||
| unpackWARs="false" autoDeploy="true"> | ||
| <Valve className="org.apache.catalina.valves.RemoteIpValve" | ||
| internalProxies=".*"/> | ||
| <Valve className="org.apache.catalina.valves.HealthCheckValve"/> | ||
| <Valve className="org.apache.catalina.valves.AccessLogValve" | ||
| directory="logs" | ||
| prefix="access_log." | ||
| suffix=".txt" | ||
| pattern='%v: %h %l %u %t "%r" %s %b "%{Referer}i" "%{User-agent}i"'/> | ||
| </Host> | ||
| </Engine> | ||
| </Service> | ||
| </Server> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| #!/bin/bash | ||
|
|
||
| # CATALINA_XMX=1200m | ||
| ## TODO Cgroup-aware memory detection for container environments | ||
| if [ -z "$CATALINA_XMX" ]; then | ||
| total_memory_kb=$(grep -i 'memtotal' /proc/meminfo | grep -o '[[:digit:]]*') | ||
| xmx_kb=$((total_memory_kb * 80 / 100)) # use 80% of memory | ||
| xmx_kb_max=$((total_memory_kb - 716800)) # make sure at least 700m left | ||
| [ $xmx_kb -gt $xmx_kb_max ] && xmx_kb=$xmx_kb_max | ||
|
msladek marked this conversation as resolved.
|
||
| xmx_kb_min=$((1024 * 1024)) # minimum 1GB heap | ||
| [ $xmx_kb -lt $xmx_kb_min ] && echo "ERROR: at least 1GB heap required" >&2 && exit 1 | ||
| CATALINA_XMX="$((xmx_kb / 1024))m" | ||
| fi | ||
|
|
||
| CATALINA_OPTS="${CATALINA_OPTS}\ | ||
| -server\ | ||
| -Xms${CATALINA_XMS:-${CATALINA_XMX}}\ | ||
| -Xmx${CATALINA_XMX}\ | ||
| -Xss1m\ | ||
| -XX:+UseShenandoahGC\ | ||
| -XX:+UseStringDeduplication\ | ||
| -Djava.awt.headless=true\ | ||
| -Dorg.apache.activeio.journal.active.DisableLocking=true\ | ||
| -Dfile.encoding=UTF-8\ | ||
| -Djava.net.preferIPv4Stack=true\ | ||
| " | ||
|
|
||
| if [ -n "$GC_LOG_VERBOSE" ]; then | ||
| CATALINA_OPTS="${CATALINA_OPTS}\ | ||
| -Xlog:gc*,safepoint:file=${CATALINA_HOME}/logs/gc.log:time,uptime,level,tags:filecount=5,filesize=10M\ | ||
| -Xlog:class+unload=trace\ | ||
| -Xlog:stringdedup*=debug\ | ||
| " | ||
| fi | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| : "${CATALINA_HOME:?CATALINA_HOME not set}" | ||
| : "${CONF_DIR:?CONF_DIR not set}" | ||
| : "${NODE_NAME:?NODE_NAME not set}" | ||
|
|
||
| echo "**entrypoint** applying server.xml" | ||
| envsubst \ | ||
| < "${CONF_DIR}/server.template.xml" \ | ||
| > "${CATALINA_HOME}/conf/server.xml" | ||
|
|
||
| echo "**entrypoint** executing: $*" | ||
| exec "$@" |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.