1
1
# Setup base image
2
- FROM ubuntu:jammy-20230522 AS base
2
+ FROM ubuntu:jammy-20230916 AS base
3
3
4
+ # Build arguments
4
5
ARG ARG_UID=1000
5
6
ARG ARG_GID=1000
6
7
7
8
FROM base AS build-arm64
8
9
RUN echo "Preparing build of AnythingLLM image for arm64 architecture"
9
10
11
+ SHELL ["/bin/bash" , "-o" , "pipefail" , "-c" ]
12
+
13
+ # Install system dependencies
14
+ # hadolint ignore=DL3008,DL3013
10
15
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
11
16
DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
12
17
unzip curl gnupg libgfortran5 libgbm1 tzdata netcat \
@@ -25,8 +30,8 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
25
30
&& rm yarn_1.22.19_all.deb
26
31
27
32
# Create a group and user with specific UID and GID
28
- RUN groupadd -g $ARG_GID anythingllm && \
29
- useradd -u $ARG_UID -m -d /app -s /bin/bash -g anythingllm anythingllm && \
33
+ RUN groupadd -g " $ARG_GID" anythingllm && \
34
+ useradd -l -u " $ARG_UID" -m -d /app -s /bin/bash -g anythingllm anythingllm && \
30
35
mkdir -p /app/frontend/ /app/server/ /app/collector/ && chown -R anythingllm:anythingllm /app
31
36
32
37
# Copy docker helper scripts
@@ -61,6 +66,10 @@ RUN echo "Done running arm64 specific installtion steps"
61
66
FROM base AS build-amd64
62
67
RUN echo "Preparing build of AnythingLLM image for non-ARM architecture"
63
68
69
+ SHELL ["/bin/bash" , "-o" , "pipefail" , "-c" ]
70
+
71
+ # Install system dependencies
72
+ # hadolint ignore=DL3008,DL3013
64
73
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
65
74
DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
66
75
curl gnupg libgfortran5 libgbm1 tzdata netcat \
@@ -79,8 +88,8 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
79
88
&& rm yarn_1.22.19_all.deb
80
89
81
90
# Create a group and user with specific UID and GID
82
- RUN groupadd -g $ARG_GID anythingllm && \
83
- useradd -u $ARG_UID -m -d /app -s /bin/bash -g anythingllm anythingllm && \
91
+ RUN groupadd -g " $ARG_GID" anythingllm && \
92
+ useradd -l -u " $ARG_UID" -m -d /app -s /bin/bash -g anythingllm anythingllm && \
84
93
mkdir -p /app/frontend/ /app/server/ /app/collector/ && chown -R anythingllm:anythingllm /app
85
94
86
95
# Copy docker helper scripts
@@ -95,50 +104,63 @@ RUN chmod +x /usr/local/bin/docker-entrypoint.sh && \
95
104
# ############################################
96
105
# COMMON BUILD FLOW FOR ALL ARCHS
97
106
# ############################################
107
+
108
+ # hadolint ignore=DL3006
98
109
FROM build-${TARGETARCH} AS build
99
110
RUN echo "Running common build flow of AnythingLLM image for all architectures"
100
111
101
112
USER anythingllm
102
113
WORKDIR /app
103
114
104
115
# Install frontend dependencies
105
- FROM build as frontend-deps
116
+ FROM build AS frontend-deps
106
117
107
118
COPY ./frontend/package.json ./frontend/yarn.lock ./frontend/
108
- RUN cd ./frontend/ && yarn install --network-timeout 100000 && yarn cache clean
119
+ WORKDIR /app/frontend
120
+ RUN yarn install --network-timeout 100000 && yarn cache clean
121
+ WORKDIR /app
109
122
110
123
# Install server dependencies
111
- FROM build as server-deps
124
+ FROM build AS server-deps
112
125
COPY ./server/package.json ./server/yarn.lock ./server/
113
- RUN cd ./server/ && yarn install --production --network-timeout 100000 && yarn cache clean
126
+ WORKDIR /app/server
127
+ RUN yarn install --production --network-timeout 100000 && yarn cache clean
128
+ WORKDIR /app
114
129
115
130
# Compile Llama.cpp bindings for node-llama-cpp for this operating system.
116
131
USER root
117
- RUN cd ./server && npx --no node-llama-cpp download
132
+ WORKDIR /app/server
133
+ RUN npx --no node-llama-cpp download
134
+ WORKDIR /app
118
135
USER anythingllm
119
136
120
137
# Build the frontend
121
- FROM frontend-deps as build-stage
138
+ FROM frontend-deps AS build-stage
122
139
COPY ./frontend/ ./frontend/
123
- RUN cd ./frontend/ && yarn build && yarn cache clean
140
+ WORKDIR /app/frontend
141
+ RUN yarn build && yarn cache clean
142
+ WORKDIR /app
124
143
125
144
# Setup the server
126
- FROM server-deps as production-stage
145
+ FROM server-deps AS production-stage
127
146
COPY --chown=anythingllm:anythingllm ./server/ ./server/
128
147
129
148
# Copy built static frontend files to the server public directory
130
- COPY --from=build-stage /app/frontend/dist ./server/public
149
+ COPY --chown=anythingllm:anythingllm -- from=build-stage /app/frontend/dist ./server/public
131
150
132
151
# Copy the collector
133
152
COPY --chown=anythingllm:anythingllm ./collector/ ./collector/
134
153
135
154
# Install collector dependencies
155
+ WORKDIR /app/collector
136
156
ENV PUPPETEER_DOWNLOAD_BASE_URL=https://storage.googleapis.com/chrome-for-testing-public
137
- RUN cd /app/collector && yarn install --production --network-timeout 100000 && yarn cache clean
157
+ RUN yarn install --production --network-timeout 100000 && yarn cache clean
138
158
139
159
# Migrate and Run Prisma against known schema
140
- RUN cd ./server && npx prisma generate --schema=./prisma/schema.prisma
141
- RUN cd ./server && npx prisma migrate deploy --schema=./prisma/schema.prisma
160
+ WORKDIR /app/server
161
+ RUN npx prisma generate --schema=./prisma/schema.prisma && \
162
+ npx prisma migrate deploy --schema=./prisma/schema.prisma
163
+ WORKDIR /app
142
164
143
165
# Setup the environment
144
166
ENV NODE_ENV=production
@@ -152,4 +174,4 @@ HEALTHCHECK --interval=1m --timeout=10s --start-period=1m \
152
174
CMD /bin/bash /usr/local/bin/docker-healthcheck.sh || exit 1
153
175
154
176
# Run the server
155
- ENTRYPOINT ["/bin/bash" , "/usr/local/bin/docker-entrypoint.sh" ]
177
+ ENTRYPOINT ["/bin/bash" , "/usr/local/bin/docker-entrypoint.sh" ]
0 commit comments