1- ARG RUBY_BASE_IMAGE=ruby:4.0.1-alpine3.23
1+ ARG RUBY_BASE_IMAGE=ruby:4.0.1-alpine3.23@sha256:7d1c4a23da9b3539fdeb5f970950a8fe044a707219e546f12152b84bbd5755d1
2+ ARG NODE_BASE_IMAGE=node:22-alpine@sha256:8094c002d08262dba12645a3b4a15cd6cd627d30bc782f53229a2ec13ee22a00
23
34# Stage 1: Frontend Build
4- FROM node:22-alpine AS frontend-builder
5+ FROM ${NODE_BASE_IMAGE} AS frontend-builder
56
67WORKDIR /app/frontend
78COPY frontend/package*.json ./
@@ -31,7 +32,11 @@ RUN apk add --no-cache \
3132 && gem install bundler:$(tail -1 Gemfile.lock | tr -d ' ' ) \
3233 && bundle config set --local without 'development test' \
3334 && bundle install --retry=5 --jobs=$(nproc) \
34- && bundle binstubs bundler html2rss
35+ && bundle binstubs bundler html2rss \
36+ && bundle clean --force \
37+ && rm -rf /usr/local/bundle/cache \
38+ /usr/local/bundle/bundler/gems/*/.git \
39+ /usr/local/bundle/cache/bundler/git
3540
3641# Stage 3: Runtime
3742FROM ${RUBY_BASE_IMAGE}
@@ -47,20 +52,24 @@ ENV PORT=4000 \
4752EXPOSE $PORT
4853
4954HEALTHCHECK --interval=30m --timeout=60s --start-period=5s \
50- CMD TOKEN="${HEALTH_CHECK_TOKEN:-CHANGE_ME_HEALTH_CHECK_TOKEN}" && \
51- curl -f -H "Authorization: Bearer ${TOKEN}" http://localhost:${PORT}/api/v1/health || exit 1
55+ CMD ruby -rnet/http -e ' \
56+ port = ENV.fetch("PORT", "4000") \
57+ token = ENV.fetch("HEALTH_CHECK_TOKEN", "CHANGE_ME_HEALTH_CHECK_TOKEN") \
58+ uri = URI("http://localhost:#{port}/api/v1/health") \
59+ request = Net::HTTP::Get.new(uri) \
60+ request["Authorization"] = "Bearer #{token}" \
61+ response = Net::HTTP.start(uri.hostname, uri.port) { |http| http.request(request) } \
62+ exit(response.is_a?(Net::HTTPSuccess) ? 0 : 1) \
63+ '
5264
5365ARG USER=html2rss
5466ARG UID=991
5567ARG GID=991
5668
5769RUN apk add --no-cache \
5870 'ca-certificates>=2024' \
59- 'curl>=8' \
60- 'gcompat>=0' \
6171 'tzdata>=2024' \
62- 'libxml2>=2' \
63- 'libxslt>=1' \
72+ && apk upgrade --no-cache zlib \
6473 && addgroup --gid "$GID" "$USER" \
6574 && adduser \
6675 --disabled-password \
@@ -79,7 +88,10 @@ WORKDIR /app
7988USER html2rss
8089
8190COPY --from=builder /usr/local/bundle /usr/local/bundle
82- COPY --chown=$USER:$USER . /app
91+ COPY --chown=$USER:$USER Gemfile Gemfile.lock app.rb config.ru ./
92+ COPY --chown=$USER:$USER app ./app
93+ COPY --chown=$USER:$USER config ./config
94+ COPY --chown=$USER:$USER public ./public
8395COPY --from=frontend-builder --chown=$USER:$USER /app/public/frontend ./public/frontend
8496
8597CMD ["bundle" , "exec" , "puma" , "-C" , "./config/puma.rb" ]
0 commit comments