CI/CD help (OD-2227)
andrebaerlocher opened 1 year ago

I am trying to set up a CI/CD pipeline for my SvelteKit app, but I fail all the time (or at least the 29 attempts).

On localhost:8015 I have a registry running, it's working, returns a JSON when I call it via bash.

Getting the following error:

09:36:23  - FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 2)
09:36:23 ERROR: failed to solve: failed to push host.docker.internal:8015/mkife:latest: failed to do request: Head "https://host.docker.internal:8015/v2/mkife/blobs/sha256:3fbdd261fcee8c04951d283134ade98a1c64518553be9d6770268135bf087129": dial tcp 192.168.65.254:8015: connect: connection refused
09:36:23 Command execution failed (command: docker buildx build --builder onedev --pull . --push -t host.docker.internal:8015/mkife:latest -t host.docker.internal:8015/mkife:0.1.30, exit code: 1)

My buildpec.yml:

version: 38
jobs:
- name: Build SvelteKit App
  steps:
  - !SetBuildVersionStep
    name: Set Build Version
    buildVersion: 0.1.@build_number@
    condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
  - !CheckoutStep
    name: CheckoutStep
    cloneCredential: !DefaultCredential {}
    withLfs: false
    withSubmodules: false
    condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
  - !CommandStep
    name: NPMCommandStep
    runInContainer: true
    image: node:latest
    interpreter: !DefaultInterpreter
      commands: |
        npm install
        npm run test
        npm run build
    useTTY: true
    condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
  - !BuildImageStep
    name: BuildImageStep
    buildPath: .
    output: !RegistryOutput
      tags: host.docker.internal:8015/mkife:latest host.docker.internal:8015/mkife:@build_version@
    condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
  - !CommandStep
    name: CommandStep
    runInContainer: true
    image: mkife:latest
    interpreter: !DefaultInterpreter
      commands: |
        docker stop mkife || true
        docker rm mkife || true
        docker run -d --name mkife -p 8013:8013 192.168.1.13/mkife/mkife:latest
    useTTY: true
    condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL
  retryCondition: never
  maxRetries: 3
  retryDelay: 30
  timeout: 14400

I tried it with the IP address, tunnelled via CapRover with HTTPS, host.docker.internal, and localhost.

In Docker Desktop (running a Mac) I have set the insecure registries:

{
  "builder": {
    "gc": {
      "defaultKeepStorage": "20GB",
      "enabled": true
    }
  },
  "experimental": false,
  "insecure-registries": [
    "localhost:8015",
    "[My IP]:8015"
  ]
}

Basically, what I want to do (and currently failing miserably...):

  1. Push to a branch
  2. Build a docker image
  3. Replace old docker container with the new version, still exposing the same port

So, if anyone was kind enough to help, that would be much appreciated!

  • Robin Shen commented 1 year ago

    Is OneDev server running directly on your Mac, or via docker container? And is the build job running with server docker executor, or remote docker executor?

  • andrebaerlocher commented 1 year ago

    OneDev is running in a docker container. I do not know what you mean by the second question, sorry. The buildx is set by Docker Desktop, the build job itself is via .onedev-buildspec.yml in the project itself and built when I press the button (sorry for the noobish description!)

  • Robin Shen commented 1 year ago

    I do not know what you mean by the second question

    I mean if you are installing OneDev agent and running jobs with agent. Seems that you only uses server, which is totally fine.

    I did a test at my side, and it works. What I am doing:

    1. Make sure to use correct server url in Administration / System Settings. This url should be accessible from jobs running within a docker container. For testing purpose, I specified it as http://<mac ip address>:6610
    2. Tags property of build image step should be specified using same host as server url above. I specified it as <mac ip address>:6610/test/myrepo for my testing
    3. Since I am testing with http protocol, docker should be configured to allow insecure connections in two places as explained here: https://docs.onedev.io/tutorials/cicd/insecure-docker-registry. For docker daemon part, it can be configured via docker desktop.
  • Robin Shen commented 1 year ago

    Also for build image step, credential to the built-in docker registry should be specified in more settings. Also make sure to use same host as server url there.

  • Robin Shen changed state to 'Closed' 1 year ago
    Previous Value Current Value
    Open
    Closed
  • Robin Shen commented 1 year ago

    Feel free to reopen if there is more info.

issue 1/1
Type
Question
Priority
Normal
Assignee
Labels
No labels
Issue Votes (0)
Watchers (2)
Reference
OD-2227
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover