Skip to content

Commit e0fb83d

Browse files
committed
MGMT-15963: Upgrade dockefiles to use centos:stream9 and build with podman
The current Dockerfile builds in this project are broken due to recent deprecation centos images. This PR aims to address that by upgrading the images we use. Additionally the build system is made more consistent with the podman compliant build that we use for assisted. The host podman is passed to skipper so that the container may use podman-remote to build the project.
1 parent a77957e commit e0fb83d

6 files changed

+37
-15
lines changed

Dockerfile.assisted-swarm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM quay.io/centos/centos:stream8
1+
FROM quay.io/centos/centos:stream9
22

33
ARG WORK_DIR=/data
44

Dockerfile.assisted-swarm-build

+21-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
1-
FROM registry.ci.openshift.org/openshift/release:golang-1.17
2-
ENV GO111MODULE=on
3-
ENV GOFLAGS=""
1+
FROM registry.ci.openshift.org/openshift/release:golang-1.20 AS golang
2+
RUN chmod g+xw -R /usr/local/go
43

5-
COPY --from=quay.io/goswagger/swagger:v0.28.0 /usr/bin/swagger /usr/bin/goswagger
6-
COPY --from=quay.io/edge-infrastructure/swagger-codegen-cli:2.4.18 /opt/swagger-codegen-cli /opt/swagger-codegen-cli
4+
FROM quay.io/centos/centos:stream9
75

8-
USER 0
6+
ENV GOPATH=/go
7+
ENV GOROOT=/usr/local/go
8+
ENV VIRTUAL_ENV=/opt/venv
9+
# A directory in the path with write permission even for non-root users
10+
ENV TOOLS=/tools/
11+
ENV PATH="$VIRTUAL_ENV/bin:$GOROOT/bin:$GOPATH/bin:$TOOLS:$PATH"
912

10-
RUN curl -L https://github.com/stoplightio/spectral/releases/download/v5.9.1/spectral-linux -o /usr/local/bin/spectral && chmod +x /usr/local/bin/spectral
13+
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /usr/bin v1.53.2
14+
COPY --from=quay.io/goswagger/swagger:sha-5d0a00d /usr/bin/swagger /usr/bin/goswagger
1115

12-
RUN yum install -y --setopt=skip_missing_names_on_install=False docker podman
13-
RUN mkdir build && chmod g+xw -R build/
16+
COPY --from=quay.io/edge-infrastructure/swagger-codegen-cli:2.4.18 /opt/swagger-codegen-cli /opt/swagger-codegen-cli
17+
COPY --from=golang /usr/bin/gotestsum /usr/bin/make /usr/bin/
18+
COPY --from=golang /usr/local/go /usr/local/go
19+
COPY --from=quay.io/openshift/origin-cli:latest /usr/bin/oc /usr/bin
20+
COPY --from=quay.io/operator-framework/upstream-opm-builder:v1.16.1 /bin/opm /bin
21+
COPY --from=registry.k8s.io/kustomize/kustomize:v4.3.0 /app/kustomize /usr/bin/
22+
COPY --from=quay.io/coreos/shellcheck-alpine:v0.5.0 /bin/shellcheck /usr/bin/shellcheck
1423

15-
RUN chmod g+xw -R .
24+
COPY ./hack/setup_env.sh ./
25+
RUN ./setup_env.sh podman_remote && \
26+
dnf clean all

Makefile

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
ASSISTED_SWARM = build/assisted-swarm
2-
CONTAINER_COMMAND := $(or $(CONTAINER_COMMAND),docker)
2+
CONTAINER_COMMAND := podman-remote
33
IMAGE := $(or $(IMAGE),quay.io/oamizur/assisted-swarm:latest)
4-
ifeq ($(CONTAINER_COMMAND), docker)
5-
CONTAINER_COMMAND = $(shell docker -v | cut -f1 -d' ' | tr '[:upper:]' '[:lower:]')
6-
endif
74

85
.PHONY: build-image generate clean
96

hack/setup_env.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function podman_remote() {
2+
curl --retry 5 --connect-timeout 30 -L https://github.com/containers/podman/releases/download/v4.1.1/podman-remote-static.tar.gz -o "podman-remote.tar.gz"
3+
tar -zxvf podman-remote.tar.gz
4+
mv podman-remote-static /usr/local/bin/podman-remote
5+
rm -f podman-remote.tar.gz
6+
}
7+
8+
"$@"

skipper.env

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
IMAGE

skipper.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ volumes:
66
- $HOME/.cache/go-build:/go/pkg/mod
77
# Registry credentials
88
- $HOME/.docker/:$HOME/.docker
9+
# Podman socket for podman-remote
10+
- $(podman info --format "{{.Host.RemoteSocket.Path}}" 2> /dev/null || echo "$XDG_RUNTIME_DIR/podman/podman.sock"):/run/podman/podman.sock
911

1012
containers:
1113
assisted-swarm-build: Dockerfile.assisted-swarm-build
14+
env_file:
15+
- skipper.env
1216
env:
1317
GOCACHE: "/go/pkg/mod"
18+
CONTAINER_HOST: unix://run/podman/podman.sock

0 commit comments

Comments
 (0)