containers: simplify Dockerfile and container build
This changes the following: - Only produce one container. There is no particular benefit to supporting several different base containers, so unify on ubi as that is what we need ourselves. - Build directly from git. Now that the RPM we include in our container does not have any dependencies and only contains a couple of executables, the indirection via RPM has less value. Eventually the value will be reduced even further as we merge the entrypoint into the main binary and move dnf-json into the worker, leaving us with only a go binary. The only potential benefit might be that the build environment of RPMs is more clearly defined, but there is no real reason to believe that our mockbuild is any better than using the UBI golang build container. This simplifies the container builds, and brings us more in line with what is done in image-builder, and what is needed to deploy to openshift.
This commit is contained in:
parent
c9077c8a7f
commit
c3185466ae
3 changed files with 24 additions and 125 deletions
|
|
@ -1,71 +0,0 @@
|
||||||
#
|
|
||||||
# osbuild-composer - Containerized OSBuild Composer
|
|
||||||
#
|
|
||||||
# This container provides a minimal fedora image with the osbuild-composer
|
|
||||||
# application installed and configured as default entrypoint.
|
|
||||||
#
|
|
||||||
# Build Arguments:
|
|
||||||
#
|
|
||||||
# * OSB_FROM
|
|
||||||
# This specifies the host image to use. It must be an RPM-based
|
|
||||||
# distribution image with all osbuild-composer requirements
|
|
||||||
# pre-installed.
|
|
||||||
#
|
|
||||||
# Example: "docker.io/library/fedora:latest"
|
|
||||||
#
|
|
||||||
# * OSB_RPMREPO
|
|
||||||
# Base URL of an RPM repository from which to install osbuild-composer
|
|
||||||
# from.
|
|
||||||
#
|
|
||||||
# Example: "https://dl01.fedoraproject.org/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/"
|
|
||||||
#
|
|
||||||
|
|
||||||
# Image arguments must be imported before `FROM`.
|
|
||||||
ARG OSB_FROM="docker.io/library/fedora:latest"
|
|
||||||
|
|
||||||
# Prepare our host environment.
|
|
||||||
FROM "${OSB_FROM}" AS base
|
|
||||||
|
|
||||||
# Import build parameters.
|
|
||||||
ARG OSB_RPMREPO="https://dl01.fedoraproject.org/pub/fedora/linux/releases/\$releasever/Everything/\$basearch/os/"
|
|
||||||
|
|
||||||
# Create our state directory and use it as anchor.
|
|
||||||
WORKDIR "/var/lib/osb"
|
|
||||||
|
|
||||||
# Create and switch into our src directory, which we use as temporary storage
|
|
||||||
# for all sources during the install.
|
|
||||||
WORKDIR "./src"
|
|
||||||
|
|
||||||
# Install all global dependencies.
|
|
||||||
RUN \
|
|
||||||
dnf \
|
|
||||||
-y \
|
|
||||||
"--repofrompath=ephemeral0,${OSB_RPMREPO}" \
|
|
||||||
"--setopt=ephemeral0.gpgcheck=0" \
|
|
||||||
"--setopt=ephemeral0.priority=10" \
|
|
||||||
install "osbuild-composer-core" \
|
|
||||||
&& dnf clean all
|
|
||||||
|
|
||||||
# Copy all our local sources, so we can access them from within the container
|
|
||||||
# build. They will be cleaned in a later step.
|
|
||||||
COPY "." "."
|
|
||||||
|
|
||||||
# Prepare the runtime configuration and state.
|
|
||||||
RUN mkdir -p "../bin"
|
|
||||||
RUN mkdir -p "/etc/osbuild-composer/"
|
|
||||||
RUN mkdir -p "/run/osbuild-composer/"
|
|
||||||
RUN mkdir -p "/run/weldr/"
|
|
||||||
RUN mkdir -p "/var/cache/osbuild-composer/"
|
|
||||||
RUN mkdir -p "/var/cache/osbuild-worker/"
|
|
||||||
RUN mkdir -p "/var/lib/osbuild-composer/"
|
|
||||||
|
|
||||||
# Install all required sources into the persistent directory.
|
|
||||||
RUN cp "entrypoint.py" "../bin/"
|
|
||||||
|
|
||||||
# Leave and delete our temporary source directory.
|
|
||||||
WORKDIR ".."
|
|
||||||
RUN rm -rf "./src"
|
|
||||||
|
|
||||||
# Prepare the runtime entrypoint and empty working directory.
|
|
||||||
WORKDIR "./workdir"
|
|
||||||
ENTRYPOINT ["python3", "../bin/entrypoint.py"]
|
|
||||||
18
distribution/Dockerfile-ubi
Normal file
18
distribution/Dockerfile-ubi
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
FROM registry.access.redhat.com/ubi8/go-toolset:latest AS builder
|
||||||
|
COPY . .
|
||||||
|
ENV GOFLAGS=-mod=vendor
|
||||||
|
RUN go install ./cmd/osbuild-composer/
|
||||||
|
|
||||||
|
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest
|
||||||
|
RUN microdnf install python3
|
||||||
|
RUN mkdir -p "/usr/libexec/osbuild-composer"
|
||||||
|
RUN mkdir -p "/etc/osbuild-composer/"
|
||||||
|
RUN mkdir -p "/run/osbuild-composer/"
|
||||||
|
RUN mkdir -p "/var/cache/osbuild-composer/"
|
||||||
|
RUN mkdir -p "/var/lib/osbuild-composer/"
|
||||||
|
COPY --from=builder /opt/app-root/src/go/bin/osbuild-composer /usr/libexec/osbuild-composer/
|
||||||
|
COPY ./containers/osbuild-composer/entrypoint.py /opt/entrypoint.py
|
||||||
|
COPY ./dnf-json /usr/libexec/osbuild-composer/
|
||||||
|
|
||||||
|
EXPOSE 443 8700
|
||||||
|
ENTRYPOINT ["python3", "/opt/entrypoint.py", "--remote-worker-api", "--composer-api"]
|
||||||
|
|
@ -2,68 +2,20 @@
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
|
||||||
# Query host information.
|
|
||||||
echo "Query host"
|
echo "Query host"
|
||||||
|
|
||||||
ARCH=$(uname -m)
|
|
||||||
COMMIT=$(git rev-parse HEAD)
|
COMMIT=$(git rev-parse HEAD)
|
||||||
|
|
||||||
|
|
||||||
# Populate our build matrix.
|
|
||||||
IMG_TAGS=(
|
|
||||||
"quay.io/osbuild/osbuild-composer:f32-${COMMIT}"
|
|
||||||
"quay.io/osbuild/osbuild-composer:f33-${COMMIT}"
|
|
||||||
"quay.io/osbuild/osbuild-composer:ubi8-${COMMIT}"
|
|
||||||
)
|
|
||||||
IMG_PATHS=(
|
|
||||||
"./containers/osbuild-composer/"
|
|
||||||
"./containers/osbuild-composer/"
|
|
||||||
"./containers/osbuild-composer/"
|
|
||||||
)
|
|
||||||
IMG_FROMS=(
|
|
||||||
"docker.io/library/fedora:32"
|
|
||||||
"docker.io/library/fedora:33"
|
|
||||||
"registry.access.redhat.com/ubi8"
|
|
||||||
)
|
|
||||||
IMG_RPMREPOS=(
|
|
||||||
"http://osbuild-composer-repos.s3-website.us-east-2.amazonaws.com/osbuild-composer/fedora-32/${ARCH}/${COMMIT}"
|
|
||||||
"http://osbuild-composer-repos.s3-website.us-east-2.amazonaws.com/osbuild-composer/fedora-33/${ARCH}/${COMMIT}"
|
|
||||||
"http://osbuild-composer-repos.s3-website.us-east-2.amazonaws.com/osbuild-composer/rhel-8.3/${ARCH}/${COMMIT}"
|
|
||||||
)
|
|
||||||
IMG_COUNT=${#IMG_TAGS[*]}
|
|
||||||
|
|
||||||
|
|
||||||
# Prepare host system.
|
|
||||||
echo "Prepare host system"
|
echo "Prepare host system"
|
||||||
|
|
||||||
sudo dnf -y install podman
|
sudo dnf -y install podman
|
||||||
|
|
||||||
|
|
||||||
# Build the entire matrix.
|
echo "Build container"
|
||||||
echo "Build containers"
|
|
||||||
|
|
||||||
for ((i=0; i<IMG_COUNT; i++))
|
podman \
|
||||||
do
|
build \
|
||||||
i_tag=${IMG_TAGS[$i]}
|
"--file=distribution/Dockerfile-ubi" \
|
||||||
i_path=${IMG_PATHS[$i]}
|
"--tag=osbuild-composer:${COMMIT}" \
|
||||||
i_from=${IMG_FROMS[$i]}
|
.
|
||||||
i_rpmrepo=${IMG_RPMREPOS[$i]}
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "-- Build #$i -------------------"
|
|
||||||
echo "Tag: ${i_tag}"
|
|
||||||
echo "Arch: ${ARCH}"
|
|
||||||
echo "Path: ${i_path}"
|
|
||||||
echo "From: ${i_from}"
|
|
||||||
echo "RpmRepo: ${i_rpmrepo}"
|
|
||||||
echo "--------------------------------"
|
|
||||||
echo
|
|
||||||
|
|
||||||
podman \
|
|
||||||
build \
|
|
||||||
"--build-arg=OSB_FROM=${i_from}" \
|
|
||||||
"--build-arg=OSB_RPMREPO=${i_rpmrepo}" \
|
|
||||||
"--tag=${i_tag}" \
|
|
||||||
"${i_path}"
|
|
||||||
echo
|
|
||||||
done
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue