simplify the Dockerfiles
- remove the caching, it's more trouble than it's worth - use '&&' instead of ';', so it fails earlier
This commit is contained in:
@ -3,8 +3,6 @@ ARG BASE_REGISTRY="docker.io"
|
|||||||
|
|
||||||
FROM ${BASE_REGISTRY}/ruby:${RUBY_VERSION}-alpine AS base
|
FROM ${BASE_REGISTRY}/ruby:${RUBY_VERSION}-alpine AS base
|
||||||
|
|
||||||
ARG TARGETARCH
|
|
||||||
|
|
||||||
ENV RACK_ENV="production" \
|
ENV RACK_ENV="production" \
|
||||||
BUNDLE_DEPLOYMENT=true \
|
BUNDLE_DEPLOYMENT=true \
|
||||||
BUNDLE_PATH="/usr/local/bundle" \
|
BUNDLE_PATH="/usr/local/bundle" \
|
||||||
@ -14,23 +12,21 @@ ENV RACK_ENV="production" \
|
|||||||
WORKDIR /kubernaut
|
WORKDIR /kubernaut
|
||||||
|
|
||||||
RUN \
|
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
|
apk add bash jemalloc
|
||||||
|
|
||||||
FROM base AS build
|
FROM base AS build
|
||||||
|
|
||||||
RUN \
|
RUN \
|
||||||
--mount=type=cache,id=var-cache-apk-${TARGETARCH},target=/var/cache/apk,sharing=locked \
|
apk update -q && \
|
||||||
apk update -q; \
|
apk add musl-dev gcc make && \
|
||||||
apk add musl-dev gcc make; \
|
|
||||||
apk add bash jemalloc
|
apk add bash jemalloc
|
||||||
|
|
||||||
COPY Gemfile Gemfile.lock ./
|
COPY Gemfile Gemfile.lock ./
|
||||||
|
|
||||||
RUN \
|
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 . .
|
COPY . .
|
||||||
|
|
||||||
@ -39,7 +35,7 @@ FROM base
|
|||||||
ENV PORT=4567
|
ENV PORT=4567
|
||||||
|
|
||||||
RUN \
|
RUN \
|
||||||
addgroup --system --gid 666 kubernaut; \
|
addgroup --system --gid 666 kubernaut && \
|
||||||
adduser --system --uid 666 --ingroup kubernaut --shell /bin/bash --disabled-password kubernaut
|
adduser --system --uid 666 --ingroup kubernaut --shell /bin/bash --disabled-password kubernaut
|
||||||
|
|
||||||
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
|
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
|
||||||
|
@ -4,8 +4,6 @@ ARG DEBIAN_VERSION="bookworm"
|
|||||||
|
|
||||||
FROM ${BASE_REGISTRY}/ruby:${RUBY_VERSION}-slim-${DEBIAN_VERSION} AS base
|
FROM ${BASE_REGISTRY}/ruby:${RUBY_VERSION}-slim-${DEBIAN_VERSION} AS base
|
||||||
|
|
||||||
ARG TARGETARCH
|
|
||||||
|
|
||||||
ENV RACK_ENV="production" \
|
ENV RACK_ENV="production" \
|
||||||
BUNDLE_DEPLOYMENT=true \
|
BUNDLE_DEPLOYMENT=true \
|
||||||
BUNDLE_PATH="/usr/local/bundle" \
|
BUNDLE_PATH="/usr/local/bundle" \
|
||||||
@ -14,30 +12,23 @@ ENV RACK_ENV="production" \
|
|||||||
|
|
||||||
WORKDIR /kubernaut
|
WORKDIR /kubernaut
|
||||||
|
|
||||||
RUN rm -f /etc/apt/apt.conf.d/docker-clean
|
|
||||||
|
|
||||||
RUN \
|
RUN \
|
||||||
--mount=type=cache,id=var-cache-apt-${TARGETARCH},target=/var/cache/apt,sharing=locked \
|
apt-get update -qq && \
|
||||||
--mount=type=cache,id=var-lib-apt,target=/var/lib/apt,sharing=locked \
|
apt-get install --yes --no-install-recommends libjemalloc2 && \
|
||||||
apt-get update -qq; \
|
rm -rf /var/lib/apt/lists /var/cache/apt/archives
|
||||||
apt-get install --yes --no-install-recommends \
|
|
||||||
libjemalloc2
|
|
||||||
|
|
||||||
|
|
||||||
FROM base AS build
|
FROM base AS build
|
||||||
|
|
||||||
RUN \
|
RUN \
|
||||||
--mount=type=cache,id=var-cache-apt-${TARGETARCH},target=/var/cache/apt,sharing=locked \
|
apt-get update -qq && \
|
||||||
--mount=type=cache,id=var-lib-apt-${TARGETARCH},target=/var/lib/apt,sharing=locked \
|
apt-get install --yes --no-install-recommends build-essential && \
|
||||||
apt-get update -qq; \
|
rm -rf /var/lib/apt/lists /var/cache/apt/archives
|
||||||
apt-get install --yes --no-install-recommends \
|
|
||||||
build-essential
|
|
||||||
|
|
||||||
COPY Gemfile Gemfile.lock ./
|
COPY Gemfile Gemfile.lock ./
|
||||||
|
|
||||||
RUN \
|
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 . .
|
COPY . .
|
||||||
|
|
||||||
@ -46,7 +37,7 @@ FROM base
|
|||||||
ENV PORT=4567
|
ENV PORT=4567
|
||||||
|
|
||||||
RUN \
|
RUN \
|
||||||
groupadd --system --gid 666 kubernaut; \
|
groupadd --system --gid 666 kubernaut && \
|
||||||
useradd --system --uid 666 --gid kubernaut --create-home --shell /bin/bash kubernaut
|
useradd --system --uid 666 --gid kubernaut --create-home --shell /bin/bash kubernaut
|
||||||
|
|
||||||
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
|
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
|
||||||
|
Reference in New Issue
Block a user