FROM eclipse-temurin:21-jre-noble as runner

ENV FC_LANG=en-US LC_CTYPE=en_US.UTF-8

ARG GIT_COMMIT_SHA
ENV GIT_COMMIT_SHA=${GIT_COMMIT_SHA}

# Dependencies
RUN apt-get update && \
  apt-get upgrade -y && \
  apt-get install -y ca-certificates ca-certificates-java fonts-noto && \
  apt-get clean && \
  curl https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem -o /usr/local/share/ca-certificates/rds-combined-ca-bundle.pem && \
  curl https://cacerts.digicert.com/DigiCertGlobalRootG2.crt.pem -o /usr/local/share/ca-certificates/DigiCertGlobalRootG2.crt.pem && \
  update-ca-certificates && \
  mkdir -p /plugins && chmod a+rwx /plugins && \
  keytool -list -cacerts

# add Metabase jar & add our run script to the image
COPY ./metabase.jar ./run_metabase.sh /app/

# expose our default runtime port
EXPOSE 3000

# if you have an H2 database that you want to initialize the new Metabase
# instance with, mount it in the container as a volume that will match the
# pattern /app/initial*.db:
# $ docker run ... -v $PWD/metabase.db.mv.db:/app/initial.db.mv.db ...

# run it
ENTRYPOINT ["/app/run_metabase.sh"]
