a11yist/Dockerfile

225 lines
5 KiB
Text
Raw Normal View History

ARG NAME=app
ARG UID=1000
ARG GID=1000
ARG APP_PORT=3000
ARG INSTALL_DIR=/${NAME}
2024-10-26 00:00:56 +02:00
ARG RUBY_VERSION=3.2.5
2024-07-22 03:27:58 +02:00
FROM ruby:${RUBY_VERSION} AS development
2024-07-20 16:52:12 +02:00
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 \
2024-09-05 22:54:38 +02:00
sqlite3 nodejs npm sassc yarn libvips fish ranger pandoc libjemalloc2 && \
apt-get clean && \
2024-07-26 00:59:00 +02:00
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}
2024-09-05 22:54:38 +02:00
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2
2024-11-17 00:46:01 +01:00
ARG HELIX_VERSION=24.07
RUN curl -L https://github.com/helix-editor/helix/releases/download/${HELIX_VERSION}/helix-${HELIX_VERSION}-x86_64-linux.tar.xz -o /tmp/helix.tar.xz && \
cd /opt/ && \
tar -xf /tmp/helix.tar.xz && \
ln -s /opt/helix-${HELIX_VERSION}-x86_64-linux/hx /usr/local/bin chmod +x /usr/local/bin/
2024-09-05 22:54:38 +02:00
2024-07-23 01:14:23 +02:00
USER ${NAME}
2024-11-17 00:46:01 +01:00
RUN mkdir -p ~/.config/fish ~/.config/helix
COPY <<FISH /home/app/.config/fish/config.fish
set fish_greeting
function fish_prompt
set -l last_status \$status
set -l stat
if test \$last_status -ne 0
set stat (set_color red)\
end
string join '' -- (set_color green) (prompt_pwd) (set_color normal) \$stat ' 🐳 '
end
FISH
COPY <<LANGS /home/app/.config/helix/languages.toml
[[language]]
name = "ruby"
shebangs = ["ruby"]
roots = ["Gemfile.lock"]
language-servers = [ "ruby-lsp" ]
auto-format = true
[language-server.ruby-lsp]
command = "ruby-lsp"
args = ["--debug"]
LANGS
COPY <<CONF /home/app/.config/helix/config.toml
theme = "gruvbox_dark_hard"
[editor]
true-color = true
CONF
CMD ["/usr/bin/fish", "-l"]
2024-09-05 22:54:38 +02:00
FROM ruby:${RUBY_VERSION}-alpine AS builder
ARG NAME
ARG UID
ARG GID
ARG APP_PORT
ARG INSTALL_DIR
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 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}
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2
USER ${NAME}
2024-07-20 16:52:12 +02:00
2024-07-23 01:14:23 +02:00
USER root
2024-07-20 16:52:12 +02:00
COPY Gemfile Gemfile.lock package.json yarn.lock ./
2024-09-05 22:54:38 +02:00
RUN bundle config without test development && bundle install && yarn install
2024-07-20 16:52:12 +02:00
FROM builder AS assets
COPY . .
2024-09-05 22:54:38 +02:00
COPY --from=builder ${INSTALL_DIR}/.bundle ${INSTALL_DIR}/.bundle
COPY --from=builder ${INSTALL_DIR}/node_modules ${INSTALL_DIR}/node_modules
2024-07-20 16:52:12 +02:00
RUN RAILS_ENV=production SECRET_KEY_BASE_DUMMY=1 rails assets:precompile
2024-09-05 22:54:38 +02:00
FROM ruby:${RUBY_VERSION}-alpine AS production
2024-07-20 16:52:12 +02:00
2024-09-05 22:54:38 +02:00
ARG INSTALL_DIR
2024-07-20 16:52:12 +02:00
ARG NAME
WORKDIR ${INSTALL_DIR}
2024-09-05 22:54:38 +02:00
ENV GEM_HOME=${INSTALL_DIR}/.bundle
2024-07-20 16:52:12 +02:00
ENV \
RAILS_ENV=production \
2024-09-05 22:54:38 +02:00
PATH=${INSTALL_DIR}/bin:$GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH \
TZ=Europe/Zurich
2024-07-20 16:52:12 +02:00
RUN \
2024-09-05 22:54:38 +02:00
adduser ${NAME} --disabled-password --shell /bin/ash && \
apk add --update --no-cache \
tzdata \
sqlite \
vips-dev \
jemalloc && \
2024-07-20 16:52:12 +02:00
gem update --system && \
2024-09-05 22:54:38 +02:00
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
2024-07-20 16:52:12 +02:00
EXPOSE 3000
2024-07-20 16:52:12 +02:00
COPY . .
2024-09-05 22:54:38 +02:00
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
2024-07-20 16:52:12 +02:00
2024-09-05 22:54:38 +02:00
USER ${NAME}
ENTRYPOINT [ "bin/entrypoint" ]
2024-07-22 04:55:30 +02:00
CMD [ "rails", "server", "--binding", "0.0.0.0", "--no-daemon", "--port" , "3000" ]