Skip to content

Commit

Permalink
Merge pull request #559 from hobbit-project/feature/build-in-docker
Browse files Browse the repository at this point in the history
Build all components in Docker
  • Loading branch information
MichaelRoeder authored Dec 17, 2023
2 parents d169b44 + 7669710 commit 86893cb
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 32 deletions.
25 changes: 4 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# build platform components
default: build
build: build-dev-images

deploy: create-networks start

Expand All @@ -26,35 +25,19 @@ start-dev-platform:
start-dev-elk:
docker-compose -f docker-compose-elk.yml up -d

build: build-java build-dev-images

build-java: install-parent-pom build-controller build-storage build-analysis build-gui

build-gui:
# see hobbit-gui/gui-serverbackend/Dockerfile

build-controller:
cd platform-controller && make build

build-storage:
cd platform-storage/storage-service && mvn clean package -U

build-analysis:
cd analysis-component && mvn clean package -U

build-dev-images: build-dev-platform-controller-image build-dev-gui-image build-dev-analysis-image build-dev-storage-image

build-dev-platform-controller-image:
docker build -t hobbitproject/hobbit-platform-controller:dev ./platform-controller
docker build -t hobbitproject/hobbit-platform-controller:dev --file platform-controller/Dockerfile .

build-dev-gui-image:
docker build -t hobbitproject/hobbit-gui:dev --file hobbit-gui/gui-serverbackend/Dockerfile .

build-dev-analysis-image:
docker build -t hobbitproject/hobbit-analysis-component:dev ./analysis-component
docker build -t hobbitproject/hobbit-analysis-component:dev --file ./analysis-component/Dockerfile .

build-dev-storage-image:
docker build -t hobbitproject/hobbit-storage-service:dev ./platform-storage/storage-service
docker build -t hobbitproject/hobbit-storage-service:dev --file ./platform-storage/storage-service/Dockerfile .

create-networks:
@docker network inspect hobbit >/dev/null || (docker network create -d overlay --attachable --subnet 172.16.100.0/24 hobbit && echo "Created network: hobbit")
Expand Down
16 changes: 12 additions & 4 deletions analysis-component/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
FROM eclipse-temurin:11-focal
FROM maven:3-eclipse-temurin-11 AS build
WORKDIR /usr/src/hobbit-platform
COPY parent-pom/pom.xml parent-pom/
RUN mvn --file parent-pom -Dmaven.test.skip=true install
ARG project=analysis-component
COPY ${project}/pom.xml ${project}/
RUN mvn --file ${project} dependency:go-offline
COPY ${project}/src ${project}/src
RUN mvn --file ${project} -Dmaven.test.skip=true package

COPY target/analysis-component.jar .

CMD java -cp analysis-component.jar org.hobbit.core.run.ComponentStarter org.hobbit.analysis.AnalysisComponent
FROM eclipse-temurin:11
COPY --from=build /usr/src/hobbit-platform/analysis-component/target/analysis-component.jar .
CMD ["java", "-cp", "analysis-component.jar", "org.hobbit.core.run.ComponentStarter", "org.hobbit.analysis.AnalysisComponent"]
4 changes: 2 additions & 2 deletions hobbit-gui/gui-serverbackend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ RUN npm --prefix hobbit-gui/gui-client run build-prod
FROM maven:3-eclipse-temurin-11 AS build
WORKDIR /usr/src/hobbit-platform
COPY parent-pom/pom.xml ./parent-pom/
RUN mvn --file parent-pom -Dmaven.test.skip=true install
COPY hobbit-gui/gui-serverbackend/pom.xml ./hobbit-gui/gui-serverbackend/
RUN mvn --file ./hobbit-gui/gui-serverbackend/ dependency:go-offline
COPY hobbit-gui/gui-serverbackend/src ./hobbit-gui/gui-serverbackend/src
RUN mvn --file ./hobbit-gui/gui-serverbackend/ test
COPY --from=build-client /usr/src/hobbit-platform/hobbit-gui/gui-client/dist ./hobbit-gui/gui-client/dist
RUN mvn --file ./hobbit-gui/gui-serverbackend/ package
RUN mvn --file ./hobbit-gui/gui-serverbackend/ -Dmaven.test.skip=true package

FROM jetty:9.3-jre8

Expand Down
14 changes: 12 additions & 2 deletions platform-controller/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
FROM eclipse-temurin:11-focal
FROM maven:3-eclipse-temurin-11 AS build
WORKDIR /usr/src/hobbit-platform
COPY parent-pom/pom.xml parent-pom/
RUN mvn --file parent-pom -Dmaven.test.skip=true install
ARG project=platform-controller
COPY ${project}/pom.xml ${project}/
RUN mvn --file ${project} dependency:go-offline
COPY ${project}/src ${project}/src
RUN mvn --file ${project} -Dmaven.test.skip=true package

FROM eclipse-temurin:11

# Create an empty metadata directory (it will be used as default by the file-based image manager)
RUN mkdir -p /usr/src/app/metadata

COPY target/platform-controller.jar platform-controller.jar
COPY --from=build /usr/src/hobbit-platform/platform-controller/target/platform-controller.jar .

CMD ["java", "-cp", "platform-controller.jar", "org.hobbit.core.run.ComponentStarter", "org.hobbit.controller.PlatformController"]
14 changes: 11 additions & 3 deletions platform-storage/storage-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
FROM eclipse-temurin:11-focal

COPY target/storage-service.jar storage-service.jar
FROM maven:3-eclipse-temurin-11 AS build
WORKDIR /usr/src/hobbit-platform
COPY parent-pom/pom.xml parent-pom/
RUN mvn --file parent-pom -Dmaven.test.skip=true install
ARG project=platform-storage/storage-service
COPY ${project}/pom.xml ${project}/
RUN mvn --file ${project} dependency:go-offline
COPY ${project}/src ${project}/src
RUN mvn --file ${project} -Dmaven.test.skip=true package

FROM eclipse-temurin:11
COPY --from=build /usr/src/hobbit-platform/platform-storage/storage-service/target/storage-service.jar .
CMD ["java", "-cp", "storage-service.jar", "org.hobbit.core.run.ComponentStarter", "org.hobbit.storage.service.StorageService"]

0 comments on commit 86893cb

Please sign in to comment.