Skip to content

Commit

Permalink
#150 use Habushu's containerize-dependencies goal
Browse files Browse the repository at this point in the history
  • Loading branch information
ewilkins-csi committed Jul 8, 2024
1 parent 68f94d1 commit fd7f673
Show file tree
Hide file tree
Showing 31 changed files with 160 additions and 272 deletions.
2 changes: 1 addition & 1 deletion build-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<version.failsafe.plugin>${version.maven.surefire.plugin}</version.failsafe.plugin>
<version.fermenter>2.10.3</version.fermenter>
<version.fermenter.legacy.tools>2.8.0</version.fermenter.legacy.tools>
<version.habushu.plugin>2.15.0</version.habushu.plugin>
<version.habushu.plugin>2.16.0</version.habushu.plugin>
<version.python>3.11.4</version.python>
<version.help.plugin>3.2.0</version.help.plugin>
<version.krausening>19</version.krausening>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Script for creating base Airflow Docker image
FROM apache/airflow:2.7.0-python3.11

LABEL org.opencontainers.image.source = "https://github.com/boozallen/aissemble"
LABEL org.opencontainers.image.source="https://github.com/boozallen/aissemble"

USER root

Expand Down Expand Up @@ -37,10 +37,10 @@ USER root
RUN mkdir -p /tmp/mlruns /tmp/model
RUN chown airflow:0 -R /tmp/mlruns /tmp/model

ENV JAVA_HOME /usr/lib/jvm/default-java
ENV JAVA_HOME=/usr/lib/jvm/default-java
RUN export JAVA_HOME

ENV DEBIAN_FRONTEND noninteractive
ENV DEBIAN_FRONTEND=noninteractive
ENV TERM linux

# Airflow UID is 50000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ARG DOCKER_BASELINE_REPO_ID
ARG VERSION_AISSEMBLE
FROM ${DOCKER_BASELINE_REPO_ID}boozallen/aissemble-quarkus:${VERSION_AISSEMBLE}

LABEL org.opencontainers.image.source = "https://github.com/boozallen/aissemble"
LABEL org.opencontainers.image.source="https://github.com/boozallen/aissemble"

USER root
RUN useradd --home /home/configstore --user-group --shell /usr/sbin/nologin --uid 1001 configstore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ ARG DOCKER_BASELINE_REPO_ID
ARG VERSION_AISSEMBLE
FROM ${DOCKER_BASELINE_REPO_ID}boozallen/aissemble-quarkus:${VERSION_AISSEMBLE}

LABEL org.opencontainers.image.source = "https://github.com/boozallen/aissemble"
LABEL org.opencontainers.image.source="https://github.com/boozallen/aissemble"

COPY target/quarkus-app/ /deployments/
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Script for creating base FastAPI Docker image

FROM python:3.11
FROM python:3.11-slim

LABEL org.opencontainers.image.source = "https://github.com/boozallen/aissemble"
LABEL org.opencontainers.image.source="https://github.com/boozallen/aissemble"

WORKDIR /app

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM mysql/mysql-server:8.0.30

LABEL org.opencontainers.image.source = "https://github.com/boozallen/aissemble"
LABEL org.opencontainers.image.source="https://github.com/boozallen/aissemble"

# MySQL places files into the root directory as a part of the startup process.
# Since the root directory isn't owned by the mysql user, it has to run as root normally in order to create those files.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM apache/hive:${METASTORE_VERSION} as appsource

FROM eclipse-temurin:17-jre as final

LABEL org.opencontainers.image.source = "https://github.com/boozallen/aissemble"
LABEL org.opencontainers.image.source="https://github.com/boozallen/aissemble"

WORKDIR /opt

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM jenkins/ssh-agent:latest-jdk11

LABEL org.opencontainers.image.source = "https://github.com/boozallen/aissemble"
LABEL org.opencontainers.image.source="https://github.com/boozallen/aissemble"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM jenkins/jenkins:lts-jdk11

LABEL org.opencontainers.image.source = "https://github.com/boozallen/aissemble"
LABEL org.opencontainers.image.source="https://github.com/boozallen/aissemble"

USER root
USER jenkins
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#Script for creating base Kafka Docker image
FROM bitnami/kafka:3.5

LABEL org.opencontainers.image.source = "https://github.com/boozallen/aissemble"
LABEL org.opencontainers.image.source="https://github.com/boozallen/aissemble"

USER root
RUN apt-get update -y \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ARG DOCKER_BASELINE_REPO_ID
ARG VERSION_AISSEMBLE
FROM ${DOCKER_BASELINE_REPO_ID}boozallen/aissemble-quarkus:${VERSION_AISSEMBLE}

LABEL org.opencontainers.image.source = "https://github.com/boozallen/aissemble"
LABEL org.opencontainers.image.source="https://github.com/boozallen/aissemble"

USER root
RUN useradd --home /home/metadata --user-group --shell /usr/sbin/nologin --uid 1001 metadata
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM python:3.11

