Docker config changes for cli editor

This commit is contained in:
david 2024-11-25 00:06:53 +01:00
parent 297138b0d4
commit b756df38a9
6 changed files with 64 additions and 203 deletions

View file

@ -1,19 +1,20 @@
ARG RUBY_VERSION=3.2.5
FROM ruby:${RUBY_VERSION}
LABEL maintainer='david@hohl.cloud'
ARG NAME=app
ARG UID=1000
ARG GID=1000
ARG APP_PORT=3000
ARG INSTALL_DIR=/${NAME}
ARG RUBY_VERSION=3.2.5
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
@ -24,9 +25,7 @@ ENV \
RAILS_ENV=development \
TZ=Europe/Zurich \
PATH=${INSTALL_DIR}/bin:$GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH \
EDITOR=vim \
RUBY_DEBUG_DAP_SHOW_PROTOCOL=1 \
RUBY_DEBUG_OPEN=true
EDITOR=vim
RUN \
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
@ -51,212 +50,50 @@ RUN \
apt-get install -yqq --no-install-recommends \
sqlite3 nodejs npm sassc yarn libvips fish ranger pandoc libjemalloc2 && \
apt-get clean && \
npm i -g tabby-agent \
vscode-langservers-extracted \
npm i -g vscode-langservers-extracted \
dockerfile-language-server-nodejs \
@microsoft/compose-language-service \
yaml-language-server@next && \
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}
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
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 chmod +x /usr/local/bin/
ln -s /opt/helix-${HELIX_VERSION}-x86_64-linux/hx /usr/local/bin
RUN mkdir -p ~/.config/fish ~/.config/helix
RUN mkdir -p /home/app/.config/{helix, fish}
COPY <<FISH /home/app/.config/fish/config.fish
set fish_greeting
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
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
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
FISH
COPY <<LANGS /home/app/.config/helix/languages.toml
[[language]]
name = "ruby"
shebangs = ["ruby"]
roots = ["Gemfile.lock"]
language-servers = [ "ruby-lsp", "rubocop" ,{ name = "solargraph", except-features = [ "format", "diagnostics" ] }]
auto-format = true
[language.debugger]
command = "rdbg"
args =["-o", "-c"]
name = "debug"
transport = "tcp"
port-arg = "-p {}"
[[language.debugger.templates]]
name = "attach"
request = "attach"
completion = [ "pid" ]
args = { attachCommands = ["rdbg --attach {0}"] }
[[language.debugger.templates]]
name = "launch server"
request = "launch"
completion = [ { name = "entrypoint", completion = "filename", default = "dev" } ]
args = { program = "{0}" }
[language-server.solargraph]
command = "solargraph"
args = ["stdio"]
config = { diagnostics = false, formatting = false }
[language-server.rubocop]
command = "rubocop"
args = ["--lsp", "--stderr", "--fail-level", "fatal"]
timeout = 3
[language-server.ruby-lsp]
command = "ruby-lsp"
# args = ["--debug"]
LANGS
COPY <<CONF /home/app/.config/helix/config.toml
theme = "dark_plus"
[editor]
true-color = true
CONF
RUN chown 1000:1000 -R /home/app
COPY bin/dev_entrypoint /usr/local/bin/dev_entrypoint
USER ${NAME}
CMD ["/usr/bin/fish", "-l"]
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}
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 ${INSTALL_DIR}/.bundle ${INSTALL_DIR}/.bundle
COPY --from=builder ${INSTALL_DIR}/node_modules ${INSTALL_DIR}/node_modules
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" ]
CMD [ "rails", "server", "--binding", "0.0.0.0", "--no-daemon", "--port" , "3000" ]
ENTRYPOINT ["/usr/local/bin/dev_entrypoint"]
CMD ["/bin/sh", "-c", "dev"]