dokku: Problem to set variables for the Dockerfile file
Does the way to set variables for the Dockerfile file still apply for latest version of Dokku? I use Dokku version 0.9.4. I saw the issue https://github.com/dokku/dokku/issues/1860 but I can’t make this approach work, i.e. can’t get the variable into the file…
Here is the command I use:
dokku docker-options:add myapp build '--build-arg "NG_ENV=prod"'
and in my Dockerfile file:
FROM node:6.9.2
ARG NG_ENV
RUN mkdir -p /app
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY . /usr/src/app
COPY package.json /usr/src/app/
RUN npm install
RUN $(npm bin)/ng build --aot --environment ${NG_ENV}
EXPOSE 3000
CMD [ "npm", "start" ]
I have nothing in the NG_ENV
variable…
Thanks very much for your help!
Additional hints
uname -a: Linux prod-myapp 4.4.0-77-generic #98-Ubuntu SMP Wed Apr 26 08:34:02 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
free -m:
total used free shared buff/cache available
Mem: 992 163 107 10 721 611
Swap: 0 0 0
docker version:
Client:
Version: 17.05.0-ce
API version: 1.29
Go version: go1.7.5
Git commit: 89658be
Built: Thu May 4 22:10:54 2017
OS/Arch: linux/amd64
Server:
Version: 17.05.0-ce
API version: 1.29 (minimum version 1.12)
Go version: go1.7.5
Git commit: 89658be
Built: Thu May 4 22:10:54 2017
OS/Arch: linux/amd64
Experimental: false
docker -D info:
Containers: 1
Running: 1
Paused: 0
Stopped: 0
Images: 10
Server Version: 17.05.0-ce
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 31
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 9048e5e50717ea4497b757314bad98ea3763c145
runc version: 9c2d8d184e5da67c95d601382adf14862e4f2228
init version: 949e6fa
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.4.0-77-generic
Operating System: Ubuntu 16.04.2 LTS
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 992.4MiB
Name: prod-myapp
ID: MFYU:LFXZ:JRNE:MGZT:L5RC:AYRW:PUQW:O37A:3RUC:L3OK:2CCB:HRZV
Docker Root Dir: /var/lib/docker
Debug Mode (client): true
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
sigil -v: 0.4.0
docker run -ti gliderlabs/herokuish:latest herokuish version:
herokuish: 0.3.28
buildpacks:
heroku-buildpack-multi v1.0.0
heroku-buildpack-ruby v158
heroku-buildpack-nodejs v99
heroku-buildpack-clojure v76
heroku-buildpack-python v99
heroku-buildpack-java v51
heroku-buildpack-gradle v21
heroku-buildpack-grails v21
heroku-buildpack-scala v76
heroku-buildpack-play v26
heroku-buildpack-php v121
heroku-buildpack-go v64
heroku-buildpack-erlang fa17af9
buildpack-nginx v8
dokku version: 0.9.4
Output
(with dokku trace on
)
-----> Cleaning up...
-----> Building myapp from dockerfile...
-----> Setting config vars
DOKKU_DOCKERFILE_PORTS: 3000
-----> Setting config vars
DOKKU_DOCKERFILE_CMD: CMD [ "npm", "start" ]
remote: build context to Docker daemon 835.6 kB
Step 1/11 : FROM node:6.9.2
---> faaadb4aaf9b
Step 2/11 : ARG NG_ENV
---> Using cache
---> bc15c7909c3f
Step 3/11 : RUN mkdir -p /app
---> Using cache
---> 91a7d779c29c
Step 4/11 : RUN mkdir -p /usr/src/app
---> Using cache
---> 5fc3f5f03e90
Step 5/11 : WORKDIR /usr/src/app
---> Using cache
---> 4bb567157a2b
Step 6/11 : COPY . /usr/src/app
---> bfee9d3e5980
Removing intermediate container 536fc9df71ab
Step 7/11 : COPY package.json /usr/src/app/
---> ca314023f6d5
Removing intermediate container 4dfac19a8a33
Step 8/11 : RUN npm install
---> Running in 09b6cec7f4bd
(...)
npm info ok
---> 564b3d9851f9
Removing intermediate container 09b6cec7f4bd
Step 9/11 : RUN $(npm bin)/ng build --aot --environment ${NG_ENV}
---> Running in 1e5a1f86c29a
npm info it worked if it ends with ok
npm info using npm@3.10.9
npm info using node@v6.9.2
npm info ok
Environment "" does not exist.
remote: The command '/bin/sh -c $(npm bin)/ng build --aot --environment ${NG_ENV}' returned a non-zero code: 1
remote:
To 178.62.215.242:myapp
! [remote rejected] develop -> master (pre-receive hook declined)
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 16 (10 by maintainers)
Commits related to this issue
- docs: Add documentation around adding build-time configuration variables Refs #2776 Closes #1860 [ci skip] — committed to dokku/dokku by josegonzalez 7 years ago
Could you have a typ0 in your
dokku docker-options
command? It seems like you’re removing the option on build?