Новое приложение Openshift не работает для dockerfile - PullRequest
1 голос
/ 05 мая 2020

Я пытаюсь использовать CLI для развертывания нового приложения в Openshift. Когда я использую GUI и нажимаю «Построить из файла docker», все работает нормально. Но когда я использую CLI, этого не происходит.

Это файлы в моем репо:

Dockerfile

FROM golang:1.11-alpine
RUN mkdir /app
COPY main.go /app
WORKDIR /app
RUN go build -o main .
EXPOSE 8080 8888
USER 1001
ENTRYPOINT ["/app/main"]

main. go

package main

import (
    "fmt"
    "net/http"
)

func helloHandler(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintln(w, "<h1>Hello OpenShift! Updated build</h1>")
}

func listenAndServe(port string) {
    fmt.Printf("serving on %s\n", port)
    err := http.ListenAndServe(":"+port, nil)
    if err != nil {
        panic("ListenAndServe: " + err.Error())
    }
}

func main() {
    http.HandleFunc("/", helloHandler)
    go listenAndServe("8080")
    select {}
}

Я следую этому артикул . Я скопировал файлы в свое частное репо и использовал секретный код для клонирования. Как уже упоминалось, я использовал команду вместе с секретным кодом источника

oc new-app https://git.abcd.corp.mycompany.com/12345/openshift-trail.git#development --source-secret=my-secret --name=demo-blah

Это дает мне следующую ошибку:

error: unable to load template file "https://git.abcd.corp.mycompany.com/12345/openshift-trail.git#development": error parsing https://git.abcd.corp.mycompany.com/12345/openshift-trail.git#development: error converting YAML to JSON: yaml: line 3: mapping values are not allowed in this context
error: git ls-remote failed with: fatal: unable to access 'https://git.abcd.corp.mycompany.com/12345/openshift-trail.git/': Problem with the SSL CA cert (path? access rights?);  local file access failed with: stat https://git.abcd.corp.mycompany.com/12345/openshift-trail.git#development: no such file or directory
error: unable to locate any images in image streams, templates loaded in accessible projects, template files, local docker images with name "https://git.abcd.corp.mycompany.com/12345/openshift-trail.git#development"

Argument 'https://git.abcd.corp.mycompany.com/12345/openshift-trail.git#development' was classified as an image, image~source, or loaded template reference.

The 'oc new-app' command will match arguments to the following types:

  1. Images tagged into image streams in the current project or the 'openshift' project
     - if you don't specify a tag, we'll add ':latest'
  2. Images in the Docker Hub, on remote registries, or on the local Docker engine
  3. Templates in the current project or the 'openshift' project
  4. Git repository URLs or local paths that point to Git repositories

--allow-missing-images can be used to point to an image that does not exist yet.

Согласно openshift doco, он говорит, что если в репо есть файл Dockerfile, он должен автоматически его обнаружить. Но здесь я получаю странную ошибку, в которой не могу разобраться. Любая помощь приветствуется.

1 Ответ

1 голос
/ 05 мая 2020

Вы можете просто собрать его как обычный файл докеров на своем компьютере и загрузить в реестр Docker, а затем развернуть его в openshift из удаленного реестра или даже поместить sh во встроенный реестр на openshift.

Я думаю, что команда, которую вы ищете, вероятно,


    oc new-build

Эта статья может помочь:

https://dzone.com/articles/4-ways-to-build-applications-in-openshift-1

...