Skip to content

Commit

Permalink
Dockerfile: remove middle stage (RedHatInsights#2634)
Browse files Browse the repository at this point in the history
Signed-off-by: Jonathan Holloway <jholloway@redhat.com>
  • Loading branch information
loadtheaccumulator authored Jul 24, 2024
1 parent 26864ff commit 51b13ee
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 29 deletions.
36 changes: 7 additions & 29 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,41 +32,20 @@ RUN go build -o /go/bin/edge-api-ibvents cmd/kafka/main.go
# Build utilities binaries
RUN go build -o /go/bin/edge-api-cleanup cmd/cleanup/main.go

######################################
# STEP 2: build the dependencies image
######################################
FROM registry.access.redhat.com/ubi8/ubi AS ubi-micro-build
RUN mkdir -p /mnt/rootfs
# This step is needed for subscription-manager refresh.
RUN yum install coreutils-single -y
RUN yum install --installroot /mnt/rootfs \
coreutils-single glibc-minimal-langpack \
pykickstart mtools xorriso genisoimage \
syslinux isomd5sum file ostree \
--releasever 8 --setopt \
install_weak_deps=false --nodocs -y; \
yum --installroot /mnt/rootfs clean all
RUN rm -rf /mnt/rootfs/var/cache/* /mnt/rootfs/var/log/dnf* /mnt/rootfs/var/log/yum.*

####################################
# STEP 3: build edge-api micro image
# STEP 2: build edge-api minimal image
####################################
FROM scratch
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest
LABEL maintainer="Red Hat, Inc."
LABEL com.redhat.component="ubi8-micro-container"

# label for EULA
LABEL com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI"

# labels for container catalog
LABEL summary="edge-api micro image"
LABEL summary="edge-api minimal image"
LABEL description="The edge-api project is an API server for fleet edge management capabilities."
LABEL io.k8s.display-name="edge-api-micro"
LABEL io.k8s.display-name="edge-api-minimal"

COPY --from=ubi-micro-build /mnt/rootfs/ /
COPY --from=ubi-micro-build /etc/yum.repos.d/ubi.repo /etc/yum.repos.d/ubi.repo

ENV MTOOLS_SKIP_CHECK=1
ENV EDGE_API_WORKSPACE /src/github.com/RedHatInsights/edge-api

# Copy the edge-api binaries into the image.
Expand All @@ -80,10 +59,9 @@ COPY --from=edge-builder /go/bin/edge-api-ibvents /usr/bin
COPY --from=edge-builder /go/bin/edge-api-cleanup /usr/bin
COPY --from=edge-builder ${EDGE_API_WORKSPACE}/cmd/spec/openapi.json /var/tmp

# kickstart inject requirements
COPY --from=edge-builder ${EDGE_API_WORKSPACE}/scripts/fleetkick.sh /usr/local/bin
RUN chmod +x /usr/local/bin/fleetkick.sh
COPY --from=edge-builder ${EDGE_API_WORKSPACE}/templates/templateKickstart.ks /usr/local/etc
RUN microdnf install -y coreutils-single glibc-minimal-langpack \
pykickstart mtools xorriso genisoimage \
syslinux isomd5sum file ostree && microdnf clean all

# template to playbook dispatcher
COPY --from=edge-builder ${EDGE_API_WORKSPACE}/templates/template_playbook_dispatcher_ostree_upgrade_payload.yml /usr/local/etc
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ OCI_TOOL=$(shell command -v podman || command -v docker)
IMAGE_TAG=$(shell git rev-parse --short=7 HEAD)

EDGE_API_CONTAINER_TAG="quay.io/cloudservices/edge-api:$(IMAGE_TAG)"
EDGE_API_DEV_CONTAINER_TAG="localhost/edge-api:dev-$(IMAGE_TAG)"

TEST_CONTAINER_TAG="quay.io/fleet-management/libfdo-data:$(IMAGE_TAG)"

Expand Down Expand Up @@ -70,6 +71,13 @@ build-test-container:
--tag "$(TEST_CONTAINER_TAG)" \
.

build-dev-container:
$(OCI_TOOL) build \
--file "$(CONTAINERFILE_NAME)" \
--no-cache \
--tag "$(EDGE_API_DEV_CONTAINER_TAG)" \
.

build:
mkdir -p build 2>/dev/null
go build $(BUILD_FLAGS) -o build/edge-api .
Expand Down

0 comments on commit 51b13ee

Please sign in to comment.