-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
76 lines (61 loc) · 2.4 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Use a base image with Java 19 installed
FROM amazoncorretto:21.0.3 AS build
# Copy the source code to the container
COPY . /app
# Set the working directory in the container
WORKDIR /app
# Expose any required ports (if needed)
# EXPOSE 8080
# Set the environment variables from Docker environment variables
# If the Docker environment variable is not provided, use the default value from .env.example
ARG TOKEN
ENV TOKEN=${TOKEN}
ARG OLLAMA_URL
ENV OLLAMA_URL=${OLLAMA_URL}
ARG OLLAMA_PORT
ENV OLLAMA_PORT=${OLLAMA_PORT:-11434}
ARG OLLAMA_MODEL
ENV OLLAMA_MODEL=${OLLAMA_MODEL}
ARG OLLAMA_EMBEDDING_MODEL
ENV OLLAMA_EMBEDDING_MODEL=${OLLAMA_EMBEDDING_MODEL}
ARG OLLAMA_CHAT_MEMORY_UPTO
ENV OLLAMA_CHAT_MEMORY_UPTO=${OLLAMA_CHAT_MEMORY_UPTO:-1}
ARG OLLAMA_TIMEOUT_SECONDS
ENV OLLAMA_TIMEOUT_SECONDS=${OLLAMA_TIMEOUT_SECONDS:-60}
ARG USER_ID
ENV USER_ID=${USER_ID}
ARG WHITELISTED_USERS
ENV WHITELISTED_USERS=${WHITELISTED_USERS}
RUN echo "TOKEN=$TOKEN" > .env \
&& echo "OLLAMA_URL=$OLLAMA_URL" >> .env \
&& echo "OLLAMA_PORT=$OLLAMA_PORT" >> .env \
&& echo "OLLAMA_MODEL=$OLLAMA_MODEL" >> .env \
&& echo "OLLAMA_EMBEDDING_MODEL=$OLLAMA_EMBEDDING_MODEL" >> .env \
&& echo "OLLAMA_CHAT_MEMORY_UPTO=$OLLAMA_CHAT_MEMORY_UPTO" >> .env \
&& echo "OLLAMA_TIMEOUT_SECONDS=$OLLAMA_TIMEOUT_SECONDS" >> .env \
&& echo "USER_ID=$USER_ID" >> .env
# Add WHITELISTED_USERS to .env if provided
RUN if [ -n "$WHITELISTED_USERS" ]; then echo "WHITELISTED_USERS=$WHITELISTED_USERS" >> .env; fi
# Ask for SearXNG URL , PORT and ENGINES and dont add if not provided
ARG SEARXNG_URL
ENV SEARXNG_URL=${SEARXNG_URL}
ARG SEARXNG_PORT
ENV SEARXNG_PORT=${SEARXNG_PORT}
ARG SEARXNG_ENGINES
ENV SEARXNG_ENGINES=${SEARXNG_ENGINES}
# add searxng to .env if provided
RUN if [ -n "$SEARXNG_URL" ]; then echo "SEARXNG_URL=$SEARXNG_URL" >> .env; fi
RUN if [ -n "$SEARXNG_PORT" ]; then echo "SEARXNG_PORT=$SEARXNG_PORT" >> .env; fi
RUN if [ -n "$SEARXNG_ENGINES" ]; then echo "SEARXNG_ENGINES=$SEARXNG_ENGINES" >> .env; fi
# Build the application using Gradle
RUN sed -i 's/\r$//' ./gradlew
RUN chmod +x ./gradlew
RUN ./gradlew build
# Use a base image with Java 19 installed
FROM amazoncorretto:21.0.3
# Set the working directory in the container
WORKDIR /app
# Copy the build result from the previous stage
COPY --from=build /app/build/shadow/AiLama-1.0-all.jar /app/AiLama-1.0-all.jar
# Run the application
CMD ["java", "-jar", "AiLama-1.0-all.jar"]