-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #195 from mlibrary/relative_root
Restructure builds to support relative root and CDN
- Loading branch information
Showing
10 changed files
with
134 additions
and
68 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
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,10 +1,11 @@ | ||
/.bundle | ||
/.cache | ||
/.local | ||
/data | ||
/db/*.sqlite3 | ||
/log | ||
/node_modules | ||
**/tmp | ||
!**/.keep | ||
.byebug_history | ||
/solr_logs | ||
/solr_logs |
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,69 +1,135 @@ | ||
FROM ruby:2.7 AS app | ||
ARG RUBY_VERSION=2.7.8 | ||
ARG RUBY_SLIM="-slim" | ||
FROM ruby:${RUBY_VERSION}${RUBY_SLIM} AS base | ||
|
||
ARG UNAME=app | ||
ARG UID=1000 | ||
ARG GID=1000 | ||
#ARG UID 502 | ||
#ARG GID 20 | ||
ARG ARCH=amd64 | ||
|
||
RUN curl https://deb.nodesource.com/setup_16.x | bash | ||
RUN curl https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - | ||
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list | ||
|
||
RUN apt-get update -yqq && \ | ||
apt-get install -yqq --no-install-recommends \ | ||
vim nodejs yarn apt-transport-https \ | ||
ARG BUNDLER_VERSION=2.4.22 | ||
ARG NODE_VERSION=20 | ||
|
||
RUN rm -f /etc/apt/apt.conf.d/docker-clean && \ | ||
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' \ | ||
> /etc/apt/apt.conf.d/keep-cache | ||
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ | ||
--mount=type=cache,target=/var/lib/apt,sharing=locked \ | ||
apt update && apt-get --no-install-recommends install -yq \ | ||
apt-transport-https \ | ||
build-essential \ | ||
curl \ | ||
git \ | ||
unzip \ | ||
libpq-dev \ | ||
##### FIXME: remove these once useless gems are trimmed \ | ||
libmariadb-dev \ | ||
libsqlite3-dev \ | ||
##### What is netcat here for??? | ||
netcat | ||
|
||
RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \ | ||
--mount=type=cache,sharing=locked,target=/var/lib/apt \ | ||
curl -SLO https://deb.nodesource.com/nsolid_setup_deb.sh && \ | ||
chmod 500 nsolid_setup_deb.sh && \ | ||
./nsolid_setup_deb.sh ${NODE_VERSION} && \ | ||
apt-get install nodejs -yq | ||
|
||
RUN gem install bundler:${BUNDLER_VERSION} | ||
|
||
RUN groupadd -g $GID -o $UNAME | ||
RUN useradd -m -d /opt/app -u $UID -g $GID -o -s /bin/bash $UNAME | ||
RUN chown $UID:$GID /opt/app | ||
|
||
ENV RAILS_LOG_TO_STDOUT true | ||
|
||
RUN mkdir /opt/app/data | ||
RUN chown $UID:$GID /opt/app/data | ||
RUN touch /opt/app/data/.keep | ||
WORKDIR /opt/app | ||
COPY Gemfile* . | ||
|
||
############# | ||
FROM base AS base-dev | ||
|
||
RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \ | ||
--mount=type=cache,sharing=locked,target=/var/lib/apt \ | ||
apt-get --no-install-recommends install -yq \ | ||
fd-find \ | ||
less \ | ||
ripgrep \ | ||
vim-tiny | ||
|
||
############ | ||
FROM base AS gems-prod | ||
|
||
RUN --mount=type=cache,id=med-bundle-prod,sharing=locked,target=/vendor/bundle \ | ||
--mount=type=cache,sharing=locked,target=/vendor/cache \ | ||
bundle config set path /vendor/bundle && \ | ||
bundle config set cache_path /vendor/cache && \ | ||
bundle config set cache_all true && \ | ||
bundle config set without 'development test' && \ | ||
bundle config build.sassc --disable-march-tune-native && \ | ||
bundle cache --no-install && \ | ||
bundle install --local && \ | ||
bundle clean && \ | ||
bundle config unset cache_path && \ | ||
bundle config set path /gems && \ | ||
mkdir -p /gems && \ | ||
cp -ar /vendor/bundle/* /gems | ||
|
||
|
||
############# | ||
FROM base-dev AS gems-dev | ||
|
||
RUN --mount=type=cache,id=med-bundle-dev,sharing=locked,target=/vendor/bundle \ | ||
--mount=type=cache,sharing=locked,target=/vendor/cache \ | ||
bundle config set path /vendor/bundle && \ | ||
bundle config set cache_path /vendor/cache && \ | ||
bundle config set cache_all true && \ | ||
bundle cache --no-install && \ | ||
bundle config build.sassc --disable-march-tune-native && \ | ||
bundle install --local && \ | ||
bundle clean && \ | ||
bundle config unset cache_path && \ | ||
bundle config set path /gems && \ | ||
mkdir -p /gems && \ | ||
cp -ar /vendor/bundle/* /gems | ||
|
||
|
||
############# | ||
FROM gems-prod AS production | ||
|
||
ARG RAILS_RELATIVE_URL_ROOT | ||
|
||
COPY . . | ||
RUN chown -R ${UID}:${GID} /gems && chown -R ${UID}:${GID} /opt/app | ||
|
||
|
||
EXPOSE 3000 | ||
USER $UNAME | ||
|
||
### temporarily required to start up/precompile | ||
ENV SOLR_ROOT=bogus | ||
ENV SOLR_COLLECTION=bogus | ||
### | ||
|
||
RUN mkdir /gems | ||
RUN chown $UID:$GID /gems | ||
RUN touch /gems/.keep | ||
ENV RAILS_ENV production | ||
ENV RAILS_SERVE_STATIC_FILES true | ||
ENV SECRET_KEY_BASE 121222bccca | ||
ENV RAILS_RELATIVE_URL_ROOT=${RAILS_RELATIVE_URL_ROOT} | ||
|
||
COPY --chown=$UID:$GID . /opt/app | ||
RUN bin/rails assets:precompile | ||
|
||
ENV BUNDLE_VERSION 2.4.22 | ||
ENV BUNDLE_PATH /gems | ||
RUN gem install bundler:2.4.22 | ||
CMD ["bin/rails", "s", "-b", "0.0.0.0"] | ||
|
||
USER ${UID}:${GID} | ||
WORKDIR /opt/app | ||
|
||
ENV RAILS_RELATIVE_URL_ROOT /m/middle-english-dictionary | ||
ENV RAILS_LOG_TO_STDOUT true | ||
ENV RAILS_ENV production | ||
############ | ||
FROM gems-dev AS development | ||
|
||
# This can be anything but must be set. | ||
ENV SECRET_KEY_BASE 121222bccca | ||
COPY . . | ||
RUN chown -R ${UID}:${GID} /gems && chown -R ${UID}:${GID} /opt/app | ||
|
||
RUN bundle config build.sassc --disable-march-tune-native | ||
RUN bundle config set path /gems | ||
|
||
RUN #bundle config set without 'test development' | ||
RUN bundle install -j 4 | ||
EXPOSE 3000 | ||
USER $UNAME | ||
|
||
# Asset precompilation | ||
# Because of...I don't know why...it wants the SOLR stuff defined | ||
ENV SOLR_ROOT http://solr:8983/ | ||
ENV SOLR_COLLECTION med-preview | ||
ENV RAILS_ROOT /m/middle-english-dictionary | ||
RUN RAILS_ENV=production bin/rails assets:precompile | ||
|
||
#CMD ["sleep", "infinity"] | ||
ENV RAILS_ENV production | ||
CMD ["bin/rails", "s", "-b", "0.0.0.0"] | ||
|
||
#FROM nginx:mainline AS assets | ||
#ENV NGINX_PORT=80 | ||
#ENV NGINX_PREFIX=/ | ||
#COPY --from=app /opt/app/nginx/assets.nginx /etc/nginx/templates/default.conf.template | ||
#COPY --from=app /opt/app/public /usr/share/nginx/html/ |
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
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
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
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
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
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
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