Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MGMT-18965: Update docker files to use universal base image #905

Open
wants to merge 1 commit into
base: release-4.16
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Dockerfile.assisted-installer
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
FROM registry.ci.openshift.org/openshift/release:golang-1.20 AS builder
FROM registry.access.redhat.com/ubi9/go-toolset:1.20 AS builder
ARG TARGETPLATFORM
ENV GOFLAGS=-mod=mod
WORKDIR /go/src/github.com/openshift/assisted-installer

# Workaround for creating build folder
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why using a workaround when we can use this image the way it's meant to?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

USER root

# Bring in the go dependencies before anything else so we can take
# advantage of caching these layers in future builds.
COPY go.mod go.mod
COPY go.sum go.sum
RUN go mod download

COPY . .
RUN TARGETPLATFORM=$TARGETPLATFORM make installer
RUN git config --global --add safe.directory '*'; \
TARGETPLATFORM=$TARGETPLATFORM make installer

FROM quay.io/centos/centos:stream9

Expand Down
42 changes: 31 additions & 11 deletions Dockerfile.assisted-installer-build
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
FROM registry.ci.openshift.org/openshift/release:golang-1.20
ENV GO111MODULE=on
FROM registry.access.redhat.com/ubi9/go-toolset:1.20 AS golang

ENV GOFLAGS=""

RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /usr/bin v1.53.2
RUN yum install -y docker && \
yum clean all
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.53.2 && \
go install golang.org/x/tools/cmd/[email protected] && \
go install github.com/onsi/ginkgo/[email protected] && \
go install github.com/golang/mock/[email protected] && \
go install gotest.tools/[email protected] && \
go install github.com/axw/gocov/gocov@latest && \
go install github.com/AlekSi/gocov-xml@latest

FROM quay.io/centos/centos:stream9

RUN dnf install -y 'dnf-command(config-manager)' && \
dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo && \
dnf install -y \
docker-ce \
docker-ce-cli \
containerd.io \
make \
git \
openssl-devel \
gcc \
&& dnf clean all

ENV GOROOT=/usr/lib/golang
ENV GOPATH=/opt/app-root/src/go
ENV PATH=$PATH:$GOROOT/bin:$GOPATH/bin

COPY --from=golang $GOPATH $GOPATH
COPY --from=golang $GOROOT $GOROOT

RUN go install golang.org/x/tools/cmd/[email protected] && \
go install github.com/onsi/ginkgo/[email protected] && \
go install github.com/golang/mock/[email protected] && \
go install gotest.tools/[email protected] && \
go install github.com/axw/gocov/gocov@latest && \
go install github.com/AlekSi/gocov-xml@latest
RUN chmod 775 -R $GOPATH && chmod 775 -R $GOROOT
22 changes: 13 additions & 9 deletions Dockerfile.assisted-installer-controller
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
FROM quay.io/openshift/origin-cli-artifacts:latest as cli-artifacts
ARG TARGETPLATFORM
RUN mkdir -p /usr/share/openshift/assisted
RUN case $TARGETPLATFORM in "") dir=linux_amd64;; *) dir=`echo $TARGETPLATFORM | sed 's@/@_@'` ;; esac ; ln /usr/share/openshift/${dir}/oc /usr/share/openshift/assisted

FROM registry.ci.openshift.org/openshift/release:golang-1.20 AS builder
FROM registry.access.redhat.com/ubi9/go-toolset:1.20 AS builder
ARG TARGETPLATFORM
ENV GOFLAGS=-mod=mod
WORKDIR /go/src/github.com/openshift/assisted-installer

# Workaround for creating build folder
USER root

# Bring in the go dependencies before anything else so we can take
# advantage of caching these layers in future builds.
COPY go.mod go.mod
COPY go.sum go.sum
RUN go mod download

COPY . .
RUN TARGETPLATFORM=$TARGETPLATFORM make controller
RUN git config --global --add safe.directory '*'; \
TARGETPLATFORM=$TARGETPLATFORM make controller

FROM quay.io/centos/centos:stream9
ARG TARGETPLATFORM

# openshift clients
RUN case $TARGETPLATFORM in "") platform=amd64;; *) platform=`echo $TARGETPLATFORM | sed 's#linux/##'` ;; esac ; \
curl -k -L -s "https://mirror.openshift.com/pub/openshift-v4/multi/clients/ocp/latest/amd64/openshift-client-linux-${platform}-rhel9.tar.gz" | tar xvz -C /usr/bin; \
chmod +x /usr/bin/oc /usr/bin/kubectl

COPY --from=cli-artifacts /usr/share/openshift/assisted/oc /usr/bin/oc
COPY --from=builder /go/src/github.com/openshift/assisted-installer/build/assisted-installer-controller /usr/bin/assisted-installer-controller

ENTRYPOINT ["/usr/bin/assisted-installer-controller"]
ENTRYPOINT ["/usr/bin/assisted-installer-controller"]
30 changes: 21 additions & 9 deletions Dockerfile.assisted-installer-controller.ocp
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.21-openshift-4.16 AS builder

FROM registry.access.redhat.com/ubi9/go-toolset:1.20 AS builder
ARG TARGETPLATFORM
ENV GOFLAGS=-mod=mod
WORKDIR /go/src/github.com/openshift/assisted-installer
ENV GOFLAGS="-mod=vendor"

# Workaround for creating build folder
USER root

# Bring in the go dependencies before anything else so we can take
# advantage of caching these layers in future builds.
COPY go.mod go.mod
COPY go.sum go.sum
RUN go mod download

COPY . .
RUN make controller
RUN git config --global --add safe.directory '*'; \
TARGETPLATFORM=$TARGETPLATFORM make controller

FROM registry.ci.openshift.org/ocp/4.16:base-rhel9
FROM quay.io/centos/centos:stream9
ARG TARGETPLATFORM

LABEL io.openshift.release.operator=true
# openshift clients
RUN case $TARGETPLATFORM in "") platform=amd64;; *) platform=`echo $TARGETPLATFORM | sed 's#linux/##'` ;; esac ; \
curl -k -L -s "https://mirror.openshift.com/pub/openshift-v4/multi/clients/ocp/latest/amd64/openshift-client-linux-${platform}-rhel9.tar.gz" | tar xvz -C /usr/bin; \
chmod +x /usr/bin/oc /usr/bin/kubectl

COPY --from=builder /go/src/github.com/openshift/assisted-installer/build/assisted-installer-controller /usr/bin/assisted-installer-controller
RUN dnf install -y --nodocs --setopt=install_weak_deps=False openshift-clients \
&& dnf clean all && rm -rf /var/cache/*

ENTRYPOINT ["/usr/bin/assisted-installer-controller"]
ENTRYPOINT ["/usr/bin/assisted-installer-controller"]