failed to read Dockerfile MacOS GoLang; Trying to create an image - bash

I keep running into that error on the last line and have tried putting the dockerfile in the tmp folder but still get the same error; I even tried upper casing and lowercasing the docker file name, it didn't resolve the issue.
my file path is Users/maheenk/Desktop/infra
my docker file :
#syntax=docker/dockerfile:1
#using latest version
FROM golang:latest
WORKDIR /app
#Download necessary Go modules
COPY go.mod ./
COPY go.sum ./
RUN go mod download
#copies source code onto image
COPY *.go ./
#static application in rootfilesystem
RUN docker build -t internhw:latest -f .Dockerfile .
EXPOSE 8080
#command to execute when image is used to start a container
CMD [ "internhw"]
the command I run in terminal:
docker build -t internhw:latest -f .Dockerfile .
what the output is in terminal:
[+] Building 0.1s (2/2) FINISHED
=> [internal] load build definition from .Dockerfile 0.1s
=> => transferring dockerfile: 2B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount200403056/.Dockerfile: no such file or directory
Output of command in terminal: ls -al
total 160
drwxrwxr-x# 9 maheenk staff 288 Apr 24 11:42 .
drwxrwxrwx# 110 maheenk staff 3520 Apr 23 17:24 ..
-rw-r--r--# 1 maheenk staff 6148 Apr 24 11:42 .DS_Store
drwxr-xr-x 14 maheenk staff 448 Apr 24 11:00 .git
-rw-r--r--# 1 maheenk staff 523 Apr 24 10:54 Dockerfile
-rw-r--r-- 1 maheenk staff 669 Apr 23 16:26 go.mod
-rw-r--r-- 1 maheenk staff 56262 Apr 23 16:26 go.sum
-rw-r--r-- 1 maheenk staff 2126 Apr 23 16:09 main.go
I added a .Dockerfile to the folder(basically a copy of the dockerfile that i renamed by putting a period in front of)
drwxrwxr-x# 9 maheenk staff 288 Apr 24 13:03 .
drwxrwxrwx# 111 maheenk staff 3552 Apr 24 12:43 ..
-rw-r--r--# 1 maheenk staff 6148 Apr 24 13:03 .DS_Store
-rw-r--r--# 1 maheenk staff 513 Apr 24 13:06 .Dockerfile
drwxr-xr-x 14 maheenk staff 448 Apr 24 13:00 .git
-rw-r--r--# 1 maheenk staff 523 Apr 24 10:54 Dockerfile
-rw-r--r-- 1 maheenk staff 669 Apr 23 16:26 go.mod
-rw-r--r-- 1 maheenk staff 56262 Apr 23 16:26 go.sum
-rw-r--r-- 1 maheenk staff 2126 Apr 23 16:09 main.go```
UPDATED VERSION:
redid the run line in docker as suggested
#syntax=docker/dockerfile:1
FROM golang:latest
WORKDIR /app
# Download necessary Go modules
COPY go.mod ./
COPY go.sum ./
RUN go mod download
#copies source code onto image
COPY *.go ./
#static application in rootfilesystem
RUN build -t internhw:latest .Dockerfile .
EXPOSE 8080
#command to execute when image is used to start a container
CMD [ "internhw" ] ```
when i run in terminal docker build -t internhw:latest .Dockerfile .
"docker build" requires exactly 1 argument.
See 'docker build --help'.
Usage: docker build [OPTIONS] PATH | URL | -
Build an image from a Dockerfile

It does make little sense to do a docker build inside a Dockerfile which is itself... 'docker built'.
If you need to add resources to an existing image, you can use COPY or ADD inside your Dockerfile.
If you need to compile something and put the result in an existing image, you can use a multi-stage build.

Related

After deleting Gradle's build cache and building, some tasks are still marked as FROM-CACHE

