Skip to content

Commit

Permalink
build: modify docker configuration for oracle-api (#108)
Browse files Browse the repository at this point in the history
* build: modify docker configuration for oracle-api

* Reintroduced oracle-api optionally in Compose

* Host networking

---------

Co-authored-by: Derek Roberts <derek.roberts@gmail.com>
  • Loading branch information
annibalsilva and DerekRoberts committed May 14, 2024
1 parent 8a5e8fe commit 82a1df1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
24 changes: 24 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,30 @@ services:
build:
context: ./backend

oracle-api:
container_name: oracle-api
environment:
NR_SPAR_ORACLE_API_VERSION: "dev"
SERVER_PORT: "8091"
DATABASE_HOST: nrcdb03.bcgov
DATABASE_PORT: "1543"
SERVICE_NAME: dbq01.nrs.bcgov
DATABASE_USER: proxy_fsa_spar_read_only_user
DATABASE_PASSWORD: "${DATABASE_PASSWORD}"
KEYCLOAK_REALM_URL: "https://test.loginproxy.gov.bc.ca/auth/realms/standard"
healthcheck:
test: [ "CMD", "java", "HealthCheck" ]
interval: 5s
timeout: 5s
retries: 5
start_period: 45s
ports:
- "8091:8091"
build:
context: ./oracle-api
profiles: ["oracle-api"]
network_mode: "host"

frontend:
container_name: frontend
depends_on:
Expand Down
11 changes: 8 additions & 3 deletions oracle-api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ FROM openjdk:17.0.2 AS build
WORKDIR /app
COPY . ./
RUN ./mvnw --no-transfer-progress --update-snapshots clean package -Dtests.skip=true -Dskip.unit.tests=true
RUN javac HealthCheck.java InstallCert.java

# Deploy container
FROM eclipse-temurin:17.0.7_7-jdk-jammy AS deploy
Expand All @@ -14,8 +15,12 @@ ENV LC_ALL en_CA.UTF-8

# Setup package/archive and supporting files
WORKDIR /usr/share/service/
COPY --from=build /app/target/*.jar ./artifacts/
COPY dockerfile-entrypoint.sh HealthCheck.java InstallCert.java ./
COPY --from=build /app/target/*.jar \
/app/HealthCheck.class \
/app/InstallCert.class \
/app/InstallCert\$SavingTrustManager.class \
./artifacts/
COPY dockerfile-entrypoint.sh ./
RUN mkdir config dump public && \
chmod -R g+w . && \
chmod g+x dockerfile-entrypoint.sh && \
Expand All @@ -24,5 +29,5 @@ RUN mkdir config dump public && \
# Port, user and entrypoint
EXPOSE 8090
USER 1001
HEALTHCHECK --interval=35s --timeout=4s CMD java HealthCheck
HEALTHCHECK --interval=35s --timeout=4s CMD java -cp /usr/share/service/artifacts/ HealthCheck
ENTRYPOINT ["/usr/share/service/dockerfile-entrypoint.sh"]
4 changes: 1 addition & 3 deletions oracle-api/dockerfile-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#!/bin/sh

java --source 17 InstallCert.java --quiet "${DATABASE_HOST}:${DATABASE_PORT}"
java -cp /usr/share/service/artifacts/ InstallCert --quiet "${DATABASE_HOST}:${DATABASE_PORT}"
keytool -exportcert -alias "${DATABASE_HOST}-1" -keystore jssecacerts -storepass changeit -file oracle.cer
keytool -importcert -alias orakey -noprompt -cacerts -storepass changeit -file oracle.cer

javac HealthCheck.java

java \
-Djava.security.egd=file:/dev/./urandom \
${JAVA_OPTS} \
Expand Down

0 comments on commit 82a1df1

Please sign in to comment.