mirror of
https://github.com/skidoodle/budgetable.git
synced 2026-04-27 23:37:36 +02:00
docker: ensure adduser/addgroup installed and create nextjs user in runner stage
This commit is contained in:
+13
-2
@@ -18,8 +18,19 @@ ENV NEXT_TELEMETRY_DISABLED=1
|
||||
ENV NODE_ENV=production \
|
||||
PORT=3000 \
|
||||
HOSTNAME="0.0.0.0"
|
||||
RUN addgroup --system --gid 1001 nodejs && \
|
||||
adduser --system --uid 1001 nextjs
|
||||
|
||||
# Ensure adduser/addgroup (or useradd/groupadd) is available, then create the group and user
|
||||
RUN if command -v apt-get >/dev/null 2>&1; then \
|
||||
apt-get update && apt-get install -y --no-install-recommends adduser && rm -rf /var/lib/apt/lists/*; \
|
||||
elif command -v apk >/dev/null 2>&1; then \
|
||||
apk add --no-cache shadow && rm -rf /var/cache/apk/*; \
|
||||
fi && \
|
||||
if command -v addgroup >/dev/null 2>&1 && command -v adduser >/dev/null 2>&1; then \
|
||||
addgroup --system --gid 1001 nodejs && adduser --system --uid 1001 --ingroup nodejs --disabled-password --home /nonexistent --shell /sbin/nologin nextjs; \
|
||||
else \
|
||||
groupadd -g 1001 nodejs || true && useradd -u 1001 -g nodejs -M -s /sbin/nologin nextjs || true; \
|
||||
fi
|
||||
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||
|
||||
Reference in New Issue
Block a user