Update docker

This commit is contained in:
david 2025-05-16 18:01:29 +02:00
parent b756df38a9
commit 4c31dbbed0
7 changed files with 441 additions and 230 deletions

View file

@ -1,18 +1,17 @@
ARG RUBY_VERSION=3.2.5
FROM ruby:${RUBY_VERSION}
LABEL maintainer='david@hohl.cloud'
ARG RUBY_VERSION=3.4
ARG NAME=app
ARG UID=1000
ARG GID=1000
ARG APP_PORT=3000
ARG INSTALL_DIR=/${NAME}
ARG INSTALL_DIR=/home/${NAME}/src
FROM ruby:${RUBY_VERSION} as development
LABEL maintainer='david@hohl.cloud'
ARG NAME
ARG UID
ARG GID
ARG APP_PORT
ARG INSTALL_DIR
WORKDIR ${INSTALL_DIR}
@ -40,6 +39,7 @@ RUN \
--disabled-login \
--shell /bin/bash \
${NAME} && \
chown -R ${NAME}:${NAME} /home/${NAME} && \
apt-get update && \
apt-get install -yqq --no-install-recommends \
gnupg2 \
@ -48,52 +48,100 @@ 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 libjemalloc2 && \
sqlite3 nodejs npm sassc yarn libvips libjemalloc2 && \
apt-get clean && \
npm i -g vscode-langservers-extracted \
dockerfile-language-server-nodejs \
@microsoft/compose-language-service \
yaml-language-server@next \
bash-language-server \
typescript-language-server typescript && \
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} && \
mkdir -p /home/${NAME}/.ssh && \
echo "|1|MY0IaoqveusfUdYlTFzGnB95mhI=|XyUGTfOoKc7vGP5WTlFwT1RU+5E= ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOLCA3O6oc0+BplWjB5Vi4jPNnGAYo24oANcylCc9i8W\
|1|pYFp+C6PAszoVmLOZliWYonpzC0=|QbeRMKsmnFBrqoH38UKkjZdISJI= ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC2PqML1VEXRdMc/WTjjN00FWw2vDl11q+0glBLQwQiBV5r3kL1kXWP7rUtuBPfivz4/ZpzkpHhWbKbnrLazpvSRHqwgMm6S1mQoH4Gb3wLwCqvoE/M8BSJsXvlJem63y/W4mtQEboZ+YyBzW1Yss41jBW9tfQxXCVlikPWm/O20hr3uealymIH5GaONE65mY9JfPr7z6AAJZ8bAfO69HWp+Q1dRD2sin3/cY+a25eQ6PWmR7g/Xw3/6pNikOj2LMErZdyCxVhCKmHeDDrWzn8qJgfPRqz9Pneb3qIBOw6kJnTfQGc+7KLZmmqRUChoLuw5jTYthngZVXJ/A0XJG30mqtrQj9uD7vqmTFXZl8wNuv52ELOwPrvJIpEFvjjNGbg8iRkjElHKub8eGvQhy/sH96Xv6WqxfGiXvyUTWrBOdhhL102fA+nXcsx90Ln0/Rjg5v5meFCT1a+3SLgQeQ44c9xasDwGFrwlR1x4uP8249SldIhKFO+1oXnskTN8Prs=\
|1|FisNvukDUhT0l2SVq4qFF1WFoBQ=|rBWKChHJabb1lM0Og5zcH3lxrOQ= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBPknmThDfyVupOSMcGdjP14VEX6e5rXrI3ny+FnLjaCNyGYt7hKyRTfvl32UVXFZqvp+gp6BVdqaKI6ey5Mygfs=" >> /home/${NAME}/.ssh/known_hosts
bundle config set app_config ${GEM_HOME}
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2
RUN curl -fsSL https://github.com/tamasfe/taplo/releases/latest/download/taplo-full-linux-x86_64.gz \
| gzip -d - | install -m 755 /dev/stdin /usr/local/bin/taplo
# RUN curl -fsSL https://github.com/Feel-ix-343/markdown-oxide/releases/download/v0.24.3/markdown-oxide-v0.24.3-x86_64-unknown-linux-gnu | install -m 755 /dev/stdin /usr/local/bin/markdown-oxide
RUN curl -fsSL https://github.com/artempyanykh/marksman/releases/download/2024-11-20/marksman-linux-x64 | install -m 755 /dev/stdin /usr/local/bin/marksman
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
RUN mkdir -p /home/app/.config/{helix, fish}
RUN mkdir -p /home/app/.config/helix/runtime/queries/slim && \
curl https://raw.githubusercontent.com/kolen/tree-sitter-slim/refs/heads/master/queries/highlights.scm -o /home/app/.config/helix/runtime/queries/slim/highlights.scm && \
curl https://raw.githubusercontent.com/kolen/tree-sitter-slim/refs/heads/master/queries/injections.scm -o /home/app/.config/helix/runtime/queries/slim/injections.scm && \
chown 1000:1000 -R /home/app
RUN mkdir -p /opt/helix-${HELIX_VERSION}-x86_64-linux/runtime/queries/slim && \
curl https://raw.githubusercontent.com/kolen/tree-sitter-slim/refs/heads/master/queries/highlights.scm -o /opt/helix-${HELIX_VERSION}-x86_64-linux/runtime/queries/slim/highlights.scm && \
curl https://raw.githubusercontent.com/kolen/tree-sitter-slim/refs/heads/master/queries/injections.scm -o /opt/helix-${HELIX_VERSION}-x86_64-linux/runtime/queries/slim/injections.scm
COPY bin/dev_entrypoint /usr/local/bin/dev_entrypoint
USER ${NAME}
ENTRYPOINT ["/usr/local/bin/dev_entrypoint"]
CMD ["/bin/sh", "-c", "dev"]
FROM development AS build
USER root
# Wir wollen die bundles nicht im app directory
ENV GEM_HOME=/usr/local/bundle \
BUNDLE_WITHOUT="development test" \
RAILS_ENV=production \
SECRET_KEY_BASE_DUMMY=1
ENV PATH=${INSTALL_DIR}/bin:$GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH
COPY ./Gemfile ./Gemfile.lock ./
RUN bundle config set app_config ${GEM_HOME} && \
bundle config && \
bundle install && \
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
bundle exec bootsnap precompile --gemfile
RUN bundle config
COPY . .
RUN bundle exec bootsnap precompile app/ lib/ && \
rails assets:precompile && \
rm -rf log/* tmp/* && \
chown -R ${NAME}:${NAME} log tmp
FROM ruby:${RUBY_VERSION}-slim AS release
ARG UID
ARG GID
ARG NAME=app
ARG INSTALL_DIR
ARG BUILD_DIR=${INSTALL_DIR}
ARG INSTALL_DIR=/app
ENV GEM_HOME=/usr/local/bundle \
BUNDLE_WITHOUT="development test" \
BUNDLE_SYSTEM=1 \
RAILS_ENV=production \
LANG=C.UTF-8 \
INSTALL_DIR=${INSTALL_DIR} \
TZ=Europe/Zurich
ENV PATH=${INSTALL_DIR}/bin:$GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH
WORKDIR ${INSTALL_DIR}
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
echo $TZ > /etc/timezone && \
adduser --disabled-password --disabled-login ${NAME} &&\
apt-get update -yqq && \
apt-get install -yqq --no-install-recommends \
sqlite3 libjemalloc2 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
gem update --system && \
truncate -s 0 /var/log/*log
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2
RUN pwd
COPY --from=build ${GEM_HOME} ${GEM_HOME}
COPY --from=build ${BUILD_DIR} .
RUN ls -la && chown -R ${NAME}:${NAME} ./tmp ./log ./storage
EXPOSE 3000
ENTRYPOINT ["bin/docker-entrypoint"]
USER ${NAME}
CMD ["./bin/rails", "server", "-b", "0"]