Commit 72bab3d7 authored by Mat's avatar Mat

Build project in Docker; create builder image

parent 2aa469c7
FROM maven:3.6-jdk-11
RUN useradd -u 10000 -m builduser
RUN mkdir /home/builduser/.m2
RUN chown -R builduser /home/builduser/.m2
USER builduser
WORKDIR /home/builduser/src/
# Load the dependencies first (to cache them for future builds)
copy --chown=builduser ./pom.xml ./
copy --chown=builduser ./searchitect-backend-dynrh2lev/pom.xml ./searchitect-backend-dynrh2lev/pom.xml
copy --chown=builduser ./searchitect-backend-dynrh2levrocks/pom.xml ./searchitect-backend-dynrh2levrocks/pom.xml
copy --chown=builduser ./searchitect-backend-sophos/pom.xml ./searchitect-backend-sophos/pom.xml
copy --chown=builduser ./searchitect-backend-template/pom.xml ./searchitect-backend-template/pom.xml
copy --chown=builduser ./searchitect-client-dynrh2lev-plugin/pom.xml ./searchitect-client-dynrh2lev-plugin/pom.xml
copy --chown=builduser ./searchitect-client-dynrh2levrocks-plugin/pom.xml ./searchitect-client-dynrh2levrocks-plugin/pom.xml
copy --chown=builduser ./searchitect-client-sophos-plugin/pom.xml ./searchitect-client-sophos-plugin/pom.xml
copy --chown=builduser ./searchitect-client/pom.xml ./searchitect-client/pom.xml
copy --chown=builduser ./searchitect-common-dynrh2lev/pom.xml ./searchitect-common-dynrh2lev/pom.xml
copy --chown=builduser ./searchitect-common-sophos/pom.xml ./searchitect-common-sophos/pom.xml
copy --chown=builduser ./searchitect-common/pom.xml ./searchitect-common/pom.xml
copy --chown=builduser ./searchitect-gate/pom.xml ./searchitect-gate/pom.xml
copy --chown=builduser ./searchitect-test/pom.xml ./searchitect-test/pom.xml
copy --chown=builduser ./searchitect-testset/pom.xml ./searchitect-testset/pom.xml
# Dependency resolution will fail, because the searchitects projects ares searched but not built. '--fail-never' forces docker to continue.
RUN mvn dependency:go-offline --fail-never
# Do the actual build
COPY --chown=builduser . .
RUN mvn -e clean install -DskipTests
CMD ["echo", "Just a builder image. Nothing to see here."]
......@@ -49,6 +49,12 @@ Docker enables a containerized easy deployment, the docker-compose configuration
docker-compose build
docker-compose up
or
docker-compose up -d
if you want to move the docker process to the background.
## How to add a new scheme
1. Implement your scheme in a new searchitect-common-scheme project
......
version: "2"
version: "3.4"
services:
# important note: servicename MUST match backend name b_id of request urls
builder:
build:
context: ./
# important note: servicename MUST match backend name b_id of request urls
template:
build: ./searchitect-backend-template
ports:
- "8383:8383"
build:
target: backend-template
context: ./searchitect-backend-template
depends_on:
- builder
restart: always
ports:
- "8383:8383"
sophos:
build: ./searchitect-backend-sophos
build:
target: backend-sophos
context: ./searchitect-backend-sophos
depends_on:
- builder
restart: always
ports:
- "8484:8484"
dynrh2lev:
build: ./searchitect-backend-dynrh2lev
build:
context: ./searchitect-backend-dynrh2lev
target: backend-dynrh2lev
depends_on:
- builder
restart: always
ports:
- "8282:8282"
dynrh2levrocks:
build: ./searchitect-backend-dynrh2levrocks
ports:
- "8585:8585"
build:
context: ./searchitect-backend-dynrh2levrocks
target: backend-dynrh2levrocks
depends_on:
- builder
restart: always
ports:
- "8585:8585"
searchitect-gate:
build: ./searchitect-gate
gate:
build:
target: gate
context: ./searchitect-gate
depends_on:
- builder
restart: always
ports:
- "8433:8433"
FROM openjdk:10
VOLUME /tmp
COPY ./target/searchitect-backend-dynrh2lev-0.1.0.jar /tmp/searchitect-backend-dynrh2lev-0.1.0.jar
FROM searchitect_builder as builder
FROM openjdk:10-jre-slim as backend-dynrh2lev
RUN useradd -u 10000 -m searchitect
USER searchitect
COPY --from=builder /home/builduser/src/searchitect-backend-dynrh2lev/target/searchitect-backend-dynrh2lev-0.1.0.jar /tmp/searchitect-backend-dynrh2lev-0.1.0.jar
CMD ["java", "-jar","/tmp/searchitect-backend-dynrh2lev-0.1.0.jar"]
FROM openjdk:10
VOLUME /tmp
COPY ./target/searchitect-backend-dynrh2levrocks-0.1.0.jar /tmp/searchitect-backend-dynrh2levrocks-0.1.0.jar
FROM searchitect_builder as builder
FROM openjdk:10-jre-slim as backend-dynrh2levrocks
RUN useradd -u 10000 -m searchitect
USER searchitect
COPY --from=builder /home/builduser/src/searchitect-backend-dynrh2levrocks/target/searchitect-backend-dynrh2levrocks-0.1.0.jar /tmp/searchitect-backend-dynrh2levrocks-0.1.0.jar
CMD ["java", "-jar","/tmp/searchitect-backend-dynrh2levrocks-0.1.0.jar"]
FROM openjdk:10
VOLUME /tmp
COPY ./target/searchitect-backend-sophos-0.1.0.jar /tmp/searchitect-backend-sophos-0.1.0.jar
FROM searchitect_builder as builder
FROM openjdk:10-jre-slim as backend-sophos
RUN useradd -u 10000 -m searchitect
USER searchitect
COPY --from=builder /home/builduser/src/searchitect-backend-sophos/target/searchitect-backend-sophos-0.1.0.jar /tmp/searchitect-backend-sophos-0.1.0.jar
CMD ["java", "-jar","/tmp/searchitect-backend-sophos-0.1.0.jar"]
FROM openjdk:10
VOLUME /tmp
COPY ./target/searchitect-backend-template-0.1.0.jar /tmp/searchitect-backend-template-0.1.0.jar
CMD ["java", "-jar","/tmp/searchitect-backend-template-0.1.0.jar"]
FROM searchitect_builder as builder
FROM openjdk:10-jre-slim as backend-template
RUN useradd -u 10000 -m searchitect
USER searchitect
COPY --from=builder /home/builduser/src/searchitect-backend-template/target/searchitect-backend-template-0.1.0.jar /tmp/searchitect-backend-template-0.1.0.jar
CMD ["java", "-jar","/tmp/searchitect-backend-template-0.1.0.jar"]
\ No newline at end of file
FROM openjdk:8
VOLUME /tmp
RUN useradd -u 10000 -m searchitect
USER searchitect
COPY ./target/searchitect-backend-template-0.1.0.jar /tmp/searchitect-backend-template-0.1.0.jar
CMD ["java", "-jar","/tmp/searchitect-backend-template-0.1.0.jar"]
FROM openjdk:8
VOLUME /tmp
RUN useradd -u 10000 -m searchitect
USER searchitect
COPY ./target/searchitect-backend-template-0.1.0.jar /tmp/searchitect-backend-template-0.1.0.jar
CMD ["java", "-jar","/tmp/searchitect-backend-template-0.1.0.jar"]
FROM openjdk:8
VOLUME /tmp
RUN useradd -u 10000 -m searchitect
USER searchitect
COPY ./target/searchitect-backend-template-0.1.0.jar /tmp/searchitect-backend-template-0.1.0.jar
CMD ["java", "-jar","/tmp/searchitect-backend-template-0.1.0.jar"]
FROM openjdk:8
VOLUME /tmp
RUN useradd -u 10000 -m searchitect
USER searchitect
COPY ./target/searchitect-gate-0.1.0.jar /tmp/searchitect-gate-0.1.0.jar
CMD ["java", "-jar","/tmp/searchitect-gate-0.1.0.jar"]
FROM openjdk:8
VOLUME /tmp
RUN useradd -u 10000 -m searchitect
USER searchitect
COPY ./target/searchitect-backend-template-0.1.0.jar /tmp/searchitect-backend-template-0.1.0.jar
CMD ["java", "-jar","/tmp/searchitect-backend-template-0.1.0.jar"]
FROM openjdk:8
VOLUME /tmp
RUN useradd -u 10000 -m searchitect
USER searchitect
COPY ./target/searchitect-backend-template-0.1.0.jar /tmp/searchitect-backend-template-0.1.0.jar
CMD ["java", "-jar","/tmp/searchitect-backend-template-0.1.0.jar"]
FROM openjdk:8
VOLUME /tmp
RUN useradd -u 10000 -m searchitect
USER searchitect
COPY ./target/searchitect-backend-template-0.1.0.jar /tmp/searchitect-backend-template-0.1.0.jar
CMD ["java", "-jar","/tmp/searchitect-backend-template-0.1.0.jar"]
FROM openjdk:10
VOLUME /tmp
COPY ./target/searchitect-gate-0.1.0.jar /tmp/searchitect-gate-0.1.0.jar
FROM searchitect_builder as builder
FROM openjdk:10-jre-slim as gate
RUN useradd -u 10000 -m searchitect
USER searchitect
COPY --from=builder /home/builduser/src/searchitect-gate/target/searchitect-gate-0.1.0.jar /tmp/searchitect-gate-0.1.0.jar
CMD ["java", "-jar","/tmp/searchitect-gate-0.1.0.jar"]
FROM openjdk:8
VOLUME /tmp
RUN useradd -u 10000 -m searchitect
USER searchitect
COPY ./target/searchitect-gate-0.1.0.jar /tmp/searchitect-gate-0.1.0.jar
CMD ["java", "-jar","/tmp/searchitect-gate-0.1.0.jar"]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment