Skip to content

Commit

Permalink
use 2-step build
Browse files Browse the repository at this point in the history
  • Loading branch information
Altonhe committed Mar 6, 2024
1 parent 8a289a1 commit 8f32e61
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
24 changes: 14 additions & 10 deletions oba/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
FROM alpine:latest as builder
# Append Test API Key dynamically
ARG TEST_API_KEY
ENV TEST_API_KEY=${TEST_API_KEY}

WORKDIR /oba
COPY bootstrap.sh .
COPY ./config ./config
RUN chmod +x bootstrap.sh
RUN apk update && apk add --no-cache bash && apk add --no-cache xmlstarlet
RUN ./bootstrap.sh


FROM tomcat:8.5.98-jdk11-temurin

ENV CATALINA_HOME /usr/local/tomcat
Expand Down Expand Up @@ -45,16 +58,7 @@ WORKDIR /oba/webapps/onebusaway-api-webapp
RUN cp /oba/libs/onebusaway-api-webapp-${OBA_VERSION}.war .
RUN jar xvf onebusaway-api-webapp-${OBA_VERSION}.war
RUN rm onebusaway-api-webapp-${OBA_VERSION}.war
COPY ./config/onebusaway-api-webapp-data-sources.xml ./WEB-INF/classes/data-sources.xml
# Append Test API Key dynamically
ARG TEST_API_KEY
ENV TEST_API_KEY=${TEST_API_KEY}
COPY bootstrap.sh .
USER root
RUN chmod +x bootstrap.sh
RUN apt-get update -y && apt-get install -y xmlstarlet && apt-get clean
RUN ./bootstrap.sh
USER $USER
COPY --from=builder /oba/config/onebusaway-api-webapp-data-sources.xml ./WEB-INF/classes/data-sources.xml
RUN cp $CATALINA_HOME/lib/mysql-connector-j-8.3.0.jar ./WEB-INF/lib
RUN mv /oba/webapps/onebusaway-api-webapp $CATALINA_HOME/webapps

Expand Down
4 changes: 2 additions & 2 deletions oba/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

XML_FILE="./WEB-INF/classes/data-sources.xml"
XML_FILE="./config/onebusaway-api-webapp-data-sources.xml"
NAMESPACE_PREFIX="x"
NAMESPACE_URI="http://www.springframework.org/schema/beans"
BEAN_ID="testAPIKey"
Expand All @@ -20,4 +20,4 @@ else
xmlstarlet ed -L -N ${NAMESPACE_PREFIX}=${NAMESPACE_URI} \
-d "//${NAMESPACE_PREFIX}:bean[@id='${BEAN_ID}']" \
${XML_FILE}
fi
fi

0 comments on commit 8f32e61

Please sign in to comment.