LABEL org.opencontainers.image.source = "https://github.com/boozallen/aissemble"
LABEL org.opencontainers.image.source="https://github.com/boozallen/aissemble"

RUN pip install \
mlflow==2.3.1 \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,60 +14,11 @@

<packaging>docker-build</packaging>

<properties>
<wheelOutputDirectory>${project.build.directory}/wheels/</wheelOutputDirectory>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.technologybrewery.orphedomos</groupId>
<artifactId>orphedomos-maven-plugin</artifactId>
<executions>
<execution>
<id>retrieve-wheels</id>
<phase>validate</phase>
<goals>
<goal>retrieve-wheels</goal>
</goals>
<configuration>
<wheelDependencies>
<wheelDependency>
<artifactId>aissemble-extensions-model-training-api-sagemaker</artifactId>
<targetDirectory>${wheelOutputDirectory}</targetDirectory>
</wheelDependency>
</wheelDependencies>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-docker-resources</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources/docker</directory>
<filtering>false</filtering>
</resource>
<resource>
<directory>../../../../extensions/aissemble-extensions-model-training-api-sagemaker/src/model_training_api_sagemaker</directory>
<includes>
<include>model_training_api_sagemaker.py</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
<groupId>org.technologybrewery.habushu</groupId>
<artifactId>habushu-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,43 @@
# Script for creating base AIOps Model Training API image

ARG DOCKER_BASELINE_REPO_ID
ARG VERSION_AISSEMBLE
FROM ${DOCKER_BASELINE_REPO_ID}boozallen/aissemble-fastapi:${VERSION_AISSEMBLE} AS builder

RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
#HABUSHU_BUILDER_STAGE - HABUSHU GENERATED CODE (DO NOT MODIFY)
FROM python:3.11-slim AS habushu_builder
# Poetry and supporting plugin installations
RUN python -m ensurepip --upgrade && \
pip install poetry && \
poetry self add poetry-monorepo-dependency-plugin && \
poetry self add poetry-plugin-bundle

