simplify the Dockerfiles
All checks were successful
Ruby Lint / lint (push) Successful in 21s
Release / docker (push) Successful in 30m37s
Ruby Test / test (push) Successful in 20s

- remove the caching, it's more trouble than it's worth
- use '&&' instead of ';', so it fails earlier
This commit is contained in:
2025-06-28 19:12:09 -05:00
parent 8e3e81978a
commit 93ee859227
2 changed files with 15 additions and 28 deletions

View File

@ -3,8 +3,6 @@ ARG BASE_REGISTRY="docker.io"
FROM ${BASE_REGISTRY}/ruby:${RUBY_VERSION}-alpine AS base
ARG TARGETARCH
ENV RACK_ENV="production" \
BUNDLE_DEPLOYMENT=true \
BUNDLE_PATH="/usr/local/bundle" \
@ -14,23 +12,21 @@ ENV RACK_ENV="production" \
WORKDIR /kubernaut
RUN \
--mount=type=cache,id=var-cache-apk-${TARGETARCH},target=/var/cache/apk,sharing=locked \
apk update -q; \
apk update -q && \
apk add bash jemalloc
FROM base AS build
RUN \
--mount=type=cache,id=var-cache-apk-${TARGETARCH},target=/var/cache/apk,sharing=locked \
apk update -q; \
apk add musl-dev gcc make; \
apk update -q && \
apk add musl-dev gcc make && \
apk add bash jemalloc
COPY Gemfile Gemfile.lock ./
RUN \
--mount=type=cache,id=usr-local-bundle-ruby-cache-${TARGETARCH},target=${BUNDLE_PATH}/ruby/3.4.0/cache,sharing=locked \
bundle install
bundle install && \
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git
COPY . .
@ -39,7 +35,7 @@ FROM base
ENV PORT=4567
RUN \
addgroup --system --gid 666 kubernaut; \
addgroup --system --gid 666 kubernaut && \
adduser --system --uid 666 --ingroup kubernaut --shell /bin/bash --disabled-password kubernaut
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"

View File

@ -4,8 +4,6 @@ ARG DEBIAN_VERSION="bookworm"
FROM ${BASE_REGISTRY}/ruby:${RUBY_VERSION}-slim-${DEBIAN_VERSION} AS base
ARG TARGETARCH
ENV RACK_ENV="production" \
BUNDLE_DEPLOYMENT=true \
BUNDLE_PATH="/usr/local/bundle" \
@ -14,30 +12,23 @@ ENV RACK_ENV="production" \
WORKDIR /kubernaut
RUN rm -f /etc/apt/apt.conf.d/docker-clean
RUN \
--mount=type=cache,id=var-cache-apt-${TARGETARCH},target=/var/cache/apt,sharing=locked \
--mount=type=cache,id=var-lib-apt,target=/var/lib/apt,sharing=locked \
apt-get update -qq; \
apt-get install --yes --no-install-recommends \
libjemalloc2
apt-get update -qq && \
apt-get install --yes --no-install-recommends libjemalloc2 && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives
FROM base AS build
RUN \
--mount=type=cache,id=var-cache-apt-${TARGETARCH},target=/var/cache/apt,sharing=locked \
--mount=type=cache,id=var-lib-apt-${TARGETARCH},target=/var/lib/apt,sharing=locked \
apt-get update -qq; \
apt-get install --yes --no-install-recommends \
build-essential
apt-get update -qq && \
apt-get install --yes --no-install-recommends build-essential && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives
COPY Gemfile Gemfile.lock ./
RUN \
--mount=type=cache,id=usr-local-bundle-ruby-cache-${TARGETARCH},target=${BUNDLE_PATH}/ruby/3.4.0/cache,sharing=locked \
bundle install
bundle install && \
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git
COPY . .
@ -46,7 +37,7 @@ FROM base
ENV PORT=4567
RUN \
groupadd --system --gid 666 kubernaut; \
groupadd --system --gid 666 kubernaut && \
useradd --system --uid 666 --gid kubernaut --create-home --shell /bin/bash kubernaut
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"