Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ linters:
- unconvert
- gci
- goimports
- scopelint
- exportloopref

linters-settings:
govet:
Expand Down
45 changes: 25 additions & 20 deletions Dockerfile.assisted-service
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
ARG BASE_TAG=stream9
ARG RHEL_VERSION=9

FROM registry.access.redhat.com/ubi$RHEL_VERSION/go-toolset:1.20 AS golang

ADD . /app
WORKDIR /app

# Licenses
RUN go install github.com/google/go-licenses@v1.6.0
RUN ${HOME}/go/bin/go-licenses save --save_path /tmp/licenses ./...

# Build binaries
FROM quay.io/centos/centos:$BASE_TAG as builder
Comment thread
danmanor marked this conversation as resolved.
FROM quay.io/centos/centos:stream$RHEL_VERSION as builder
Comment thread
danmanor marked this conversation as resolved.

COPY hack/container_build_scripts/install_build_deps.sh .
COPY hack/container_build_scripts/utils.sh .
ARG BASE_TAG
RUN ./install_build_deps.sh $BASE_TAG
COPY --from=registry.ci.openshift.org/openshift/release:golang-1.20 /usr/local/go /usr/local/go
ARG RHEL_VERSION
RUN ./install_build_deps.sh $RHEL_VERSION

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

ENV GOROOT=/usr/local/go
ENV PATH=$PATH:$GOROOT/bin
COPY --from=golang $GOPATH $GOPATH
COPY --from=golang $GOROOT $GOROOT

RUN chmod 775 -R $GOPATH && chmod 775 -R $GOROOT

WORKDIR /assisted-service/

Expand All @@ -29,17 +43,8 @@ RUN cd ./cmd/operator && CGO_ENABLED=1 GOFLAGS="" GO111MODULE=on go build -o /bu
RUN cd ./cmd/webadmission && CGO_ENABLED=1 GOFLAGS="" GO111MODULE=on go build -o /build/assisted-service-admission
RUN cd ./cmd/agentbasedinstaller/client && CGO_ENABLED=1 GOFLAGS="" GO111MODULE=on go build -o /build/agent-installer-client

# Licenses
FROM registry.access.redhat.com/ubi9/go-toolset:1.18 AS licenses

ADD . /app
WORKDIR /app

RUN go install github.com/google/go-licenses@v1.6.0
RUN ${HOME}/go/bin/go-licenses save --save_path /tmp/licenses ./...

# Create final image
FROM quay.io/centos/centos:$BASE_TAG
FROM quay.io/centos/centos:stream$RHEL_VERSION

ARG release=main
ARG version=latest
Expand All @@ -56,12 +61,12 @@ LABEL url https://github.com/openshift/assisted-service
LABEL vendor "Red Hat, Inc."
LABEL maintainer "Red Hat"

COPY --from=licenses /tmp/licenses /licenses
COPY --from=golang /tmp/licenses /licenses

COPY hack/container_build_scripts/replace_dnf_repositories_ref_if_needed.sh .
COPY hack/container_build_scripts/utils.sh .
ARG BASE_TAG
RUN ./replace_dnf_repositories_ref_if_needed.sh $BASE_TAG
ARG RHEL_VERSION
RUN ./replace_dnf_repositories_ref_if_needed.sh $RHEL_VERSION

# multiarch images need it till WRKLDS-222 and https://bugzilla.redhat.com/show_bug.cgi?id=2111537 are fixed
RUN dnf install -y --setopt=install_weak_deps=False skopeo
Expand Down
20 changes: 12 additions & 8 deletions Dockerfile.assisted-service-build
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
FROM registry.ci.openshift.org/openshift/release:golang-1.20 AS golang
RUN chmod g+xw -R /usr/local/go
FROM registry.access.redhat.com/ubi9/go-toolset:1.20 AS golang

RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.53.2
RUN go install gotest.tools/gotestsum@latest

FROM quay.io/centos/centos:stream9

ENV GOPATH=/go
ENV GOROOT=/usr/local/go
ENV GOROOT=/usr/lib/golang
ENV GOPATH=/opt/app-root/src/go
ENV VIRTUAL_ENV=/opt/venv
# A directory in the path with write permission even for non-root users
ENV TOOLS=/tools/
ENV PATH="$VIRTUAL_ENV/bin:$GOROOT/bin:$GOPATH/bin:$TOOLS:$PATH"

RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /usr/bin v1.53.2
COPY --from=golang $GOPATH $GOPATH
COPY --from=golang $GOROOT $GOROOT

RUN chmod 775 -R $GOPATH && chmod 775 -R $GOROOT

# TODO: Replace with version 0.30.4 once it is released.
#
# We need version 5d0a00d of go-swagger because it is the first that contains
Expand All @@ -27,15 +33,13 @@ RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/i
COPY --from=quay.io/goswagger/swagger:sha-5d0a00d /usr/bin/swagger /usr/bin/goswagger