COPY ./target/wheels/* /tmp/wheels/
# Re-install any dependencies defined in the base image into the virtual environment, then install new requirements
RUN pip install -r /tmp/requirements.txt && \
set -e && \
cd /tmp/wheels/; for x in *.whl; do pip install $x --no-cache-dir; done
WORKDIR /work-dir
COPY --chown=1001 target/containerize-support ./containerize-support/
RUN find . -type f -name pyproject.toml -exec sed -i 's|develop[[:blank:]]*=[[:blank:]]*true|develop = false|g' {} \;

USER root
WORKDIR /work-dir/containerize-support/extensions/aissemble-extensions-model-training-api-sagemaker
ENV POETRY_CACHE_DIR="/.cache/pypoetry"

# Start a new build stage based on a slim Python image, which will have the minimal amount of code, FastAPI
# components, and installed dependencies copied into it from the initial builder image
FROM python:3.11-slim as final
# export target project's virtual environment to /opt/venv
RUN --mount=type=cache,target=/.cache/pypoetry/ \
poetry lock && \
poetry bundle venv /opt/venv
#HABUSHU_BUILDER_STAGE - HABUSHU GENERATED CODE (END)

LABEL org.opencontainers.image.source = "https://github.com/boozallen/aissemble"

WORKDIR /app
FROM ${DOCKER_BASELINE_REPO_ID}boozallen/aissemble-fastapi:${VERSION_AISSEMBLE} AS builder

# Set/move any required environmental variables and key scripts/configs needed by FastAPI from the base image
# into the slimmed down final Python image
ENV API_MAIN model_training_api_sagemaker
#HABUSHU_FINAL_STAGE - HABUSHU GENERATED CODE (DO NOT MODIFY)
FROM python:3.11-slim AS final
# Copy venv from builder and activate by adding to the path
COPY --from=habushu_builder --chown=1001 /opt/venv /opt/venv/
ENV PATH="/opt/venv/bin:$PATH"
ENV PYTHONPATH=/app
COPY --from=builder /start.sh /start.sh
#HABUSHU_FINAL_STAGE - HABUSHU GENERATED CODE (END)

# Copy over the virtual environment (and all pip installed packages) from the initial builder stage
COPY --from=builder /opt/venv /opt/venv
LABEL org.opencontainers.image.source="https://github.com/boozallen/aissemble"

COPY ./target/model_training_api_sagemaker.py /app/model_training_api_sagemaker.py
# Set/move any required environmental variables and key scripts/configs needed by FastAPI from the base image
# into the slimmed down final Python image
ENV API_MAIN=model_training_api_sagemaker.model_training_api_sagemaker
COPY --from=builder --chown=1001 /start.sh /start.sh

CMD ["/start.sh"]
Original file line number Diff line number Diff line change
Expand Up @@ -13,65 +13,12 @@
<description>A base image for the aiSSEMBLE Model Training API service which runs on FastAPI</description>

<packaging>docker-build</packaging>

<properties>
<wheelOutputDirectory>${project.build.directory}/wheels/</wheelOutputDirectory>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.technologybrewery.orphedomos</groupId>
<artifactId>orphedomos-maven-plugin</artifactId>
<executions>
<execution>
<id>retrieve-wheels</id>
<phase>validate</phase>
<goals>
<goal>retrieve-wheels</goal>
</goals>
<configuration>
<wheelDependencies>
<wheelDependency>
<artifactId>aissemble-foundation-messaging-python-client</artifactId>
<targetDirectory>${wheelOutputDirectory}</targetDirectory>
</wheelDependency>
<wheelDependency>
<artifactId>aissemble-foundation-model-training-api</artifactId>
<targetDirectory>${wheelOutputDirectory}</targetDirectory>
</wheelDependency>
</wheelDependencies>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-docker-resources</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources/docker</directory>
<filtering>false</filtering>
</resource>
<resource>
<directory>../../../../foundation/aissemble-foundation-model-training-api/src/model_training_api</directory>
<includes>
<include>model_training_api.py</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
<groupId>org.technologybrewery.habushu</groupId>
<artifactId>habushu-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,46 @@
# Script for creating base AIOps Model Training API image

ARG DOCKER_BASELINE_REPO_ID
ARG VERSION_AISSEMBLE
FROM ${DOCKER_BASELINE_REPO_ID}boozallen/aissemble-fastapi:${VERSION_AISSEMBLE} AS builder
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"

COPY ./target/wheels/* /tmp/wheels/
# Re-install any dependencies defined in the base image into the virtual environment, then install new requirements
RUN pip install -r /tmp/requirements.txt && \
set -e && \
cd /tmp/wheels/; for x in *.whl; do pip install $x --no-cache-dir; done

# Start a new build stage based on a slim Python image, which will have the minimal amount of code, FastAPI
# components, and installed dependencies copied into it from the initial builder image
FROM python:3.11-slim as final
#HABUSHU_BUILDER_STAGE - HABUSHU GENERATED CODE (DO NOT MODIFY)
FROM python:3.11-slim AS habushu_builder
# Poetry and supporting plugin installations
RUN python -m ensurepip --upgrade && \
pip install poetry && \
poetry self add poetry-monorepo-dependency-plugin && \
poetry self add poetry-plugin-bundle

WORKDIR /work-dir
COPY --chown=1001 target/containerize-support ./containerize-support/
RUN find . -type f -name pyproject.toml -exec sed -i 's|develop[[:blank:]]*=[[:blank:]]*true|develop = false|g' {} \;

USER root
WORKDIR /work-dir/containerize-support/foundation/aissemble-foundation-model-training-api
ENV POETRY_CACHE_DIR="/.cache/pypoetry"

# export target project's virtual environment to /opt/venv
RUN --mount=type=cache,target=/.cache/pypoetry/ \
poetry lock && \
poetry bundle venv /opt/venv
#HABUSHU_BUILDER_STAGE - HABUSHU GENERATED CODE (END)

FROM ghcr.io/boozallen/aissemble-fastapi:1.8.0-SNAPSHOT AS builder

#HABUSHU_FINAL_STAGE - HABUSHU GENERATED CODE (DO NOT MODIFY)
FROM python:3.11-slim AS final
# Copy venv from builder and activate by adding to the path
COPY --from=habushu_builder --chown=1001 /opt/venv /opt/venv/
ENV PATH="/opt/venv/bin:$PATH"
#HABUSHU_FINAL_STAGE - HABUSHU GENERATED CODE (END)

LABEL org.opencontainers.image.source = "https://github.com/boozallen/aissemble"
LABEL org.opencontainers.image.source="https://github.com/boozallen/aissemble"

WORKDIR /app
# Set/move any required environmental variables and key scripts/configs needed by FastAPI from the base image
# into the slimmed down final Python image
ENV API_MAIN model_training_api
ENV PATH="/opt/venv/bin:$PATH"
ENV PYTHONPATH=/app
ENV API_MAIN=model_training_api.model_training_api
ENV PYTHONUNBUFFERED="1"
ENV GIT_PYTHON_REFRESH="quiet"
COPY --from=builder /start.sh /start.sh

# Copy over the virtual environment (and all pip installed packages) from the initial builder stage
COPY --from=builder /opt/venv /opt/venv

COPY ./target/model_training_api.py /app/model_training_api.py
COPY --from=builder --chown=1001 /start.sh /start.sh

CMD ["/start.sh"]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM nvidia/cuda:12.1.1-base-ubuntu22.04

LABEL org.opencontainers.image.source = "https://github.com/boozallen/aissemble"
LABEL org.opencontainers.image.source="https://github.com/boozallen/aissemble"

# Workaround for ubuntu fix start
# https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/1962606
Expand Down
Loading

0 comments on commit fd7f673

Please sign in to comment.