Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment is not halted if there is no Dockerfile #237

Closed
bohdan-shulha opened this issue Apr 20, 2023 · 3 comments
Closed

Deployment is not halted if there is no Dockerfile #237

bohdan-shulha opened this issue Apr 20, 2023 · 3 comments

Comments

@bohdan-shulha
Copy link

Hi team,

mrsk doesn't check whether Dockerfile exists or not.

In my project, Dockerfile is located not in the root folder and I have forgotten to tell it to mrsk.

However, non-existent Dockerfile didn't stop mrsk to attempt deployment. Ofc, it failed, but the reason was not an easy one to find. I suspect that output will look like the same if one makes a typo in config for the Dockerfile path variable.

" > mrsk_lock/details on 165.22.1.24
 DEBUG [73b0bb84] Command: /usr/bin/env mkdir mrsk_lock && echo "TG9ja2VkIGJ5OiBCb2hkYW4gU2h1bGhhIGF0IDIwMjMtMDQtMjAgMTE6NDI6
MTYgVVRDClZlcnNpb246IDgyYmUxNTZlMDY3MGQ1N2Q5M2M4ZWNlY2ZkNGYz
YWYxMDUzYWQ0YjMKTWVzc2FnZTogQXV0b21hdGljIGRlcGxveSBsb2Nr
" > mrsk_lock/details
  INFO [73b0bb84] Finished in 1.268 seconds with exit status 0 (successful).
Ensure curl and Docker are installed...
  INFO [4f0dc2f2] Running which curl on 165.22.1.24
 DEBUG [4f0dc2f2] Command: which curl
 DEBUG [4f0dc2f2]       /usr/bin/curl
  INFO [4f0dc2f2] Finished in 0.243 seconds with exit status 0 (successful).
  INFO [7f10be90] Running which docker on 165.22.1.24
 DEBUG [7f10be90] Command: which docker
 DEBUG [7f10be90]       /usr/bin/docker
  INFO [7f10be90] Finished in 0.244 seconds with exit status 0 (successful).
Log into image registry...
  INFO [c5ae1998] Running docker login registry.digitalocean.com -u [REDACTED] -p [REDACTED] on localhost
 DEBUG [c5ae1998] Command: docker login registry.digitalocean.com -u [REDACTED] -p [REDACTED]
 DEBUG [c5ae1998]       WARNING! Using --password via the CLI is insecure. Use --password-stdin.
 DEBUG [c5ae1998]       WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
 DEBUG [c5ae1998]       Configure a credential helper to remove this warning. See
 DEBUG [c5ae1998]       https://docs.docker.com/engine/reference/commandline/login/#credentials-store
 DEBUG [c5ae1998]       
 DEBUG [c5ae1998]       Login Succeeded
  INFO [c5ae1998] Finished in 1.184 seconds with exit status 0 (successful).
  INFO [158eb3cf] Running docker login registry.digitalocean.com -u [REDACTED] -p [REDACTED] on 165.22.1.24
 DEBUG [158eb3cf] Command: docker login registry.digitalocean.com -u [REDACTED] -p [REDACTED]
 DEBUG [158eb3cf]       WARNING! Using --password via the CLI is insecure. Use --password-stdin.
 DEBUG [158eb3cf]       WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

 DEBUG [158eb3cf]       Login Succeeded
  INFO [158eb3cf] Finished in 0.434 seconds with exit status 0 (successful).