I start off by deleting Gradle's build cache
$ rm -rf $GRADLE_HOME/caches/build-cache-*
I manually confirm this directory is gone. I also clean to ensure nothing from incremental build will interfere
$ ./gradlew clean
I then run a build w/ build-cache enabled:
$ ./gradlew --build-cache --scan app:assembleDebug
...
238 actionable tasks: 172 executed, 49 from cache, 17 up-to-date
Checking the generated report I see that some tasks are still marked as FROM-CACHE. How is this happening?
FWIW I'm using Gradle 5.6.3. I also don't use a remote build cache.
UPDATE: after clearing build cache, here's what's left in the cache dir:
$ pwd
/Users/jasonatwood/.gradle/caches
$ ls -al
total 24
drwx------ 11 jasonatwood staff 352 Dec 13 18:11 .
drwxr-xr-x 9 jasonatwood staff 288 Oct 15 17:24 ..
drwxr-xr-x 14 jasonatwood staff 448 Oct 29 16:07 5.4.1
drwxr-xr-x 15 jasonatwood staff 480 Nov 26 18:25 5.6.3
drwxr-xr-x 35 jasonatwood staff 1120 Dec 11 14:14 jars-3
drwxr-xr-x 5 jasonatwood staff 160 Oct 15 17:44 journal-1
drwxr-xr-x 7 jasonatwood staff 224 Oct 15 17:50 modules-2
drwxr-xr-x 5 jasonatwood staff 160 Oct 15 17:50 transforms-2
-rw-r--r-- 1 jasonatwood staff 39 Oct 15 17:27 transforms-2.lock
-rw------- 1 jasonatwood staff 28 Oct 22 16:34 user-id.txt
-rw-r--r-- 1 jasonatwood staff 17 Dec 13 18:00 user-id.txt.lock
If I understand correctly, I don't need to delete any of these.
The local task cache in the .gradle directory within the root project might interfere.
In order to disable the local/global caching altogether, use gradle.properties:
org.gradle.caching=false
If you remove the local build cache and don't use a remove cache, Gradle should indeed not be able to fetch anything cached on the next build. However, I don't think you actually removed anything.
The GRADLE_HOME environment variable, if you have it, should points to an unpacked local Gradle distribution. It could be something like /Users/jasonatwood/gradle-6.0-all. It would be wrong to set it to a path that is not a Gradle distribution.
The Gradle build cache resides in /Users/jasonatwood/.gradle/caches/build-cache-1.
When you try to remove it with $ rm -rf $GRADLE_HOME/caches/build-cache-*, you are using GRADLE_HOME as if it is pointing to the root of your home folder (/Users/jasonatwood), which it most likely isn't.
So instead, use this for removing it: $ rm -rf ~/.gradle/caches/build-cache-*
Or, at the very least, verify that the cache folder has indeed been removed.
If I run a --scan and look at the FROM-CACHE tasks in the generated HTML report.
I then look at the build cache keys for those FROM-CACHE tasks. I then go find those keys on my local machine. I see they are generated at the same time as the rest of the build. So I'm guessing that Gradle is using build cache within a build and not just across builds.
Sometimes there is a need to invalidate cache every time you restart the IDEA. This may be due to shared indexes reuse. What I did Settings --> Tools --> Shared Indexes -> Download Automatically and it resolved all the pain.
Earlier the setting was Don't download use Local.

Nativescript app will not running locally

I have a nativescript app I have inherited and am trying to get it running locally. Here is what I am seeing:
ruby-2.4.1 marklocklear:foobar_app marklocklear$ tns run ios
Skipping node_modules folder! Use the syncAllFiles option to sync files from this folder.
Searching for devices...
Executing before-liveSync hook from /Users/marklocklear/nativescript/foobar_app/hooks/before-liveSync/nativescript-angular-sync.js
Executing before-watchPatterns hook from /Users/marklocklear/nativescript/foobar_app/hooks/before-watchPatterns/nativescript-dev-typescript.js
Executing before-watch hook from /Users/marklocklear/nativescript/foobar_app/hooks/before-watch/nativescript-dev-typescript.js
Found peer TypeScript 2.9.2
15:17:35 - Starting compilation in watch mode...
15:17:40 - Found 0 errors. Watching for file changes.
At this point the command line sits there...if I open the preview or playground app I get nothing on my iPhone (which is connected to my mac) I get nothing.
If I try tns run ios --emulator this opens an emulator locally, but I don't see the app anywhere on the emulator.
I have a couple of sample apps that I am able to run locally, so I think the framework is installed correctly. Here is what the root of the app looks like:
ls -la
total 64
drwxr-xr-x 10 marklocklear staff 320 Oct 25 12:44 .
drwxr-xr-x# 7 marklocklear staff 224 Oct 26 14:44 ..
drwxr-xr-x# 31 marklocklear staff 992 Oct 25 10:09 app
drwxr-xr-x 8 marklocklear staff 256 Oct 25 12:44 hooks
drwxr-xr-x 64 marklocklear staff 2048 Oct 25 12:44 node_modules
-rw-r--r--# 1 marklocklear staff 19593 Oct 25 10:09 package-lock.json
-rw-r--r--# 1 marklocklear staff 1381 Oct 25 10:09 package.json
drwxr-xr-x# 5 marklocklear staff 160 Oct 25 10:09 platforms
-rw-r--r--# 1 marklocklear staff 271 Oct 25 10:09 references.d.ts
-rw-r--r--# 1 marklocklear staff 681 Oct 25 12:44 tsconfig.json
Any ideas on how to trouble shoot this?
Remove your platform, node_modules and build again. Try a real device too.

Go Project in IntelliJ Not Resolving Dependencies

I have IntelliJ CE and I just imported a Go project that I cloned from GitHub. On my Mac, I have some folder organization where I group projects that I work on based on the technologies. For example., in my Projects folder on my Mac, I have the following sub folders:
- go-projects
- scala-projects
- rust-projects
- ruby-projects
So I obviously checked out the Go project in the go-projects folder which looks like this:
Joes-MacBook-Pro:go-projects joe$ ll
total 0
drwxr-xr-x 3 joe staff 102B Oct 28 07:51 bin/
drwxr-xr-x 19 joe staff 646B Oct 24 06:48 golang-restful-starter-kit/
drwxr-xr-x 3 joe staff 102B Oct 28 07:51 pkg/
drwxr-xr-x 3 joe staff 102B Oct 27 10:23 src/
And if I get into the src folder, it looks like this:
Joes-MacBook-Pro:go-projects joe$ cd src
total 0
drwxr-xr-x 6 joe staff 204B Nov 7 19:14 github.com/
Joes-MacBook-Pro:src joe$ cd github.com/
total 0
drwxr-xr-x 3 joe staff 102B Oct 28 08:20 btcsuite/
drwxr-xr-x 16 joe staff 544B Nov 7 19:16 eth-client/
drwxr-xr-x 3 joe staff 102B Oct 27 10:24 ethereum/
drwxr-xr-x 3 joe staff 102B Oct 28 07:51 tools/
Joes-MacBook-Pro:github.com joe$
Here is my Go related environment settings:
# For Go projects, we set the GOPATH
export GOROOT="/usr/local/go"
export GOPATH="/Users/joe/Projects/Private/go-projects"
export GODEPS="/Users/joe/Projects/Private/go-projects/bin/godep"
Now I import one of the Go project into IntelliJ and I get to see the following error saying that it is not able to resolve a directory as it can be seen in the screenshot below!
How can I get rid of this error? Any ideas?
I just realized that when I clone the project, I should not do a git clone but rather do:
go get -u github.com/golang/lint/golint
Not sure why this is so, but after doing this my IntelliJ was able to resolve every file on my project!
For golang projects, it's good to have Goland installed ( also a product of JetBrains )Goland Download. Moreover for the above concern you can use:
go get *the_project_to_clone*

How to make the zip file with particular directories in gradle

I am working on one gradle script where I need to create the zip file.Below are my contents in the workspace but I need few folder inside the zip file and the zip file should be create with name application-data-1.0.zip.I need only three folder inside that zip file
data,sql and services .As per my understanding I need to use distribution plugin.Could someone tell me how could I do that?
-rw-r--r-- 1 jenkins jenkins 38 Mar 11 22:39 at.properties
drwxr-xr-x 3 jenkins jenkins 4096 Mar 11 22:39 data
-rw-r--r-- 1 jenkins jenkins 38 Mar 11 22:39 pd.properties
-rw-r--r-- 1 jenkins jenkins 5532 Mar 11 22:39 maven.xml
-rw-r--r-- 1 jenkins jenkins 74384 Mar 11 22:39 pom.xml
-rw-r--r-- 1 jenkins jenkins 37 Mar 11 22:39 sbx.properties
-rw-r--r-- 1 jenkins jenkins 595 Mar 11 22:39 project.xml
-rw-r--r-- 1 jenkins jenkins 1020 Mar 11 22:39 project.properties
drwxr-xr-x 3 jenkins jenkins 4096 Mar 11 22:39 sql
drwxr-xr-x 3 jenkins jenkins 4096 Mar 11 22:39 services
-rw-r--r-- 1 jenkins jenkins 40 Mar 11 22:39 tst.properties
-rw-r--r-- 1 jenkins jenkins 5656258 Mar 26 15:51 application-data-1.0.zip
Using a custom zip task, you can do something like:
task applicationDistZip(type: Zip) {
archiveBaseName.set("application-data")
archiveVersion.set('1.0')
from ('.') {
include 'data/**'
include 'services/**'
include 'sql/**'
}
}
Using the distribution plugin:
distributions {
application {
baseName = 'application-data'
version = '1.0'
contents {
from ('.') {
include 'data/**'
include 'services/**'
include 'sql/**'
}
}
}
}
To generate the zip, just run the command applicationDistZip

Failed to archive Cocoa application with command-line tool inside Executables

I stuck with this problem in my project, so, I tried it with an empty test project. Here is what I do.
Create a new Cocoa application project in Xcode.
Add a new command-line tool target to it.
Add this target to the dependencies of the cocoa app.
In cocoa app target build phases add Copy files build phase, Destination = Executables, add executable product to the list.
Now Run cocoa application. No problem, application launched. Navigate app bundle in Finder, Show package contents, executable here in Contents/MacOS. This is what I expect to be.
The problem occurs when I archive cocoa application, it fails with the following error:
(null): error: /Users/prudnikov/Library/Developer/Xcode/DerivedData/TestAppWithExecutable-hiysgipuqcktgoayxrgjfrtcxubl/Build/Intermediates/ArchiveIntermediates/TestAppWithExecutable/BuildProductsPath/Release/TestAppExecutable: No such file or directory
Here is a screenshot
Here is content of this directory
prudnikov#Vladimirs-iMac ~ $ ls -al /Users/prudnikov/Library/Developer/Xcode/DerivedData/TestAppWithExecutable-hiysgipuqcktgoayxrgjfrtcxubl/Build/Intermediates/ArchiveIntermediates/TestAppWithExecutable/BuildProductsPath/Release/
total 8
drwxr-xr-x 5 prudnikov staff 170B Apr 26 21:59 ./
drwxr-xr-x# 3 prudnikov staff 102B Apr 26 21:59 ../
drwxr-xr-x 3 prudnikov staff 102B Apr 26 21:59 TestAppExecutable.dSYM/
lrwxr-xr-x 1 prudnikov staff 239B Apr 26 21:59 TestAppWithExecutable.app# -> /Users/prudnikov/Library/Developer/Xcode/DerivedData/TestAppWithExecutable-hiysgipuqcktgoayxrgjfrtcxubl/Build/Intermediates/ArchiveIntermediates/TestAppWithExecutable/InstallationBuildProductsLocation/Applications/TestAppWithExecutable.app
drwxr-xr-x 3 prudnikov staff 102B Apr 26 21:59 TestAppWithExecutable.app.dSYM/
Archiving executable — no problems. All build settings are defaults.
I've also tried to change build configuration from Debug to Release for Run action of Cocoa application scheme. It runs successfully in this case as well.
This is very strange for me. Please advice how to do it?
UPDATE: It seems that I have problem with OS. People tried the same example and it worked. Then I trien to create a new account on my Mac and do the same there and it worked as well. What global configuration can cause this?
I don't think this is an Answer but it's too long for a comment.
Check the parent directories
gdunham: ~/Library/Developer/Xcode/DerivedData$ ls -laeG /Users/gdunham/Library/Developer/Xcode/DerivedData | grep -e " \\.$"
drwxr-xr-x 31 gdunham staff 1054 Apr 15 14:29 /Users/gdunham/Library/Developer/Xcode/DerivedData
drwxr-xr-x 13 gdunham staff 442 May 1 19:56 /Users/gdunham/Library/Developer/Xcode
drwxr-xr-x 4 gdunham staff 136 Mar 8 2012 /Users/gdunham/Library/Developer/
drwx------# 66 gdunham staff 2244 Apr 2 22:43 /Users/gdunham/Library
0: group:everyone deny delete
drwxr-xr-x+ 62 gdunham staff 2108 Apr 30 14:33 /Users/gdunham
0: group:everyone deny delete
drwxr-xr-x 7 root admin 238 Feb 20 14:16 /Users
drwxr-xr-x 34 root wheel 1224 Apr 20 09:26 /
Also look at your group membership
gdunham: ~/Library/Developer/Xcode/DerivedData$ groups
staff com.apple.access_screensharing com.apple.access_screensharing-disabled everyone _appstore localaccounts _appserverusr admin _appserveradm _lpadmin _lpoperator _developer com.apple.sharepoint.group.1

Resources