COPY --from=quay.io/edge-infrastructure/swagger-codegen-cli:2.4.18 /opt/swagger-codegen-cli /opt/swagger-codegen-cli
COPY --from=golang /usr/bin/gotestsum /usr/bin/make /usr/bin/
COPY --from=golang /usr/local/go /usr/local/go
COPY --from=quay.io/openshift/origin-cli:latest /usr/bin/oc /usr/bin
COPY --from=quay.io/operator-framework/upstream-opm-builder:v1.16.1 /bin/opm /bin
COPY --from=registry.k8s.io/kustomize/kustomize:v4.3.0 /app/kustomize /usr/bin/
COPY --from=quay.io/coreos/shellcheck-alpine:v0.5.0 /bin/shellcheck /usr/bin/shellcheck

RUN dnf install -y --enablerepo=crb \
openssl postgresql nmstate-devel sqlite gcc genisoimage git libvirt-client libvirt-devel java && \
openssl openssl-devel postgresql nmstate-devel sqlite gcc genisoimage git libvirt-client libvirt-devel java make && \
dnf clean all

# Git checks if the user that owns the files on the filesystem match the
Expand Down
21 changes: 16 additions & 5 deletions Dockerfile.assisted-service-debug
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
ARG SERVICE=quay.io/edge-infrastructure/assisted-service:latest
FROM registry.ci.openshift.org/openshift/release:golang-1.20 AS download_dlv
FROM registry.access.redhat.com/ubi9/go-toolset:1.20 AS golang

RUN GOFLAGS=-mod=mod go install github.com/go-delve/delve/cmd/dlv@v1.21.2

FROM $SERVICE
FROM quay.io/centos/centos:stream9

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 chmod 775 -R $GOPATH && chmod 775 -R $GOROOT

ARG DEBUG_SERVICE_PORT=40000
COPY --from=download_dlv /go/bin/dlv /
EXPOSE 8090 $DEBUG_SERVICE_PORT

COPY assisted-service /assisted-service
COPY assisted-service-operator /assisted-service-operator
CMD ["/dlv", "--listen=:40000", "--headless=true", "--continue", "--api-version=2", "--accept-multiclient", "exec", "/assisted-service"]

CMD ["dlv", "--listen=:40000", "--headless=true", "--continue", "--api-version=2", "--accept-multiclient", "exec", "/assisted-service"]
18 changes: 11 additions & 7 deletions ci-images/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
FROM registry.access.redhat.com/ubi9/go-toolset:1.20 AS golang

RUN go install gotest.tools/gotestsum@latest

FROM quay.io/centos/centos:stream9

RUN dnf install --enablerepo=crb -y \
git unzip make gcc which nmstate-devel python3
git unzip make gcc which nmstate-devel python3 openssl-devel

# Git checks if the user that owns the files on the filesystem match the
# current user. We need to disable this check because tests in Prow are
# running with a random user.
RUN git config --system --add safe.directory '*'

COPY --from=registry.ci.openshift.org/openshift/release:golang-1.20 /usr/local/go /usr/local/go
COPY --from=registry.ci.openshift.org/openshift/release:golang-1.20 /usr/bin/gotestsum /usr/bin/make /usr/bin/

ENV GOPATH=/go
ENV GOROOT=/usr/local/go
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

COPY . /assisted-service/
WORKDIR /assisted-service/

RUN go mod tidy && go mod vendor

RUN chmod 775 -R $GOPATH && chmod 775 -R $(go env GOROOT) && chmod 775 -R /assisted-service/ && \
RUN chmod 775 -R $GOPATH && chmod 775 -R $GOROOT && chmod 775 -R /assisted-service/ && \
mkdir /.cache && chmod 775 -R /.cache
1 change: 0 additions & 1 deletion ci-images/Dockerfile.code-generation
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ ENV PATH="$VIRTUAL_ENV/bin:$PATH"
#
# https://issues.redhat.com/browse/MGMT-12697
COPY --from=quay.io/goswagger/swagger:sha-5d0a00d /usr/bin/swagger /usr/bin/goswagger

COPY --from=registry.k8s.io/kustomize/kustomize:v4.3.0 /app/kustomize /usr/bin/

RUN cd / && /assisted-service/hack/setup_env.sh spectral && \
Expand Down
6 changes: 3 additions & 3 deletions hack/container_build_scripts/install_build_deps.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash

tag=${1}
rhel_version=${1}
repo=crb

if [ "$tag" = "stream8" ]; then
if [ "$rhel_version" = "8" ]; then
repo=powertools
source ./utils.sh
replace_dnf_repositories_ref
fi

dnf install --enablerepo=$repo -y gcc git nmstate-devel && dnf clean all
dnf install --enablerepo=$repo -y gcc git nmstate-devel openssl-devel && dnf clean all
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

tag=${1}
rhel_version=${1}

if [ "$tag" = "stream8" ]; then
if [ "$rhel_version" = "8" ]; then
source ./utils.sh
replace_dnf_repositories_ref
fi