-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
27 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,38 @@ | ||
ARG BASE_IMAGE=ruby:3.4-alpine | ||
ARG RUBY_VERSION=3.4.1 | ||
ARG APP_ROOT=/app | ||
|
||
FROM $BASE_IMAGE AS build-env | ||
# base | ||
FROM docker.io/library/ruby:$RUBY_VERSION-alpine AS base | ||
ARG APP_ROOT | ||
WORKDIR $APP_ROOT | ||
WORKDIR "$APP_ROOT" | ||
RUN apk update && apk upgrade && \ | ||
apk add build-base && \ | ||
rm -rf /var/cache/apk/* | ||
COPY Gemfile* ./ | ||
RUN bundle install --without=development test | ||
ENV BUNDLE_DEPLOYMENT="1" | ||
ENV BUNDLE_PATH="/usr/local/bundle" | ||
ENV BUNDLE_WITHOUT="development" | ||
|
||
FROM $BASE_IMAGE AS final | ||
# build | ||
FROM base AS build | ||
RUN apk update && apk upgrade && \ | ||
apk add build-base && \ | ||
rm -rf /var/cache/apk/* | ||
COPY Gemfile Gemfile.lock ./ | ||
RUN bundle install && \ | ||
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git | ||
|
||
# final | ||
FROM base | ||
ARG APP_ROOT | ||
ARG BUILD_DATE | ||
ARG SOURCE | ||
ARG REVISION | ||
ARG BUNDLE_DIR=/usr/local/bundle | ||
LABEL org.opencontainers.image.licenses="MIT" | ||
LABEL org.opencontainers.image.title="SamlProxy" | ||
LABEL org.opencontainers.image.created="$BUILD_DATE" | ||
LABEL org.opencontainers.image.source="$SOURCE" | ||
LABEL org.opencontainers.image.revision="$REVISION" | ||
WORKDIR $APP_ROOT | ||
COPY --from=build-env $BUNDLE_DIR $BUNDLE_DIR | ||
COPY . . | ||
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}" | ||
COPY --from=build "${APP_ROOT}" "${APP_ROOT}" | ||
COPY helpers ./helpers | ||
COPY config ./config | ||
COPY config.ru saml_proxy.rb LICENSE "$APP_ROOT" | ||
RUN addgroup --system --gid 1000 samlproxy && \ | ||
adduser --system --uid 1000 samlproxy --ingroup samlproxy && \ | ||
chown -R samlproxy:samlproxy "$APP_ROOT" | ||
USER samlproxy | ||
ENV RACK_ENV=production | ||
ENV PORT=9292 | ||
CMD ["bundle", "exec", "puma"] |