Docker Build Args

Build Args

You can also customize the Docker build args. Here’s an example:

config/jets/deploy.rb

Jets.deploy.configure do
  config.dockerfile.build_args.at_top = {
    "BUILD_ARG1" => "value1",
  }
  config.dockerfile.build_args.build_stage = {
    "BUILD_ARG2" => "value2",
  }
  config.dockerfile.build_args.deployment_stage = {
    "BUILD_ARG3" => "value3",
  }
end

The build args are added to near the top of different sections of the multi-stage Dockerfile, after Jets installs system packages, and user custom packages.

Dockerfile

ARG BUILD_ARG1 # <===== ADDED
FROM ruby:3.2.3-slim as base
# ...
FROM base as build
RUN apt-get update && apt-get install -y build-essential
ARG BUILD_ARG2 # <===== ADDED
RUN bundle install
# ...

FROM base as deployment
RUN apt-get update && apt-get install -y curl
ARG BUILD_ARG3 # <===== ADDED
COPY --from=build /usr/local/bundle /usr/local/bundle
# ...

ENTRYPOINT [ "aws_lambda_ric" ]
CMD [ "handlers/controller.lambda_handler" ]

Docker Build

Jets will then call:

docker build --build-arg BUILD_ARG1=value1 --build-arg BUILD_ARG2=value2 --build-arg BUILD_ARG2=value2 ...