Dockerfile describes the steps used to create a Build from your
FROM ubuntu:18.04 COPY . . RUN ["deps", "install"] CMD ["bin/start"]
||defines the base image|
||add files from the local directory tree|
||execute a command|
||defines the default command to run on this image|
||define build variables|
Optimizing Build Times
Each line of a
Dockerfile will be cached as long as files referenced by it are not changed. This allows you
to cache expensive steps such as dependency installation by selectively copying files before running commands.
The following example selectively copies only the files needed to run
npm before installing dependencies.
FROM nodejs COPY package.json package-lock.json . RUN ["npm", "install"] COPY . . CMD ["npm", "start"]
npm install will be cached on successive builds unless
package-lock.json is changed.
Convox respects the
ARG directive, allowing you to specify variables at build time.
This is useful for creating dynamic build environments, allowing you to use the same Dockerfile for varying deployments.
It is not recommended to use build variables for passing secrets. Values for build variables are embedded in the resulting image.
You can declare build variables using the
ARG directive with an optional default value:
ARG COPYRIGHT=2020 ARG RUBY_VERSION
Values for these variables will be read from the Environment at build time:
$ convox env set RUBY_VERSION=2.6.4