Skip to content

Instantly share code, notes, and snippets.

@gbzarelli
Last active October 20, 2021 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gbzarelli/cab7e53e3eda1dab6273f0aa63009b5e to your computer and use it in GitHub Desktop.
Save gbzarelli/cab7e53e3eda1dab6273f0aa63009b5e to your computer and use it in GitHub Desktop.
release:
enabled: true
stage: 'PreSync'
policy: 'BeforeHookCreation'
wave: 0
command: 'flyway/flyway'
args:
- '-locations=filesystem:/flyway/sql'
- '-url=$(DATASOURCE_URL)'
- '-schemas=my_db'
- '-user=$(DATASOURCE_USERNAME)'
- '-password=$(DATASOURCE_PASSWORD)'
- '-connectRetries=3'
- 'migrate'
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3
ARG JAVA_PACKAGE=java-11-openjdk-headless
ARG RUN_JAVA_VERSION=1.3.8
ENV FLYWAY_VERSION 7.5.2
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
# Install java and the run-java script
# Also set up permissions for user `1001`
RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} tar gzip \
&& microdnf update \
&& microdnf clean all \
&& mkdir /deployments \
&& mkdir /flyway \
&& chown 1001 /deployments \
&& chmod "g+rwX" /deployments \
&& chown 1001:root /deployments \
&& curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \
&& chown 1001 /deployments/run-java.sh \
&& chmod 540 /deployments/run-java.sh \
&& echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/lib/security/java.security
# Install and configure Flyway
RUN curl https://repo1.maven.org/maven2/org/flywaydb/flyway-commandline/${FLYWAY_VERSION}/flyway-commandline-${FLYWAY_VERSION}.tar.gz -o /flyway/flyway-commandline-${FLYWAY_VERSION}.tar.gz \
&& tar -xzf /flyway/flyway-commandline-${FLYWAY_VERSION}.tar.gz --strip-components=1 -C /flyway \
&& rm /flyway/flyway-commandline-${FLYWAY_VERSION}.tar.gz \
&& chown 1001 /flyway/flyway \
&& chmod 540 /flyway/flyway
# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager -javaagent:newrelic/newrelic.jar"
COPY app/quarkus-application/target/lib/* /deployments/lib/
COPY app/quarkus-application/target/*-runner.jar /deployments/app.jar
COPY resources/flyway/db/migration /flyway/sql
COPY newrelic/newrelic.jar /deployments/newrelic/newrelic.jar
EXPOSE 8080
USER 1001
ENTRYPOINT [ "/deployments/run-java.sh" ]
ROM registry.access.redhat.com/ubi8/ubi-minimal:8.3
ARG JAVA_PACKAGE=java-11-openjdk-headless
ARG RUN_JAVA_VERSION=1.3.8
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} tar gzip \
&& microdnf update \
&& microdnf clean all \
&& mkdir /deployments \
&& chown 1001 /deployments \
&& chmod "g+rwX" /deployments \
&& chown 1001:root /deployments \
&& curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \
&& chown 1001 /deployments/run-java.sh \
&& chmod 540 /deployments/run-java.sh \
&& echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/lib/security/java.security
COPY /target/*.jar /deployments/app.jar
EXPOSE 8080
USER 1001
ENTRYPOINT [ "/deployments/run-java.sh" ]
FROM adoptopenjdk:13-jre-hotspot
ARG JAVA_PACKAGE=java-13-openjdk-headless
ARG RUN_JAVA_VERSION=1.3.8
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
ENV FLYWAY_VERSION 7.5.2
# Install java and the run-java script
# Also set up permissions for user `1001`
RUN mkdir /deployments \
&& mkdir /flyway \
&& chown 1001 /deployments \
&& chmod "g+rwX" /deployments \
&& chown 1001:root /deployments \
&& curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \
&& chown 1001 /deployments/run-java.sh \
&& chmod 540 /deployments/run-java.sh
# Install and configure Flyway
RUN curl https://repo1.maven.org/maven2/org/flywaydb/flyway-commandline/${FLYWAY_VERSION}/flyway-commandline-${FLYWAY_VERSION}.tar.gz -o /flyway/flyway-commandline-${FLYWAY_VERSION}.tar.gz \
&& tar -xzf /flyway/flyway-commandline-${FLYWAY_VERSION}.tar.gz --strip-components=1 -C /flyway \
&& rm /flyway/flyway-commandline-${FLYWAY_VERSION}.tar.gz \
&& chown 1001 /flyway/flyway \
&& chmod 540 /flyway/flyway
ENV JAVA_OPTIONS="-javaagent:newrelic/newrelic.jar"
COPY newrelic/newrelic.jar /deployments/newrelic/newrelic.jar
COPY /target/*.jar /deployments/app.jar
COPY src/main/resources/db/migration /flyway/sql
EXPOSE 8080
USER 1001
ENTRYPOINT [ "/deployments/run-java.sh" ]
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3
ARG JAVA_PACKAGE=java-1.8.0-openjdk-headless
ARG RUN_JAVA_VERSION=1.3.8
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} tar gzip \
&& microdnf update \
&& microdnf clean all \
&& mkdir /deployments \
&& chown 1001 /deployments \
&& chmod "g+rwX" /deployments \
&& chown 1001:root /deployments \
&& curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \
&& chown 1001 /deployments/run-java.sh \
&& chmod 540 /deployments/run-java.sh \
&& echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/lib/security/java.security
COPY /target/*.jar /deployments/app.jar
EXPOSE 8080
USER 1001
ENTRYPOINT [ "/deployments/run-java.sh" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment