Last active
August 17, 2022 12:13
-
-
Save ljmotta/d14951323e84680fb00100cfbbab2806 to your computer and use it in GitHub Desktop.
Base Dockerfile for Serverless Workflow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM maven:3.8.5-jdk-11 as create | |
ARG QUARKUS_PLATFORM_VERSION | |
WORKDIR /tmp/ | |
RUN mvn io.quarkus.platform:quarkus-maven-plugin:${QUARKUS_PLATFORM_VERSION}:create \ | |
-DprojectGroupId=org.kie \ | |
-DprojectArtifactId=kn-plugin-workflow \ | |
-DnoCode \ | |
-DplatformVersion=${QUARKUS_PLATFORM_VERSION} \ | |
-Dextensions="kogito-quarkus-serverless-workflow,kogito-addons-quarkus-knative-eventing,resteasy-reactive-jackson,quarkus-kubernetes" | |
RUN cd kn-plugin-workflow \ | |
&& rm -rf src/main/docker/ src/main/java/ src/test/ | |
COPY workflow.sw.json /tmp/kn-plugin-workflow/src/main/resources | |
# =============================================================== | |
# BUILDER | |
# =============================================================== | |
# docker build -f Dockerfile.workflow --target=builder \ | |
# --build-arg QUARKUS_PLATFORM_VERSION=2.10.0.Final \ | |
# -f Dockerfile \ | |
# -t quay.io/kiegroup/swf-base:2.10.0.Final \ | |
# . | |
# TODO: change to minimal image | |
FROM openjdk:11 as builder | |
COPY --from=create /root/.m2 /root/.m2 | |
COPY --from=create /tmp/ /tmp/ | |
WORKDIR /tmp/kn-plugin-workflow | |
RUN ./mvnw package -Dquarkus.kubernetes.deployment-target=knative \ | |
&& rm -rf ./target \ | |
&& rm ./src/main/resources/workflow.sw.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# tag will change dynamically | |
FROM quay.io/kiegroup/swf-base:2.10.0.Final as builder | |
WORKDIR /tmp/kn-plugin-workflow | |
ARG extensions | |
RUN if [[ -z "$extensions" ]]; \ | |
then echo "WITHOUT ADDITIONAL EXTENSIONS"; \ | |
else ./mvnw quarkus:add-extension -Dextensions=${extensions}; \ | |
fi | |
# copy application.properties if exists | |
ARG workflow_file | |
COPY ${workflow_file} application.propertie[s] ./src/main/resources/ | |
ARG workflow_name | |
ARG container_registry | |
ARG container_group | |
ARG container_name | |
ARG container_tag | |
RUN ./mvnw package \ | |
-Dquarkus.kubernetes.deployment-target=knative \ | |
-Dquarkus.knative.name=${workflow_name} \ | |
-Dquarkus.container-image.registry=${container_registry} \ | |
-Dquarkus.container-image.group=${container_group} \ | |
-Dquarkus.container-image.name=${container_name} \ | |
-Dquarkus.container-image.tag=${container_tag} | |
# =============================================================== | |
# KUBERNETES FILES | |
# =============================================================== | |
# DOCKER_BUILDKIT=1 docker build -f Dockerfile.workflow --target=kubernetes \ | |
# --build-arg workflow_file=workflow.sw.json \ | |
# --build-arg extensions=quarkus-jsonp,quarkus-smallrye-openapi \ | |
# --build-arg workflow_name=my-project \ | |
# --build-arg container_registry=quay.io \ | |
# --build-arg container_group=lmotta \ | |
# --build-arg container_name=test \ | |
# --build-arg container_tag=0.0.1 \ | |
# --output type=local,dest=kubernetes . | |
FROM scratch as kubernetes | |
COPY --from=builder /tmp/kn-plugin-workflow/target/kubernetes . | |
# =============================================================== | |
# RUNNER | |
# =============================================================== | |
# docker build -f Dockerfile.workflow --target=runner \ | |
# --build-arg workflow_file=workflow.sw.json \ | |
# --build-arg extensions=quarkus-jsonp,quarkus-smallrye-openapi \ | |
# --build-arg workflow_name=my-project \ | |
# --build-arg container_registry=quay.io \ | |
# --build-arg container_group=lmotta \ | |
# --build-arg container_name=test \ | |
# --build-arg container_tag=0.0.1 \ | |
# -t quay.io/lmotta/runner . | |
# TODO: change to minimal image | |
FROM openjdk:11 as runner | |
COPY --from=builder /tmp/kn-plugin-workflow/target/quarkus-app/lib/ /runner/lib/ | |
COPY --from=builder /tmp/kn-plugin-workflow/target/quarkus-app/*.jar /runner/ | |
COPY --from=builder /tmp/kn-plugin-workflow/target/quarkus-app/app/ /runner/app/ | |
COPY --from=builder /tmp/kn-plugin-workflow/target/quarkus-app/quarkus/ /runner/quarkus/ | |
EXPOSE 8080 | |
CMD ["java", "-jar", "/deployments/quarkus-run.jar", "-Dquarkus.http.host=0.0.0.0"] | |
# =============================================================== | |
# DEV | |
# =============================================================== | |
# docker build -f Dockerfile.workflow --target=dev \ | |
# --build-arg workflow_file=workflow.sw.json \ | |
# --build-arg extensions=quarkus-jsonp,quarkus-smallrye-openapi \ | |
# --build-arg workflow_name=my-project \ | |
# --build-arg container_registry=quay.io \ | |
# --build-arg container_group=lmotta \ | |
# --build-arg container_name=test \ | |
# --build-arg container_tag=0.0.1 \ | |
# -t quay.io/lmotta/dev . | |
# docker container run -it \ | |
# --mount type=bind,source="$(pwd)",target=/tmp/kn-plugin-workflow/src/main/resources \ | |
# -p 8080:8080 quay.io/lmotta/dev | |
# TODO: change to minimal image | |
FROM openjdk:11 as dev | |
COPY --from=builder /root/.m2/ /root/.m2/ | |
COPY --from=builder /tmp/ /tmp/ | |
WORKDIR /tmp/kn-plugin-workflow/ | |
EXPOSE 8080 | |
CMD ["./mvnw", "quarkus:dev"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment