Skip to content

Commit 64f970b

Browse files
wip
1 parent 0dc8083 commit 64f970b

File tree

1 file changed

+36
-33
lines changed

1 file changed

+36
-33
lines changed

Dockerfile

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,30 @@ ENV SOURCEBOT_LOG_LEVEL=info
195195
# Sourcebot collects anonymous usage data using [PostHog](https://posthog.com/). Uncomment this line to disable.
196196
# ENV SOURCEBOT_TELEMETRY_DISABLED=1
197197

198-
COPY package.json yarn.lock* .yarnrc.yml public.pem ./
199-
COPY .yarn ./.yarn
198+
# Configure dependencies
199+
RUN apk add --no-cache git ca-certificates bind-tools tini jansson wget supervisor uuidgen curl perl jq redis postgresql postgresql-contrib openssl util-linux unzip
200+
201+
ARG UID=1500
202+
ARG GID=1500
203+
204+
# To run as non-root, the user must be part of postgres, redis and node groups
205+
RUN addgroup -g $GID sourcebot && \
206+
adduser -D -u $UID -h /app -S sourcebot && \
207+
adduser sourcebot postgres && \
208+
adduser sourcebot redis && \
209+
adduser sourcebot node && \
210+
chown -R sourcebot /app && \
211+
mkdir /var/log/sourcebot && \
212+
chown sourcebot /var/log/sourcebot
213+
214+
COPY --chown=sourcebot:sourcebot package.json yarn.lock* .yarnrc.yml public.pem ./
215+
COPY --chown=sourcebot:sourcebot .yarn ./.yarn
200216

201217
# Configure zoekt
202-
COPY vendor/zoekt/install-ctags-alpine.sh .
218+
COPY --chown=sourcebot:sourcebot vendor/zoekt/install-ctags-alpine.sh .
203219
RUN ./install-ctags-alpine.sh && rm install-ctags-alpine.sh
204-
RUN mkdir -p ${DATA_CACHE_DIR}
205-
COPY --from=zoekt-builder \
220+
RUN mkdir -p ${DATA_CACHE_DIR} && chown -R sourcebot ${DATA_CACHE_DIR}
221+
COPY --chown=sourcebot:sourcebot --from=zoekt-builder \
206222
/cmd/zoekt-git-index \
207223
/cmd/zoekt-indexserver \
208224
/cmd/zoekt-mirror-github \
@@ -215,23 +231,21 @@ COPY --from=zoekt-builder \
215231
/usr/local/bin/
216232

217233
# Copy all of the things
218-
COPY --from=web-builder /app/packages/web/public ./packages/web/public
219-
COPY --from=web-builder /app/packages/web/.next/standalone ./
220-
COPY --from=web-builder /app/packages/web/.next/static ./packages/web/.next/static
234+
COPY --chown=sourcebot:sourcebot --from=web-builder /app/packages/web/public ./packages/web/public
235+
COPY --chown=sourcebot:sourcebot --from=web-builder /app/packages/web/.next/standalone ./
236+
COPY --chown=sourcebot:sourcebot --from=web-builder /app/packages/web/.next/static ./packages/web/.next/static
221237

222-
COPY --from=backend-builder /app/node_modules ./node_modules
223-
COPY --from=backend-builder /app/packages/backend ./packages/backend
238+
COPY --chown=sourcebot:sourcebot --from=backend-builder /app/node_modules ./node_modules
239+
COPY --chown=sourcebot:sourcebot --from=backend-builder /app/packages/backend ./packages/backend
224240

225-
COPY --from=shared-libs-builder /app/node_modules ./node_modules
226-
COPY --from=shared-libs-builder /app/packages/db ./packages/db
227-
COPY --from=shared-libs-builder /app/packages/schemas ./packages/schemas
228-
COPY --from=shared-libs-builder /app/packages/crypto ./packages/crypto
229-
COPY --from=shared-libs-builder /app/packages/error ./packages/error
230-
COPY --from=shared-libs-builder /app/packages/logger ./packages/logger
231-
COPY --from=shared-libs-builder /app/packages/shared ./packages/shared
241+
COPY --chown=sourcebot:sourcebot --from=shared-libs-builder /app/node_modules ./node_modules
242+
COPY --chown=sourcebot:sourcebot --from=shared-libs-builder /app/packages/db ./packages/db
243+
COPY --chown=sourcebot:sourcebot --from=shared-libs-builder /app/packages/schemas ./packages/schemas
244+
COPY --chown=sourcebot:sourcebot --from=shared-libs-builder /app/packages/crypto ./packages/crypto
245+
COPY --chown=sourcebot:sourcebot --from=shared-libs-builder /app/packages/error ./packages/error
246+
COPY --chown=sourcebot:sourcebot --from=shared-libs-builder /app/packages/logger ./packages/logger
247+
COPY --chown=sourcebot:sourcebot --from=shared-libs-builder /app/packages/shared ./packages/shared
232248

233-
# Configure dependencies
234-
RUN apk add --no-cache git ca-certificates bind-tools tini jansson wget supervisor uuidgen curl perl jq redis postgresql postgresql-contrib openssl util-linux unzip
235249

236250
# Fixes git "dubious ownership" issues when the volume is mounted with different permissions to the container.
237251
RUN git config --global safe.directory "*"
@@ -241,21 +255,10 @@ RUN mkdir -p /run/postgresql && \
241255
chown -R postgres:postgres /run/postgresql && \
242256
chmod 775 /run/postgresql
243257

244-
# To run as non-root, the user must be part of postgres, redis and node groups
245-
RUN addgroup -g 1500 sourcebot && \
246-
adduser -D -u 1500 -h /app -S sourcebot && \
247-
adduser sourcebot postgres && \
248-
adduser sourcebot redis && \
249-
adduser sourcebot node && \
250-
chown -R sourcebot /data && \
251-
chown -R sourcebot /app && \
252-
mkdir /var/log/sourcebot && \
253-
chown sourcebot /var/log/sourcebot
254-
255-
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
256-
COPY prefix-output.sh ./prefix-output.sh
258+
COPY --chown=sourcebot:sourcebot supervisord.conf /etc/supervisor/conf.d/supervisord.conf
259+
COPY --chown=sourcebot:sourcebot prefix-output.sh ./prefix-output.sh
257260
RUN chmod +x ./prefix-output.sh
258-
COPY entrypoint.sh ./entrypoint.sh
261+
COPY --chown=sourcebot:sourcebot entrypoint.sh ./entrypoint.sh
259262
RUN chmod +x ./entrypoint.sh
260263

261264

0 commit comments

Comments
 (0)