Skip to content

Commit a87ae28

Browse files
authored
CLDR-14145 fix bidic (#24)
* CLDR-14145 fix bidic - build bidic (bidiref1) (separate alpine build) - add a $BIDIREF1 env variable which gives the path to bidiref1 - does not set data path properly * CLDR-14145 fix bidic data - copy ucd data - add a BIDIREFHOME directory to the JSP for changing the working directory of bidiref1 before it is called Should have no impact outside of Docker. Jetty doesn't explode the *.war file the same way that Tomcat does, so the raw ucd files weren't quite as accessible without explicitly copying them.
1 parent a13c653 commit a87ae28

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

UnicodeJsps/Dockerfile

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
# Copyright (c) 2020 and later Unicode, Inc. and others. All Rights Reserved.
2-
# Use -eJDKVERSION=13 -eTOMCATVERSION=8 for example to change these
3-
ARG JDKVERSION=16
4-
FROM openjdk:${JDKVERSION}-alpine AS build
2+
FROM alpine as cbuild
3+
ARG CVERSION=13.0.0
4+
ARG CPATH=https://www.unicode.org/Public/PROGRAMS/BidiReferenceC/
5+
WORKDIR /build
6+
RUN apk add --update -q wget make gcc musl-dev
7+
RUN wget -np -nv --reject-regex='.*\.(lib|exe)$' --cut-dirs=4 -nH -r ${CPATH}${CVERSION}/
8+
RUN cd source && gcc -I ../include/ -static -Os -o3 -o bidiref1 bidiref1.c brutils.c brtest.c brtable.c brrule.c
9+
RUN ls -lh /build/source/bidiref1 && (/build/source/bidiref1 || true)
10+
FROM openjdk:16-alpine AS build
511
# Need ant, add it. Yes, this pulls in JDK8, but it's an easier
612
# way to manage this.
713
RUN apk add --update apache-ant
@@ -21,6 +27,14 @@ FROM jetty:9-jre11-slim AS run
2127
ADD port-entrypoint.sh /port-entrypoint.sh
2228
ADD ./jetty.d/ROOT /var/lib/jetty/webapps/ROOT/
2329
ENTRYPOINT [ "/port-entrypoint.sh" ]
30+
# copy the .war
2431
COPY --from=build /home/UnicodeJsps.war /var/lib/jetty/webapps/
32+
# copy the UCD for bidiref1
33+
COPY --from=build /home/src/org/unicode/jsp/bidiref1/ucd/ /usr/local/share/ucd/
34+
# this is the parent to 'ucd'
35+
ENV BIDIREFHOME /usr/local/share
36+
# copy the bidiref1 bin
37+
ENV BIDIREF1 /usr/local/bin/bidiref1
38+
COPY --from=cbuild /build/source/bidiref1 /usr/local/bin/
2539
# This is the default PORT. Override by setting PORT.
2640
EXPOSE 8080

UnicodeJsps/WebContent/bidic.jsp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,20 @@ function setUbaInput(str) {
107107

108108
<body>
109109
<%
110+
String BINPATH = java.lang.System.getenv("BIDIREF1");
111+
if(BINPATH == null || BINPATH.isEmpty()) {
112+
BINPATH = "bidiref/bidiref1";
113+
}
114+
java.io.File f = new java.io.File(BINPATH);
115+
if(!f.canRead()) {
116+
throw new RuntimeException("bidic binary not found (check $BIDIREF1}): " + BINPATH);
117+
}
118+
String BRHOME = java.lang.System.getenv("BIDIREFHOME");
119+
java.io.File brHome = new java.io.File(".");
120+
if(BRHOME != null && !BRHOME.isEmpty()) {
121+
brHome = new java.io.File(BRHOME);
122+
}
123+
110124
request.setCharacterEncoding("UTF-8");
111125
String queryStr = request.getQueryString();
112126
UtfParameters utfParams = new UtfParameters(queryStr);
@@ -156,8 +170,9 @@ function setUbaInput(str) {
156170
157171
////Process process = new ProcessBuilder("C:\\Windows\\System32\\cmd.exe", "/C", "cd").start();
158172
Process process = new ProcessBuilder(
159-
"bidiref/bidiref1",
173+
BINPATH,
160174
"-b" + ubaPara, "-u" + ubaVersion, "-d" + ubaDetail, "-y" + (ubaShowVacuous ? "0" : "1"), "-s" + valInputCpSeq)
175+
.directory(brHome)
161176
.start();
162177
java.io.InputStream is = process.getInputStream();
163178
java.io.InputStreamReader isr = new java.io.InputStreamReader(is);

0 commit comments

Comments
 (0)