Skip to content

Commit

Permalink
update to multi-stage build
Browse files Browse the repository at this point in the history
  • Loading branch information
jaroldwong committed Jan 24, 2024
1 parent 230dee4 commit 6a729a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 44 deletions.
51 changes: 10 additions & 41 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,52 +1,21 @@
FROM openjdk:8@sha256:75739abc3852736798b0f0f897c98d8f587368e8e6cf9a2580289e3390b6432b
FROM gradle:6.9-jdk8 AS builder
USER root
WORKDIR /usr/src
COPY . .
RUN gradle build --no-daemon -x check -x test

FROM openjdk:8-jdk-alpine
RUN apk --no-cache add openssl

EXPOSE 8080

LABEL maintainer="UC Davis DSS IT http://it.dss.ucdavis.edu"

WORKDIR /usr/src/app

ARG IPA_DATASOURCE_URL
ENV IPA_DATASOURCE_URL $IPA_DATASOURCE_URL
ARG IPA_DATASOURCE_USERNAME
ENV IPA_DATASOURCE_USERNAME $IPA_DATASOURCE_USERNAME
ARG IPA_DATASOURCE_PASSWORD
ENV IPA_DATASOURCE_PASSWORD $IPA_DATASOURCE_PASSWORD
ARG IPA_SPRING_PROFILE="development"
ENV IPA_SPRING_PROFILE $IPA_SPRING_PROFILE
ARG IPA_JWT_SIGNING_KEY
ENV IPA_JWT_SIGNING_KEY $IPA_JWT_SIGNING_KEY
ARG IPA_JWT_TIMEOUT
ENV IPA_JWT_TIMEOUT $IPA_JWT_TIMEOUT
ARG IPA_URL_API
ENV IPA_URL_API $IPA_URL_API
ARG DW_URL
ENV DW_URL $DW_URL
ARG DW_TOKEN
ENV DW_TOKEN $DW_TOKEN
ARG DW_PORT
ENV DW_PORT $DW_PORT
ARG SMTP_HOST
ENV SMTP_HOST $SMTP_HOST
ARG SMTP_EMAIL_FROM
ENV SMTP_EMAIL_FROM $SMTP_EMAIL_FROM
ARG IPA_URL_FRONTEND
ENV IPA_URL_FRONTEND $IPA_URL_FRONTEND
ARG CAS_URL
ENV CAS_URL $CAS_URL

COPY import-rds-certs.sh .
RUN ./import-rds-certs.sh

COPY ./gradle gradle
COPY ./gradlew gradlew
COPY ./build.gradle build.gradle
COPY ./checkstyle.xml checkstyle.xml

# RUN ./gradlew resolveDependencies

COPY ./src src

RUN ./gradlew build -x test
COPY --from=builder /usr/src/build/libs/ipa-api-0.1.0.jar ipa-api-0.1.0.jar

CMD java -Djava.security.egd=file:/dev/./urandom -jar build/libs/ipa-api-0.1.0.jar
CMD java -Djava.security.egd=file:/dev/./urandom -jar ./ipa-api-0.1.0.jar
6 changes: 3 additions & 3 deletions import-rds-certs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ then
mkdir -p "${mydir}"
fi

curl -sS "https://truststore.pki.rds.amazonaws.com/us-west-2/us-west-2-bundle.pem" > ${mydir}/us-west-2-bundle.pem
wget -O ${mydir}/us-west-2-bundle.pem "https://truststore.pki.rds.amazonaws.com/us-west-2/us-west-2-bundle.pem"
awk 'split_after == 1 {n++;split_after=0} /-----END CERTIFICATE-----/ {split_after=1}{print > "rds-ca-" n ".pem"}' < ${mydir}/us-west-2-bundle.pem

for CERT in rds-ca-*; do
alias=$(openssl x509 -noout -text -in $CERT | perl -ne 'next unless /Subject:/; s/.*(CN=|CN = )//; print')
alias=$(openssl x509 -noout -text -in $CERT | awk '/Subject:/ {sub(/.*CN *= */, ""); print; exit}')
echo "Importing $alias"
keytool -import -file ${CERT} -alias "${alias}" -storepass changeit -keystore "$JAVA_HOME/jre/lib/security/cacerts" -noprompt
rm $CERT
done

rm ${mydir}/us-west-2-bundle.pem
rm ${mydir}/us-west-2-bundle.pem

0 comments on commit 6a729a6

Please sign in to comment.