| # Licensed to the Apache Software Foundation (ASF) under one or more |
| # contributor license agreements. See the NOTICE file distributed with |
| # this work for additional information regarding copyright ownership. |
| # The ASF licenses this file to You under the Apache License, Version 2.0 |
| # (the "License"); you may not use this file except in compliance with |
| # the License. You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| ## Stage 1 : build with maven builder image with native capabilities |
| FROM quay.io/quarkus/ubi-quarkus-native-image:21.3.0-java11 AS build-gen |
| |
| ## rsync required for npm to build frontend |
| USER root |
| RUN microdnf install rsync |
| |
| ## Copy code |
| COPY --chown=quarkus:quarkus karavan-generator/mvnw /code/mvnw |
| COPY --chown=quarkus:quarkus karavan-generator/.mvn /code/.mvn |
| COPY --chown=quarkus:quarkus karavan-generator/ /code/karavan-generator/ |
| COPY --chown=quarkus:quarkus karavan-core/ /code/karavan-core/ |
| COPY --chown=quarkus:quarkus karavan-app/ /code/karavan-app/ |
| COPY --chown=quarkus:quarkus karavan-designer/ /code/karavan-designer/ |
| # Required as output for KameletGenerator: |
| COPY --chown=quarkus:quarkus karavan-vscode/ /code/karavan-vscode/ |
| |
| USER quarkus |
| WORKDIR /code |
| |
| # Generate Camel definitions |
| RUN ./mvnw clean compile exec:java -Dexec.mainClass="org.apache.camel.karavan.generator.KaravanGenerator" -f karavan-generator |
| |
| ## Stage 2 : build karavan-core |
| FROM node:16-alpine AS build-node |
| # Root user as we will not be running this image anyway |
| USER root |
| WORKDIR /code/karavan-core |
| |
| COPY --chown=root karavan-core/tsconfig.json /code/karavan-core/ |
| COPY --chown=root karavan-core/package.json /code/karavan-core/ |
| COPY --chown=root karavan-core/package-lock.json /code/karavan-core/ |
| RUN npm install --ignore-scripts |
| |
| COPY --chown=root --from=build-gen /code/karavan-core/ /code/karavan-core/ |
| RUN npm run build |
| |
| ## Stage 3 : build karavan-app |
| FROM build-gen as build-app |
| COPY --chown=quarkus:quarkus --from=build-node /code/karavan-core/lib/ /code/karavan-core/lib/ |
| COPY --chown=quarkus:quarkus --from=build-node /code/karavan-core/node_modules/ /code/karavan-core/node_modules/ |
| RUN ./mvnw clean package -Pnative -f karavan-app |
| |
| ## Stage 4 : create the docker final image |
| FROM quay.io/quarkus/quarkus-distroless-image:1.0 |
| COPY --chown=nonroot --from=build-app /code/karavan-app/target/*-runner /deployments/application |
| |
| EXPOSE 8080 |
| USER nonroot |
| WORKDIR /deployments |
| CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] |