teracyhq / docker-files

Teracy docker-files project to build common Docker images
https://hub.docker.com/r/teracy/
MIT License
92 stars 55 forks source link

added parameter for node version #38

Closed M3ssman closed 7 years ago

M3ssman commented 7 years ago

to be able to build images for different node versions defaults to "8"

CLAassistant commented 7 years ago

CLA assistant check
All committers have signed the CLA.

hoatle commented 7 years ago

thank you @M3ssman for your pull request changes, however, we got the error here:

Step 1/21 : FROM node:$NODE_VERSION
Error parsing reference: "node:$NODE_VERSION" is not a valid repository/tag: invalid reference format

Did you test the changes locally? How did you build that new image?

M3ssman commented 7 years ago

Hello hoatle, thank for your remarks. Follwing the Instructions from docker commandline I use the --build-args Flag to set the Parameter at Build Time. According to the Docker Reference, the build-args / ARG can be used this way. So for my use-case, building Test Containers with different node Versions (6 / 7 / 8), this works pretty well. I don't know how your Tests are configured and what they assume about the Dockerfiles or Dockerfile-Reference. I'm using the latest Docker Version (2017.06), maybe it is related to this?

hoatle commented 7 years ago

Hello @M3ssman, let me know your command terminal output, mine did not work as following:

vagrant@teracy:~/workspace/docker-files/angular-cli/base$ docker version
Client:
 Version:      17.06.0-ce
 API version:  1.30
 Go version:   go1.8.3
 Git commit:   02c1d87
 Built:        Fri Jun 23 21:23:31 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.06.0-ce
 API version:  1.30 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   02c1d87
 Built:        Fri Jun 23 21:19:04 2017
 OS/Arch:      linux/amd64
 Experimental: false
vagrant@teracy:~/workspace/docker-files/angular-cli/base$ docker image build -t hoatle/angular-cli --build-arg NODE_VERSION=8 .
Sending build context to Docker daemon  5.632kB
Step 1/21 : FROM node:$NODE_VERSION
invalid reference format
hoatle commented 7 years ago

hello @M3ssman, I see the problem. ARG must be put before FROM. This works:

ARG NODE_VERSION=8

FROM node:$NODE_VERSION

Could you check and update the PR to make it work? Thank you.

M3ssman commented 7 years ago

hello @hoatle , pardon me, it is exactly as you pointed out. When build on a regular Ubuntu Docker-Host, it complains like you mentioned. My first attempt was based on Docker Toolbox for Windows (on Windows 10), which didn't complain about the Order, but I recently reproduced the Behavior on a Ubuntu 16.04 Host and it crashed like you reported. Strange, isn't it?.

Anyway, the Travis CI is still not going with the updated PR ...

M3ssman commented 7 years ago

hello @hoatle , the Travis is running a 17.03 Docker Version, looks like this one is not working with the ARG before FROM. According to Docs, this feature requires at least 17.05.0-ce (2017-05-04).

hoatle commented 7 years ago

@M3ssman please install the latest Docker version following this example https://github.com/acme101/ror-starter/blob/develop/.travis.yml#L20-L21