a11yist/Dockerfile
david 21ab02d647
Some checks failed
/ Run system tests (push) Waiting to run
/ Build, push and deploy image (push) Blocked by required conditions
/ Run tests (push) Has been cancelled
/ Checkout (push) Successful in 8m9s
Links, mainly...
2024-07-26 00:59:00 +02:00

133 lines
3.1 KiB
Docker

ARG NAME=app
ARG UID=1000
ARG GID=1000
ARG APP_PORT=3000
ARG INSTALL_DIR=/${NAME}
ARG RUBY_VERSION=3.3.4
FROM ruby:${RUBY_VERSION} AS development
ARG NAME
ARG UID
ARG GID
ARG APP_PORT
ARG INSTALL_DIR
LABEL maintainer='david@hohl.cloud'
WORKDIR ${INSTALL_DIR}
ENV GEM_HOME=${INSTALL_DIR}/.bundle
ENV \
LANG=C.UTF-8 \
INSTALL_DIR=${INSTALL_DIR} \
RAILS_ENV=development \
TZ=Europe/Zurich \
PATH=${INSTALL_DIR}/bin:$GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH \
EDITOR=vim
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 && \
apt-get install -yqq --no-install-recommends \
gnupg2 \
curl && \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
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 && \
apt-get clean && \
npm install tabby-agent && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
truncate -s 0 /var/log/*log && \
gem update --system && \
bundle config set app_config ${GEM_HOME}
USER ${NAME}
FROM development AS builder
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
ARG NAME
ARG UID
ARG GID
ARG APP_PORT
ARG INSTALL_DIR
WORKDIR ${INSTALL_DIR}
ENV \
LANG=C.UTF-8 \
INSTALL_DIR=${INSTALL_DIR} \
RAILS_ENV=production \
TZ=Europe/Zurich \
PATH=${INSTALL_DIR}/bin:$GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH
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 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
truncate -s 0 /var/log/*log && \
gem update --system && \
bundle config set app_config ${GEM_HOME}
EXPOSE 3000
ENTRYPOINT [ "bin/entrypoint" ]
COPY . .
COPY --from=builder /app/.bundle /app/.bundle
COPY --from=assets /app/public/assets /app/public/assets
RUN chown -R app:app /app/tmp /app/log /app/storage
RUN date +"%Y-%m-%d %H:%M:%S %Z" >> .build_version
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" ]