Skip to content

Commit

Permalink
Fix Dockerfile issues (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
lyang authored Feb 8, 2025
1 parent aba4a0f commit 263f15a
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions Dockerfile
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"]

0 comments on commit 263f15a

Please sign in to comment.