You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

51 lines
1.9 KiB

# syntax=docker/dockerfile:1
FROM alpine:3.20
# Install minimal tooling
RUN apk add --no-cache \
--repository=https://dl-cdn.alpinelinux.org/alpine/edge/testing wol \
&& apk add --no-cache bash curl ca-certificates docker-cli lua5.4 lua5.4-socket luajit luajit-dev openssh-client netcat-openbsd
# Create the ssh directory
RUN mkdir -p /root/.ssh && chmod 700 /root/.ssh
# ssh-add ssh key from env var but do not keep env var around
ARG SSH_PRIVATE_KEY
ARG SSH_PUBLIC_KEY
ARG OLLAMA_HOST
ARG OLLAMA_PORT
ARG SINCE
RUN echo "$SSH_PRIVATE_KEY" > /root/.ssh/id_rsa && \
echo "$SSH_PUBLIC_KEY" > /root/.ssh/id_rsa.pub && \
chmod 600 /root/.ssh/id_rsa && \
chmod 644 /root/.ssh/id_rsa.pub && \
unset SSH_PRIVATE_KEY && unset SSH_PUBLIC_KEY
# Prepare known_hosts and try to pre-fetch host key (non-fatal if unreachable at build time)
RUN touch /root/.ssh/known_hosts && chmod 600 /root/.ssh/known_hosts
RUN ssh-keyscan -T 5 -H "$OLLAMA_HOST" >> /root/.ssh/known_hosts || true
# Copy script
WORKDIR /app
COPY scripts/* .
# Create a wrapper script to choose between lua5.4 and luajit
RUN echo '#!/bin/sh' > /app/run-lua.sh && \
echo 'if [ "$USE_LUAJIT" = "true" ]; then' >> /app/run-lua.sh && \
echo ' echo "Using LuaJIT for better performance"' >> /app/run-lua.sh && \
echo ' exec luajit /app/auto-boot-ollama-host.lua "$@"' >> /app/run-lua.sh && \
echo 'else' >> /app/run-lua.sh && \
echo ' echo "Using standard Lua 5.4"' >> /app/run-lua.sh && \
echo ' exec lua5.4 /app/auto-boot-ollama-host.lua "$@"' >> /app/run-lua.sh && \
echo 'fi' >> /app/run-lua.sh && \
chmod +x /app/run-lua.sh
#COPY scripts/auto-boot-ollama-host.sh /usr/local/bin/auto-boot-ollama-host.sh
#RUN chmod +x /usr/local/bin/auto-boot-ollama-host.sh
# Environment defaults (can be overridden by compose/Komodo)
ENV CONTAINER_NAME=paperless-ai \
OLLAMA_HOST=${OLLAMA_HOST} \
OLLAMA_PORT=${OLLAMA_PORT} \
SINCE=${SINCE:-0s}
ENTRYPOINT ["/app/run-lua.sh"]