Last active
May 7, 2019 14:38
-
-
Save ohadlevy/696cbb38346e5619fd45fe9aa35ed802 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
fedora:30 as base | |
ARG RUBY_MODULE="ruby:2.6" | |
ARG NODEJS_MODULE="nodejs:11" | |
ARG HOME=/home/foreman | |
RUN echo "tsflags=nodocs" >> /etc/dnf/dnf.conf && dnf -y upgrade && dnf -y module install ${RUBY_MODULE} ${NODEJS_MODULE} && dnf -y install mysql-libs mariadb-connector-c postgresql-libs ruby{,gems} rubygem-{rake,bundler} nc hostname && dnf clean all && rm -rf /var/cache/dnf/ | |
WORKDIR $HOME | |
RUN groupadd -r foreman -f -g 1001 && useradd -u 1001 -r -g foreman -d $HOME -s /sbin/nologin -c "Foreman Application User" foreman && chown -R 1001:1001 $HOME | |
COPY entrypoint.sh /usr/bin/ | |
RUN chmod +x /usr/bin/entrypoint.sh | |
ENTRYPOINT entrypoint.sh | |
builder | |
FROM base as builder | |
ARG HOME=/home/foreman | |
ARG RAILS_ENV=production | |
ARG FOREMAN_APIPIE_LANGS=en | |
ARG BUNDLER_SKIPPED_GROUPS="test development openid libvirt journald" | |
RUN dnf -y install redhat-rpm-config git gcc-c++ make bzip2 libxml2-devel libcurl-devel ruby-devel mysql-devel postgresql-devel libsq3-devel && dnf clean all && rm -rf /var/cache/dnf/ | |
ENV DATABASE_URL sqlite3:tmp/bootstrap-db.sql | |
USER 1001 | |
WORKDIR $HOME | |
RUN mkdir bundler.d && mkdir config | |
COPY Gemfile ${HOME} | |
COPY bundler.d/* bundler.d/ | |
RUN echo gem \"rdoc\" > bundler.d/container.rb | |
COPY config/boot* config/ | |
RUN entrypoint.sh bundle install --without "${BUNDLER_SKIPPED_GROUPS}" --path vendor --jobs 5 --retry 3 && rm -rf vendor/ruby/*/cache/*.gem && find vendor/ruby/*/gems -name "*.c" -delete && find vendor/ruby/*/gems -name "*.o" -delete | |
COPY package.json ${HOME} | |
RUN entrypoint.sh npm install --ignore-scripts --no-optional | |
COPY --chown=1001:1001 . ${HOME}/ | |
RUN entrypoint.sh bundle update | |
RUN entrypoint.sh npm install --no-optional && entrypoint.sh npm rebuild node-sass --force | |
RUN entrypoint.sh bundle exec rake assets:clean assets:precompile db:migrate && entrypoint.sh bundle exec rake db:seed apipie:cache:index && rm tmp/bootstrap-db.sql | |
RUN entrypoint.sh ./node_modules/webpack/bin/webpack.js --config config/webpack.config.js && entrypoint.sh npm run analyze && rm -rf public/webpack/stats.json | |
CMD "bundle exec bin/rails server" | |
FROM base | |
ARG HOME=/home/foreman | |
ARG RAILS_ENV=production | |
ENV RAILS_SERVE_STATIC_FILES true | |
ENV RAILS_LOG_TO_STDOUT true | |
USER 1001 | |
WORKDIR ${HOME} | |
COPY --chown=1001:0 . ${HOME}/ | |
RUN echo gem \"rdoc\" > bundler.d/container.rb | |
COPY --from=builder /usr/bin/entrypoint.sh /usr/bin/entrypoint.sh | |
COPY --from=builder --chown=1001:1001 ${HOME}/.bundle/config ${HOME}/.bundle/config | |
COPY --from=builder --chown=1001:1001 ${HOME}/Gemfile.lock ${HOME}/Gemfile.lock | |
COPY --from=builder ${HOME}/vendor/ruby ${HOME}/vendor/ruby | |
COPY --from=builder ${HOME}/public ${HOME}/public | |
RUN sed -i 's/\"production.\log\"/STDOUT/' config/logging.yaml | |
RUN date -u > BUILD_TIME | |
CMD "bundle exec bin/rails server" | |
EXPOSE 3000/tcp | |
EXPOSE 5910-5930/tcp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment