A lot :)
This commit is contained in:
parent
aad67af0d1
commit
63fc206c27
153 changed files with 2043 additions and 646 deletions
156
Dockerfile
156
Dockerfile
|
|
@ -47,7 +47,7 @@ RUN \
|
|||
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
|
||||
apt-get update -yqq && \
|
||||
apt-get install -yqq --no-install-recommends \
|
||||
sqlite3 nodejs npm sassc yarn libvips fish ranger pandoc && \
|
||||
sqlite3 nodejs npm sassc yarn libvips fish ranger pandoc libjemalloc2 && \
|
||||
apt-get clean && \
|
||||
npm install tabby-agent && \
|
||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
|
||||
|
|
@ -55,26 +55,23 @@ RUN \
|
|||
gem update --system && \
|
||||
bundle config set app_config ${GEM_HOME}
|
||||
|
||||
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2
|
||||
|
||||
USER ${NAME}
|
||||
|
||||
FROM development AS builder
|
||||
RUN mkdir -p ~/.config/fish && echo "set fish_greeting" >> ~/.config/fish/config.fish
|
||||
RUN \
|
||||
echo >> ~/.config/fish/config.fish &&\
|
||||
echo "function fish_prompt" >> ~/.config/fish/config.fish &&\
|
||||
echo " set -l last_status \$status" >> ~/.config/fish/config.fish &&\
|
||||
echo " set -l stat" >> ~/.config/fish/config.fish &&\
|
||||
echo " if test \$last_status -ne 0" >> ~/.config/fish/config.fish &&\
|
||||
echo " set stat (set_color red)\"[\$last_status]\"(set_color normal)" >> ~/.config/fish/config.fish &&\
|
||||
echo " end" >> ~/.config/fish/config.fish &&\
|
||||
echo " string join '' -- (set_color green) (prompt_pwd) (set_color normal) \$stat ' 🐳 '" >> ~/.config/fish/config.fish && \
|
||||
echo "end" >> ~/.config/fish/config.fish
|
||||
|
||||
USER root
|
||||
|
||||
COPY Gemfile Gemfile.lock package.json yarn.lock ./
|
||||
|
||||
RUN bundle install && yarn install
|
||||
|
||||
FROM builder AS assets
|
||||
|
||||
COPY . .
|
||||
|
||||
COPY --from=builder /app/.bundle /app/.bundle
|
||||
COPY --from=builder /app/node_modules /app/node_modules
|
||||
|
||||
RUN RAILS_ENV=production SECRET_KEY_BASE_DUMMY=1 rails assets:precompile
|
||||
|
||||
FROM ruby:${RUBY_VERSION}-slim AS production
|
||||
FROM ruby:${RUBY_VERSION}-alpine AS builder
|
||||
|
||||
ARG NAME
|
||||
ARG UID
|
||||
|
|
@ -84,50 +81,111 @@ ARG INSTALL_DIR
|
|||
|
||||
WORKDIR ${INSTALL_DIR}
|
||||
|
||||
ENV GEM_HOME=${INSTALL_DIR}/.bundle
|
||||
|
||||
ENV \
|
||||
LANG=C.UTF-8 \
|
||||
INSTALL_DIR=${INSTALL_DIR} \
|
||||
RAILS_ENV=production \
|
||||
RAILS_ENV=development \
|
||||
TZ=Europe/Zurich \
|
||||
PATH=${INSTALL_DIR}/bin:$GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH
|
||||
PATH=${INSTALL_DIR}/bin:$GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH \
|
||||
EDITOR=vim
|
||||
|
||||
ENV GEM_HOME=${INSTALL_DIR}/.bundle
|
||||
|
||||
RUN \
|
||||
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
|
||||
echo $TZ > /etc/timezone && \
|
||||
addgroup --gid ${GID} ${NAME} && \
|
||||
adduser \
|
||||
--gecos GECOS \
|
||||
--home /home/${NAME} \
|
||||
--uid ${UID} \
|
||||
--gid ${GID} \
|
||||
--disabled-password \
|
||||
--disabled-login \
|
||||
--shell /bin/bash \
|
||||
${NAME} && \
|
||||
apt-get update -yqq && \
|
||||
apt-get install -yqq --no-install-recommends \
|
||||
sqlite3 libvips pandoc && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
|
||||
RUN apk add --update --no-cache \
|
||||
binutils-gold \
|
||||
build-base \
|
||||
curl \
|
||||
file \
|
||||
g++ \
|
||||
gcc \
|
||||
git \
|
||||
less \
|
||||
libstdc++ \
|
||||
libffi-dev \
|
||||
libc-dev \
|
||||
linux-headers \
|
||||
libxml2-dev \
|
||||
libxslt-dev \
|
||||
libgcrypt-dev \
|
||||
make \
|
||||
netcat-openbsd \
|
||||
nodejs \
|
||||
openssl \
|
||||
pkgconfig \
|
||||
tzdata \
|
||||
yarn \
|
||||
sqlite \
|
||||
vips-dev \
|
||||
npm \
|
||||
sassc \
|
||||
jemalloc \
|
||||
pandoc-cli \
|
||||
sqlite-libs \
|
||||
build-base && \
|
||||
truncate -s 0 /var/log/*log && \
|
||||
gem update --system && \
|
||||
bundle config set app_config ${GEM_HOME}
|
||||
|
||||
EXPOSE 3000
|
||||
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2
|
||||
|
||||
ENTRYPOINT [ "bin/entrypoint" ]
|
||||
USER ${NAME}
|
||||
|
||||
USER root
|
||||
|
||||
COPY Gemfile Gemfile.lock package.json yarn.lock ./
|
||||
|
||||
RUN bundle config without test development && bundle install && yarn install
|
||||
|
||||
FROM builder AS assets
|
||||
|
||||
COPY . .
|
||||
|
||||
COPY --from=builder /app/.bundle /app/.bundle
|
||||
COPY --from=assets /app/public/assets /app/public/assets
|
||||
COPY --from=builder ${INSTALL_DIR}/.bundle ${INSTALL_DIR}/.bundle
|
||||
COPY --from=builder ${INSTALL_DIR}/node_modules ${INSTALL_DIR}/node_modules
|
||||
|
||||
RUN chown -R app:app /app/tmp /app/log /app/storage
|
||||
RUN date +"%Y-%m-%d %H:%M:%S %Z" >> .build_version
|
||||
RUN RAILS_ENV=production SECRET_KEY_BASE_DUMMY=1 rails assets:precompile
|
||||
|
||||
FROM ruby:${RUBY_VERSION}-alpine AS production
|
||||
|
||||
ARG INSTALL_DIR
|
||||
ARG NAME
|
||||
|
||||
WORKDIR ${INSTALL_DIR}
|
||||
|
||||
ENV GEM_HOME=${INSTALL_DIR}/.bundle
|
||||
|
||||
ENV \
|
||||
RAILS_ENV=production \
|
||||
PATH=${INSTALL_DIR}/bin:$GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH \
|
||||
TZ=Europe/Zurich
|
||||
|
||||
RUN \
|
||||
adduser ${NAME} --disabled-password --shell /bin/ash && \
|
||||
apk add --update --no-cache \
|
||||
tzdata \
|
||||
sqlite \
|
||||
vips-dev \
|
||||
jemalloc && \
|
||||
gem update --system && \
|
||||
bundle config set app_config ${GEM_HOME} && \
|
||||
bundle config set without development test && \
|
||||
apk add patchelf && \
|
||||
patchelf --add-needed libjemalloc.so.2 /usr/local/bin/ruby && \
|
||||
apk del patchelf && \
|
||||
truncate -s 0 /var/log/*log
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
COPY . .
|
||||
|
||||
COPY --from=builder ${INSTALL_DIR}/.bundle ${INSTALL_DIR}/.bundle
|
||||
COPY --from=assets ${INSTALL_DIR}/public/assets ${INSTALL_DIR}/public/assets
|
||||
|
||||
RUN chown -R ${NAME}:${NAME} ${INSTALL_DIR}/tmp ${INSTALL_DIR}/log ${INSTALL_DIR}/storage && \
|
||||
date +"%Y-%m-%d %H:%M:%S %Z" >> .build_version
|
||||
|
||||
USER ${NAME}
|
||||
|
||||
ENTRYPOINT [ "bin/entrypoint" ]
|
||||
|
||||
USER app
|
||||
# Using variables in command list is not possible:
|
||||
# https://stackoverflow.com/questions/40454470/how-can-i-use-a-variable-inside-a-dockerfile-cmd
|
||||
CMD [ "rails", "server", "--binding", "0.0.0.0", "--no-daemon", "--port" , "3000" ]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue