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

[nats] Release v1.0.2 #3206

Merged
merged 1 commit into from
Jul 19, 2017
Merged

[nats] Release v1.0.2 #3206

merged 1 commit into from
Jul 19, 2017

Conversation

kozlovic
Copy link
Contributor

The Windows Docker Images were not working. This release fixes this.

Details can be found here

The Windows Docker Images were not working. This release fixes this.

Details can be found [here](https://github.com/nats-io/gnatsd/releases/tag/v1.0.2)
@yosifkit
Copy link
Member

Diff:
diff --git a/_bashbrew-list b/_bashbrew-list
index 617d648..610cd62 100644
--- a/_bashbrew-list
+++ b/_bashbrew-list
@@ -1,6 +1,6 @@
-nats:1.0.0
-nats:1.0.0-nanoserver
-nats:1.0.0-windowsservercore
+nats:1.0.2
+nats:1.0.2-nanoserver
+nats:1.0.2-windowsservercore
 nats:latest
 nats:nanoserver
 nats:windowsservercore
diff --git a/nats_latest/gnatsd b/nats_latest/gnatsd
index f3fef94..62bf5e6 100755
Binary files a/nats_latest/gnatsd and b/nats_latest/gnatsd differ
diff --git a/nats_nanoserver/Dockerfile b/nats_nanoserver/Dockerfile
index 375c704..8958474 100644
--- a/nats_nanoserver/Dockerfile
+++ b/nats_nanoserver/Dockerfile
@@ -1,16 +1,14 @@
-# escape=`
 FROM microsoft/nanoserver
-SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
 
-ENV NATS_VERSION="v1.0.0"
-
-# Download and expand released version
-RUN Invoke-WebRequest -OutFile gnatsd.zip "https://github.com/nats-io/gnatsd/releases/download/$($env:NATS_VERSION)/gnatsd-$($env:NATS_VERSION)-windows-amd64.zip" -UseBasicParsing ; `
-    Expand-Archive gnatsd.zip -DestinationPath C:\ ; `
-    Move-Item "C:/gnatsd-$($env:NATS_VERSION)-windows-amd64" 'c:/gnatsd'; `
-    Remove-Item gnatsd.zip
+# The NAT Server will look for this environment variable.
+# When set, it prevents the use of the service API to detect
+# if it is running in interactive mode or not, which is
+# failing in the context of a Docker container.
+# (https://github.com/nats-io/gnatsd/issues/543)
+ENV NATS_DOCKERIZED=1
 
 WORKDIR c:/gnatsd
+COPY gnatsd.exe gnatsd.exe
 COPY gnatsd.conf gnatsd.conf
 
 # Expose client, management, and cluster ports
diff --git a/nats_latest/gnatsd b/nats_nanoserver/gnatsd.exe
similarity index 46%
copy from nats_latest/gnatsd
copy to nats_nanoserver/gnatsd.exe
index f3fef94..756ca0a 100755
Binary files a/nats_latest/gnatsd and b/nats_nanoserver/gnatsd.exe differ
diff --git a/nats_windowsservercore/Dockerfile b/nats_windowsservercore/Dockerfile
index 301cb94..28752cc 100644
--- a/nats_windowsservercore/Dockerfile
+++ b/nats_windowsservercore/Dockerfile
@@ -1,16 +1,14 @@
-# escape=`
 FROM microsoft/windowsservercore
-SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
 
-ENV NATS_VERSION="v1.0.0"
-
-# Download and expand released version
-RUN Invoke-WebRequest -OutFile gnatsd.zip "https://github.com/nats-io/gnatsd/releases/download/$($env:NATS_VERSION)/gnatsd-$($env:NATS_VERSION)-windows-amd64.zip" -UseBasicParsing ; `
-    Expand-Archive gnatsd.zip -DestinationPath C:\ ; `
-    Move-Item "C:/gnatsd-$($env:NATS_VERSION)-windows-amd64" 'c:/gnatsd'; `
-    Remove-Item gnatsd.zip
+# The NAT Server will look for this environment variable.
+# When set, it prevents the use of the service API to detect
+# if it is running in interactive mode or not, which is
+# failing in the context of a Docker container.
+# (https://github.com/nats-io/gnatsd/issues/543)
+ENV NATS_DOCKERIZED=1
 
 WORKDIR c:/gnatsd
+COPY gnatsd.exe gnatsd.exe
 COPY gnatsd.conf gnatsd.conf
 
 # Expose client, management, and cluster ports
diff --git a/nats_latest/gnatsd b/nats_windowsservercore/gnatsd.exe
similarity index 46%
copy from nats_latest/gnatsd
copy to nats_windowsservercore/gnatsd.exe
index f3fef94..756ca0a 100755
Binary files a/nats_latest/gnatsd and b/nats_windowsservercore/gnatsd.exe differ

@yosifkit
Copy link
Member

Build test of #3206; 7bcda51 (nats):

$ bashbrew build nats:1.0.2
Building bashbrew/cache:68298cd46f63cdcc7dd02b495ee983384e7f6724a87ac89885c8612cc2ae0148 (nats:1.0.2)
Tagging nats:1.0.2
Tagging nats:latest

$ test/run.sh nats:1.0.2
testing nats:1.0.2
	'cve-2014--shellshock' [1/2]...passed
	'override-cmd' [2/2]...image does not appear to contain "echo" -- assuming single-binary image
passed


$ bashbrew build nats:1.0.2-nanoserver
skipping "nats:1.0.2-nanoserver" (due to architecture "amd64"; only "windows-amd64" supported)

$ test/run.sh nats:1.0.2-nanoserver
testing nats:1.0.2-nanoserver
	image does not exist!


$ bashbrew build nats:1.0.2-windowsservercore
skipping "nats:1.0.2-windowsservercore" (due to architecture "amd64"; only "windows-amd64" supported)

$ test/run.sh nats:1.0.2-windowsservercore
testing nats:1.0.2-windowsservercore
	image does not exist!

The following images failed at least one test:

  • nats:
    • nats:1.0.2-nanoserver
    • nats:1.0.2-windowsservercore

@yosifkit yosifkit merged commit 0e6a097 into docker-library:master Jul 19, 2017
@kozlovic
Copy link
Contributor Author

@yosifkit I am planning on adding arm64v8 (and some other architectures) to NATS docker image, however, since our image is built from scratch, as I understand it, our nats-docker repo will have architecture directories with their own Dockerfile and executable (which I build separately with yet another Dockerfile based on golang that uses cross-compile). Is that the way to do it? Thanks!

@tianon
Copy link
Member

tianon commented Aug 22, 2017

@kozlovic my comment over at gliderlabs/docker-alpine#304 (comment) probably has some useful info/links (#3024, #3031, https://github.com/tianon/docker-brew-alpine-multiarch); #3176 is another good example 👍

Happy to help describe further or implement anything to make this happen! 👍

@yosifkit
Copy link
Member

Since hello-world is also just a single binary image, docker-library/hello-world#31 might be a good example too.

@kozlovic
Copy link
Contributor Author

hello-world is what I based my approach on. In a nutshell, I have a repo nats-docker that will have all directories amd64, arm32v7, arm64 and ppc64le with each one a gnatsd executable that has been cross-compiled from a docker image based on golang-1.8.3. In these directories, there will be a Dockerfile that contains FROM scratch and copy the local exe into the docker image.
Would that work? If I try to build a docker image for, say, arm64 and try to execute it, it complains about threads:

cd arm64v8/
Ivans-MacBook-Pro:arm64v8 ivan$ ls -lrt
total 11744
-rw-r--r--  1 ivan  staff      671 Aug 22 14:37 gnatsd.conf
-rw-r--r--  1 ivan  staff      216 Aug 22 14:37 Dockerfile
-rwxr-xr-x  1 ivan  staff  6004512 Aug 22 17:49 gnatsd
Ivans-MacBook-Pro:arm64v8 ivan$ docker build -t test .
Sending build context to Docker daemon  6.009MB
Step 1/6 : FROM scratch
 ---> 
Step 2/6 : COPY gnatsd /gnatsd
 ---> c0c6a64592b3
(...)
Successfully tagged test:latest
Ivans-MacBook-Pro:arm64v8 ivan$ docker run -ti test
runtime: failed to create new OS thread (have 2 already; errno=22)
fatal error: newosproc

So I am either doing something wrong, or when built on your side, the scratch will be based on the specified architecture as opposed to when I run on my laptop?

@tianon
Copy link
Member

tianon commented Aug 22, 2017

That'd be because Docker for Mac is injecting QEMU for you in order to run those non-amd64 binaries natively, but QEMU doesn't support running Go binaries 100% properly (I think golang/go#1508 is the correct Go upstream issue about that). 😄

@tianon
Copy link
Member

tianon commented Aug 22, 2017

golang/go#13024 is another useful discussion about the issue.

@kozlovic
Copy link
Contributor Author

But does this mean that it would work if built as part of the PR (I expect that you guys don't build from a Mac ;-)).

@tianon
Copy link
Member

tianon commented Aug 23, 2017 via email

@kozlovic
Copy link
Contributor Author

If I were to add a tag (say 1.0.3-beta) for the new architectures, with both source and the nats-docker git commits from a branch that will be later deleted, would that work? And would only this tag (1.0.3-beta) for these architectures be pushed to the hub? (since the others would not be changed)

For instance:

--- a/library/nats
+++ b/library/nats
@@ -6,6 +6,13 @@ GitCommit: 4a2e6f17092b5b8481637c1881f781ae25374309
 
 Tags: 1.0.2, latest
 
+Tags: 1.0.3-beta
+Architectures: arm32v7, arm64v8
+arm32v7-GitCommit: <commit to branch>
+arm32v7-Directory: arm32v7
+arm64v8-GitCommit: <commit to branch>
+arm64v8-Directory: arm64v8
+
 Tags: 1.0.2-nanoserver, nanoserver
 Architectures: windows-amd64
 Directory: windows/nanoserver

Once the images are built and I can verify that they seem to work, I would then issue a product release 1.0.4 and consolidate the amd64 and those 2 new arch under the same latest tag (and of course have a new PR to this repo).

Thank you so much for the help so far!

@yosifkit
Copy link
Member

It should be fine to have a release that is only non-amd64 images. Due to the way the code validates each section, they still need a valid default Directory and GitCommit (which can come from the global section). So something like this:

+Tags: 1.0.3-beta
+Architectures: arm32v7, arm64v8
# this still needs to be fetchable, probably just use the same values as one of the arches
# and leave off the corresponding "arch-*" fields
+GitCommit: <commit to branch>
+Directory: arm32v7
# if they are on a different branch from master, then you'll need this:
+GitFetch: refs/heads/branch-name
+arm32v7-GitCommit: <commit to branch>
+arm32v7-Directory: arm32v7
+arm64v8-GitCommit: <commit to branch>
+arm64v8-Directory: arm64v8

@kozlovic
Copy link
Contributor Author

Sorry, I am bit confused. For this experiment, yes, they would be in a different branch than master.
In your example, you have the "default" directory set to arm32v7 and the corresponding commit. Just to confirm: this is still needed even if we then have the GitFetch and arch-* specific fields, right?

@tianon
Copy link
Member

tianon commented Aug 23, 2017

Here's what I'd recommend:

Maintainers: Derek Collison <[email protected]> (@derekcollison),
             Ivan Kozlovic <[email protected]> (@kozlovic),
             Waldemar Salinas <[email protected]> (@wallyqs)
GitRepo: https://github.com/nats-io/nats-docker.git
GitCommit: 4a2e6f17092b5b8481637c1881f781ae25374309

Tags: 1.0.2, latest

Tags: 1.0.3-beta
Architectures: arm32v7, arm64v8
GitFetch: refs/heads/add_arm_arch
GitCommit: e5a46dc648c7ee5aa3817e12171eab5e74718b1c
arm32v7-Directory: arm32v7
arm64v8-Directory: arm64v8

Tags: 1.0.2-nanoserver, nanoserver
Architectures: windows-amd64
Directory: windows/nanoserver
Constraints: nanoserver

Tags: 1.0.2-windowsservercore, windowsservercore
Architectures: windows-amd64
Directory: windows/windowsservercore
Constraints: windowsservercore

@kozlovic
Copy link
Contributor Author

You found the branch I was referring to and did all the work for me. Thanks! and sorry to be a pain ;-)

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

Successfully merging this pull request may close these issues.

4 participants