cuber-cloud / cuber-gem

An automation tool that simplify the deployment of your apps on Kubernetes.
https://cuber.cloud
Apache License 2.0
656 stars 24 forks source link

Expand Dockerfile path #10

Closed mrkn closed 1 year ago

mrkn commented 1 year ago

With docker-desktop 4.17.0, docker build command couldn't resolve the location of Dockerfile.

The execution log is below:

$ cuber deploy

-----> Cloning Git repository
Cloning into '.cuber/repo'...
remote: Enumerating objects: 140, done.
remote: Counting objects: 100% (140/140), done.
remote: Compressing objects: 100% (118/118), done.
remote: Total 140 (delta 10), reused 113 (delta 8), pack-reused 0
Receiving objects: 100% (140/140), 47.44 KiB | 319.00 KiB/s, done.
Resolving deltas: 100% (10/10), done.

-----> Building image from Dockerfile
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 2B done
#1 DONE 0.0s

#2 [internal] load .dockerignore
#2 transferring context: 2B done
#2 DONE 0.0s
ERROR: failed to solve: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount1598098172/Dockerfile: no such file or directory
Cuber: docker build failed
collimarco commented 1 year ago

Hello,

Thanks for reporting this issue. Unfortunately I cannot reproduce the problem that you are describing.

I am using Docker Desktop 4.17.0 on MacOS and everything works properly (tested again right now).

Did it worked for you before? What OS are you using? Maybe that is a Docker bug on your platform.

mrkn commented 1 year ago

Did it worked for you before? What OS are you using? Maybe that is a Docker bug on your platform.

I'm using Ubuntu 20.04. It is my first trial of cuber. I downloaded docker desktop for ubuntu from https://docs.docker.com/desktop/install/ubuntu/

Thanks.

mrkn commented 1 year ago

And the contents of my Cuberfile is like below:

app "test-app"
repo "https://github.com/mrkn/test-app.git"
dockerfile "Dockerfile"
image "mrkn/test-app"
kubeconfig "kubeconfig.yaml"

migrate 'rails db:migrate', check: 'rake db:abort_if_pending_migrations'

env "RAILS_ENV", "production"
env "RAILS_MASTER_KEY", "xxxx"

proc :web, "bundle exec rails server -b 0.0.0.0 -p $PORT", scale: 1

My situation is that Cuberfile and Dockerfile is outside of the repository. Do Cuberfile and Dockerfile need to be placed inside the repository?

I can avoid this problem to specify File.expand_path("Dockerfile") to dockerfile.

collimarco commented 1 year ago

The Cuberfile is just Ruby, so you can ideally write this if you want (wrong):

dockerfile File.expand_path("Dockerfile")

Or this (correct, because it's a relative path inside the repo):

dockerfile "path/to/Dockerfile"

It shouldn't be necessary in general.

The Dockerfile is usually part of the application and resides in the same Git repository (usually in the root folder).

The Cuberfile, on the other hand, can be in the same Git repository or in any another place.

Maybe in your case the problem is that your Dockerfile in not in your Git repository.

mrkn commented 1 year ago

Oops, I didn't read the documentation carefully! I've noticed that the following description.

The name (or relative path) of the Dockerfile inside your app repository.

I'm sorry to bother you.