Skip to content

Instantly share code, notes, and snippets.

@sparkoo
Created September 3, 2021 11:59
Show Gist options
  • Save sparkoo/e94450ef4dcdfe5135d0ab52cc2c577f to your computer and use it in GitHub Desktop.
Save sparkoo/e94450ef4dcdfe5135d0ab52cc2c577f to your computer and use it in GitHub Desktop.
Che Operator Dockerfile patch
diff --git a/Dockerfile b/Dockerfile
index 3a17512b..50c53173 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -26,6 +26,20 @@ RUN mkdir -p $GOPATH/restic && \
curl -sSLo /tmp/asset-header-rewrite-traefik-plugin.zip https://api.github.com/repos/che-incubator/header-rewrite-traefik-plugin/zipball/${DEV_HEADER_REWRITE_TRAEFIK_PLUGIN}
WORKDIR /che-operator
+
+RUN unzip /tmp/asset-devworkspace-operator.zip */deploy/deployment/* -d /tmp && \
+ mkdir -p /tmp/devworkspace-operator/templates/ && \
+ mv /tmp/devfile-devworkspace-operator-*/deploy /tmp/devworkspace-operator/templates/
+
+RUN unzip /tmp/asset-header-rewrite-traefik-plugin.zip -d /tmp && \
+ mkdir -p /tmp/header-rewrite-traefik-plugin && \
+ mv /tmp/*-header-rewrite-traefik-plugin-*/headerRewrite.go /tmp/*-header-rewrite-traefik-plugin-*/.traefik.yml /tmp/header-rewrite-traefik-plugin
+
+# Build restic. Needed for backup / restore capabilities
+RUN cd $GOPATH/restic && \
+ export ARCH="$(uname -m)" && if [[ ${ARCH} == "x86_64" ]]; then export ARCH="amd64"; elif [[ ${ARCH} == "aarch64" ]]; then export ARCH="arm64"; fi && \
+ GOOS=linux GOARCH=${ARCH} CGO_ENABLED=0 go build -mod=vendor -o /tmp/restic/restic ./cmd/restic
+
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
@@ -33,45 +47,30 @@ COPY go.sum go.sum
# Copy the go source
COPY main.go main.go
COPY api/ api/
-COPY controllers/ controllers/
COPY templates/ templates/
-COPY pkg/ pkg/
COPY vendor/ vendor/
COPY mocks/ mocks/
COPY config/ config/
+COPY pkg/ pkg/
+COPY controllers/ controllers/
# build operator
RUN export ARCH="$(uname -m)" && if [[ ${ARCH} == "x86_64" ]]; then export ARCH="amd64"; elif [[ ${ARCH} == "aarch64" ]]; then export ARCH="arm64"; fi && \
- export MOCK_API=true && \
- go test -mod=vendor -v ./... && \
CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} GO111MODULE=on go build -mod=vendor -a -o che-operator main.go
-RUN unzip /tmp/asset-devworkspace-operator.zip */deploy/deployment/* -d /tmp && \
- mkdir -p /tmp/devworkspace-operator/templates/ && \
- mv /tmp/devfile-devworkspace-operator-*/deploy /tmp/devworkspace-operator/templates/
-
-RUN unzip /tmp/asset-header-rewrite-traefik-plugin.zip -d /tmp && \
- mkdir -p /tmp/header-rewrite-traefik-plugin && \
- mv /tmp/*-header-rewrite-traefik-plugin-*/headerRewrite.go /tmp/*-header-rewrite-traefik-plugin-*/.traefik.yml /tmp/header-rewrite-traefik-plugin
-
-# Build restic. Needed for backup / restore capabilities
-RUN cd $GOPATH/restic && \
- export ARCH="$(uname -m)" && if [[ ${ARCH} == "x86_64" ]]; then export ARCH="amd64"; elif [[ ${ARCH} == "aarch64" ]]; then export ARCH="arm64"; fi && \
- GOOS=linux GOARCH=${ARCH} CGO_ENABLED=0 go build -mod=vendor -o /tmp/restic/restic ./cmd/restic
-
# https://access.redhat.com/containers/?tab=tags#/registry.access.redhat.com/ubi8-minimal
FROM registry.access.redhat.com/ubi8-minimal:8.4-208
-COPY --from=builder /che-operator/che-operator /manager
-COPY --from=builder /che-operator/templates/*.sh /tmp/
+# install httpd-tools for /usr/bin/htpasswd
+RUN microdnf install -y httpd-tools && microdnf -y update && microdnf -y clean all && rm -rf /var/cache/yum && echo "Installed Packages" && rpm -qa | sort -V && echo "End Of Installed Packages" && \
+ mkdir ~/.ssh && chmod 0766 ~/.ssh
+
COPY --from=builder /tmp/devworkspace-operator/templates/deploy /tmp/devworkspace-operator/templates
COPY --from=builder /tmp/header-rewrite-traefik-plugin /tmp/header-rewrite-traefik-plugin
COPY --from=builder /tmp/restic/restic /usr/local/bin/restic
COPY --from=builder /go/restic/LICENSE /usr/local/bin/restic-LICENSE.txt
-
-# install httpd-tools for /usr/bin/htpasswd
-RUN microdnf install -y httpd-tools && microdnf -y update && microdnf -y clean all && rm -rf /var/cache/yum && echo "Installed Packages" && rpm -qa | sort -V && echo "End Of Installed Packages" && \
- mkdir ~/.ssh && chmod 0766 ~/.ssh
+COPY --from=builder /che-operator/templates/*.sh /tmp/
+COPY --from=builder /che-operator/che-operator /manager
WORKDIR /
USER 65532:65532
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment