Wrong build instructions?
greg0ire opened this issue · comments
I don't know go or rocker but I'm trying to contribute a solution to #68 , and I am stuck :
if git describe --contains HEAD &>/dev/null; then export VERSIONARGS="-var DNSDockVersion=`git describe --contains HEAD`"; else unset VERSIONARGS; fi
echo $VERSIONARGS
-var DNSDockVersion=v1.13.1
rocker build -var Arch=amd64 ${VERSIONARGS} -var OutputDir=/tmp
Incorrect Usage.
NAME:
build - launches a build for the specified Rockerfile
USAGE:
command build [command options] [arguments...]
OPTIONS:
--file, -f "Rockerfile" rocker build file to execute
--auth, -a Username and password in user:password format
--build-arg [--build-arg option --build-arg option] Set build-time variables, can pass multiple of those, format is key=value (default [])
--var [--var option --var option] set variables to pass to build tasks, value is like "key=value"
--vars [--vars option --vars option] Load variables form a file, either JSON or YAML. Can pass multiple of this.
--no-cache supresses cache for docker builds
--reload-cache removes any cache that hit and save the new one
--cache-dir "~/.rocker_cache" Set the directory where the cache will be stored
--no-reuse suppresses reuse for all the volumes in the build
--push pushes all the images marked with push to docker hub
--pull always attempt to pull a newer version of the FROM images
--attach attach to a container in place of ATTACH command
--meta add metadata to the tagged images, such as user, Rockerfile source, variables and git branch/sha
--print just print the Rockerfile after template processing and stop
--demand-artifacts fail if artifacts not found for {{ image }} helpers
--id override the default id generation strategy for current build
--artifacts-path put artifacts (files with pushed images description) to the directory
--no-garbage remove the images from the tail if not tagged
--push-retry "0" number of retries for failed image pushes
flag provided but not defined: -var DNSDockVersion%
The last line looks interesting. What did I do wrong?
Hi
Are you sure docker is installed ?
If it is the case, can you try the following command:
cd <path_to_your code>
rocker build -var SRCDIR=. -var OUTPUTDIR=/tmp/output
You shall find a binary in /tmp/output
Are you sure docker is installed ?
Yes (I use it for my day to day work)
rocker build -var SRCDIR=. -var OUTPUTDIR=/tmp/output
Seems to work! Thanks!
Hm… my changes don't seem to be taken into account. I can't use the binary since I already have a DNS server running, so I thought I'd just run the container that was used for building… not sure if it makes sense. I run it like that :
docker run --rm --volume=/var/run/docker.sock:/var/run/docker.sock --publish=172.17.0.1:53:53/udp --name dns_dock_dev tonistiigi/dnsdock:amd64-develop
Does it make sense?
you can avoid the --publish and get the IP of your container (docker inspect dns_dock_dev). Add this IP as a new DNS server in your /etc/resolv.conf (first line) and use "dig" to see the name resolution.
you can avoid the --publish and get the IP of your container (docker inspect dns_dock_dev). Add this IP as a new DNS server in your /etc/resolv.conf (first line) and use "dig" to see the name resolution.
Yeah but the IP might change from time to time, right? At least that way I have it fixed. Anyway regarding my question, once I have run rocker, is this command I run a good way to test my changes? If yes, do you have any idea why they seem to have no effect ?
Here is the diff :
diff --git a/src/http.go b/src/http.go
index 6dcecdd..f33369f 100644
--- a/src/http.go
+++ b/src/http.go
@@ -41,10 +41,13 @@ func (s *HTTPServer) Start() error {
}
func (s *HTTPServer) getServices(w http.ResponseWriter, req *http.Request) {
+ log.Println('hello');
if err := json.NewEncoder(w).Encode(s.list.GetAllServices()); err != nil {
log.Println("Error encoding: ", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
}
+ w.Header().Set("Content-Type", "application/json")
}
func (s *HTTPServer) getService(w http.ResponseWriter, req *http.Request) {
I added the log afterwards, but couldn't see it in the output, and I'm unsure what I need to do to have the new code running, so I try running the rocker command again but it went pretty past.
Yep the container's IP may change (if you change the starting order of all your containers)
The instruction I gave you was just test it. If you want to use it in production you shall type -p 53:53.
this command is a good way to test. Your changes shall have an effect. You don't see the "hello" log ?
No I don't, but I added it afterwards, maybe I need to recompile something? I don't know go at all.
rerun the rocker build command with --no-cache. It your connection is too slow, rerun rocker build with --attach and run the following command in the container:
go build -o /tmp/output/dnsdock
It seems to work, I have some error output related to my code :)
Changed the single with double quotes and I can see my code in action, thanks a lot!