Build and push app image...
  INFO [2315b4ec] Running docker build -t registry.digitalocean.com/e-sportstats/front-office:82be156e0670d57d93c8ececfd4f3af1053ad4b3 -t registry.digitalocean.com/e-sportstats/front-office:latest --label service="front-office" --file Dockerfile . && docker push registry.digitalocean.com/e-sportstats/front-office:82be156e0670d57d93c8ececfd4f3af1053ad4b3 && docker push registry.digitalocean.com/e-sportstats/front-office:latest on localhost
 DEBUG [2315b4ec] Command: docker build -t registry.digitalocean.com/e-sportstats/front-office:82be156e0670d57d93c8ececfd4f3af1053ad4b3 -t registry.digitalocean.com/e-sportstats/front-office:latest --label service="front-office" --file Dockerfile . && docker push registry.digitalocean.com/e-sportstats/front-office:82be156e0670d57d93c8ececfd4f3af1053ad4b3 && docker push registry.digitalocean.com/e-sportstats/front-office:latest
 DEBUG [2315b4ec]       #1 [internal] load build definition from Dockerfile
 DEBUG [2315b4ec]       #1 sha256:17262e9e47efa268c03ff93f7e48afcd8ef6be27ebccc996934a395d9d1b1586
 DEBUG [2315b4ec]       #1 transferring dockerfile: 2B 0.0s done
 DEBUG [2315b4ec]       #1 DONE 0.1s
 DEBUG [2315b4ec]       
 DEBUG [2315b4ec]       #2 [internal] load .dockerignore
 DEBUG [2315b4ec]       #2 sha256:998931b5f40c38d02dab6fc6f9e35ef359494519e5914a7c603a2eebfd2dc0d6
 DEBUG [2315b4ec]       #2 transferring context: 2B done
 DEBUG [2315b4ec]       #2 DONE 0.0s
 DEBUG [2315b4ec]       failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount2827601602/Dockerfile: no such file or directory
 ERROR Missing compatible builder, so creating a new one first
 DEBUG Using builder: native
  INFO [3e5a8c17] Running /usr/bin/env  on localhost
 DEBUG [3e5a8c17] Command: /usr/bin/env 
 DEBUG [3e5a8c17]       PATH=/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
 DEBUG [3e5a8c17]       HOSTNAME=5371189788cb
 DEBUG [3e5a8c17]       TERM=xterm
 DEBUG [3e5a8c17]       SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock
 DEBUG [3e5a8c17]       LANG=C.UTF-8
 DEBUG [3e5a8c17]       RUBY_MAJOR=3.2
 DEBUG [3e5a8c17]       RUBY_VERSION=3.2.0
 DEBUG [3e5a8c17]       RUBY_DOWNLOAD_SHA256=d2f4577306e6dd932259693233141e5c3ec13622c95b75996541b8d5b68b28b4
 DEBUG [3e5a8c17]       GEM_HOME=/usr/local/bundle
 DEBUG [3e5a8c17]       BUNDLE_SILENCE_ROOT_WARNING=1
 DEBUG [3e5a8c17]       BUNDLE_APP_CONFIG=/usr/local/bundle
 DEBUG [3e5a8c17]       HOME=/root
 DEBUG [3e5a8c17]       MRSK_DOCKER_REGISTRY_TOKEN=$realtoken
 DEBUG [3e5a8c17]       VERBOSE=1
  INFO [3e5a8c17] Finished in 0.002 seconds with exit status 0 (successful).
 DEBUG [52b450cd] Running /usr/bin/env echo '[2023-04-20 11:42:20] [root] Pulled image with version 82be156e0670d57d93c8ececfd4f3af1053ad4b3' >> mrsk-front-office-audit.log on 165.22.1.24
 DEBUG [52b450cd] Command: /usr/bin/env echo '[2023-04-20 11:42:20] [root] Pulled image with version 82be156e0670d57d93c8ececfd4f3af1053ad4b3' >> mrsk-front-office-audit.log
 DEBUG [52b450cd] Finished in 0.238 seconds with exit status 0 (successful).
  INFO [d9d65660] Running docker image rm --force registry.digitalocean.com/e-sportstats/front-office:82be156e0670d57d93c8ececfd4f3af1053ad4b3 on 165.22.1.24
 DEBUG [d9d65660] Command: docker image rm --force registry.digitalocean.com/e-sportstats/front-office:82be156e0670d57d93c8ececfd4f3af1053ad4b3
 DEBUG [d9d65660]       Error: No such image: registry.digitalocean.com/e-sportstats/front-office:82be156e0670d57d93c8ececfd4f3af1053ad4b3
  INFO [d9d65660] Finished in 0.259 seconds with exit status 0 (successful).
  INFO [c9acf32c] Running docker pull registry.digitalocean.com/e-sportstats/front-office:latest on 165.22.1.24
 DEBUG [c9acf32c] Command: docker pull registry.digitalocean.com/e-sportstats/front-office:latest
 DEBUG [c9acf32c]       Error response from daemon: manifest for registry.digitalocean.com/e-sportstats/front-office:latest not found: manifest unknown: manifest unknown
  Deploy lock was not released
  Deploy lock was not released
  Finished all in 4.9 seconds
  Deploy lock was not released
  ERROR (SSHKit::Command::Failed): docker exit status: 1
docker stdout: Nothing written
docker stderr: Error response from daemon: manifest for registry.digitalocean.com/e-sportstats/front-office:latest not found: manifest unknown: manifest unknown

/usr/local/bundle/gems/sshkit-1.21.4/lib/sshkit/command.rb:97:in `exit_status='
/usr/local/bundle/gems/sshkit-1.21.4/lib/sshkit/backends/netssh.rb:170:in `execute_command'
/usr/local/bundle/gems/sshkit-1.21.4/lib/sshkit/backends/abstract.rb:148:in `block in create_command_and_execute'
<internal:kernel>:90:in `tap'
/usr/local/bundle/gems/sshkit-1.21.4/lib/sshkit/backends/abstract.rb:148:in `create_command_and_execute'
/usr/local/bundle/gems/sshkit-1.21.4/lib/sshkit/backends/abstract.rb:80:in `execute'
/usr/local/bundle/gems/mrsk-0.11.0/lib/mrsk/cli/build.rb:39:in `block (2 levels) in pull'
/usr/local/bundle/gems/sshkit-1.21.4/lib/sshkit/backends/abstract.rb:31:in `instance_exec'
/usr/local/bundle/gems/sshkit-1.21.4/lib/sshkit/backends/abstract.rb:31:in `run'
/usr/local/bundle/gems/sshkit-1.21.4/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
@bohdan-shulha
Copy link
Author

Ah, I see that there's already a ticket for this.

#109

Probably, it makes sense to close this one.

Jberczel added a commit to Jberczel/mrsk that referenced this issue May 1, 2023
Add checks for:

* Docker installed locally
* Docker buildx plugin installed locally (not currently required for
  native/local build)
* Dockerfile exists

Checks will halt deployment and provide more specific error messages.

Also adds a cli subcommand:
`mrsk build dependencies`

Fixes: basecamp#109 and basecamp#237
Jberczel added a commit to Jberczel/mrsk that referenced this issue May 1, 2023
Add checks for:

* Docker installed locally
* Docker buildx plugin installed locally
* Dockerfile exists

If checks fail, it will halt deployment and provide more specific error messages.

Also adds a cli subcommand:
`mrsk build dependencies`

Fixes: basecamp#109 and basecamp#237
@dhh
Copy link
Member

dhh commented May 2, 2023

Fixed via #256.

@dhh dhh closed this as completed May 2, 2023
@meglio
Copy link

meglio commented Sep 25, 2023

Now it requires a Dockerfile even when there should be none, i.e. when I am deploying some public image from Docker Hub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants