Skip to content
Snippets Groups Projects
Unverified Commit 9b48e322 authored by Khemissi Amir's avatar Khemissi Amir Committed by GitHub
Browse files

CI: Reducing Greenlight Docker image size (#5073)


* CI: Limited more local files from propagating to image.

* CI: Reduced the image size.

---------

Co-authored-by: default avatarAhmad Farhat <ahmad.af.farhat@gmail.com>
parent 9f2441bd
No related branches found
No related tags found
No related merge requests found
...@@ -4,26 +4,31 @@ ...@@ -4,26 +4,31 @@
README.md README.md
SECURITY.md SECURITY.md
.github .github
.gitlab-ci.yml
.rvmrc
# Rails # Rails
.env* .env*
*.rbc *.rbc
capybara-*.html capybara-*.html
.rspec .rspec
log **/.bundle/
tmp *.dev
.rubocop.yml
log/*
tmp/*
storage/*
/db/**/*.sqlite3 /db/**/*.sqlite3
/db/**/*.sqlite3-journal /db/**/*.sqlite3-journal
/db/production /db/production
/db/production-postgres /db/production-postgres
public/assets public/**/assets/
public/b
coverage/ coverage/
.rvmrc vendor/*
vendor/bundle Dockerfile*
.bundle spec/
Dockerfile test/
.gitlab-ci.yml **/node_modules/
.rubocop.yml app/assets/builds/*
spec dockerfiles/
test !**/.keep
FROM alpine:3.17 AS alpine FROM ruby:alpine3.17 AS base
ARG RAILS_ROOT=/usr/src/app ARG RAILS_ROOT=/usr/src/app
ENV RAILS_ROOT=${RAILS_ROOT} ENV RAILS_ROOT=${RAILS_ROOT}
FROM alpine AS base
WORKDIR $RAILS_ROOT
RUN apk add --no-cache \
libpq \
libxml2 \
libxslt \
ruby \
ruby-irb \
ruby-bigdecimal \
ruby-bundler \
ruby-json \
tzdata \
bash \
shared-mime-info
FROM base
RUN apk add --no-cache \
build-base \
curl-dev \
git \
gettext \
imagemagick \
libxml2-dev \
libxslt-dev \
pkgconf \
postgresql-dev \
ruby-dev \
nodejs npm \
yarn \
yaml-dev \
zlib-dev \
&& ( echo 'install: --no-document' ; echo 'update: --no-document' ) >>/etc/gemrc
COPY . ./
RUN bundle install -j4 \
&& yarn install
ARG RAILS_ENV ARG RAILS_ENV
ENV RAILS_ENV=${RAILS_ENV:-production} ENV RAILS_ENV=${RAILS_ENV:-production}
ARG NODE_ENV
ENV NODE_ENV=${RAILS_ENV}
ARG RAILS_LOG_TO_STDOUT ARG RAILS_LOG_TO_STDOUT
ENV RAILS_LOG_TO_STDOUT=${RAILS_LOG_TO_STDOUT:-true} ENV RAILS_LOG_TO_STDOUT=${RAILS_LOG_TO_STDOUT:-true}
ARG RAILS_SERVE_STATIC_FILES ARG RAILS_SERVE_STATIC_FILES
ENV RAILS_SERVE_STATIC_FILES=${RAILS_SERVE_STATIC_FILES:-true} ENV RAILS_SERVE_STATIC_FILES=${RAILS_SERVE_STATIC_FILES:-true}
ARG PORT ARG PORT
ENV PORT=${PORT:-3000} ENV PORT=${PORT:-3000}
EXPOSE ${PORT}
ARG VERSION_TAG ARG VERSION_TAG
ENV VERSION_TAG=$VERSION_TAG ENV VERSION_TAG=$VERSION_TAG
ENV PATH=$PATH:$RAILS_ROOT/bin
WORKDIR $RAILS_ROOT
RUN bundle config --local deployment 'true' \
&& bundle config --local without 'development:test'
FROM base as build
ARG PACKAGES='alpine-sdk libpq-dev'
COPY Gemfile Gemfile.lock ./
RUN apk update \
&& apk add --update --no-cache ${PACKAGES} \
&& bundle install --no-cache \
&& bundle doctor
FROM base as prod
ARG PACKAGES='libpq-dev tzdata imagemagick yarn bash'
COPY --from=build $RAILS_ROOT/vendor/bundle ./vendor/bundle
COPY package.json yarn.lock ./
RUN apk update \
&& apk add --update --no-cache ${PACKAGES} \
&& yarn install --production --frozen-lockfile \
&& yarn cache clean
COPY . ./
RUN apk update \
&& apk upgrade \
&& update-ca-certificates
EXPOSE ${PORT}
ENTRYPOINT [ "./bin/start" ] ENTRYPOINT [ "./bin/start" ]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment