basecamp / kamal

Deploy web apps anywhere.
https://kamal-deploy.org
MIT License
9.39k stars 359 forks source link

Add --target option to Builder to support multi-stage Docker builds #786

Closed hundredwatt closed 1 month ago

hundredwatt commented 2 months ago

The builder config now supports specifying a target, e.g.:

config/deploy.yml

builder:
  target: prod

for a Dockerfile that's structured like:

ARG RUBY_VERSION=3.2.2
FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base

... etc ...

FROM base as build

... etc ...

FROM base as app

ENTRYPOINT ["/rails/bin/docker-entrypoint"]

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD ["./bin/rails", "server"]

FROM app as prod

ENV RAILS_ENV="production" 

FROM app as staging

ENV RAILS_ENV="staging" 
djmb commented 2 months ago

@hundredwatt - thanks for the PR!

If you could fix up the Rubocop error, I'll get this merged.

hundredwatt commented 2 months ago

@djmb Fixed 👍