Fix file permissions for data directory in Docker
This commit is contained in:
1 parent
7eb27a8ac5
commit
3ac8c01d4c
1 file changed
+14
-6
+14
-6
@@ -23,8 +23,8 @@ RUN npm run build
|
||||
# Production stage
|
||||
FROM node:20-alpine AS runner
|
||||
|
||||
# Install Python and yt-dlp dependencies
|
||||
RUN apk add --no-cache python3 py3-pip ffmpeg
|
||||
# Install Python, yt-dlp dependencies, and su-exec
|
||||
RUN apk add --no-cache python3 py3-pip ffmpeg su-exec
|
||||
|
||||
# Install yt-dlp
|
||||
RUN pip3 install --no-cache-dir yt-dlp --break-system-packages
|
||||
@@ -45,11 +45,19 @@ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||
# Create data directory for database
|
||||
RUN mkdir -p /app/data && chown -R nextjs:nodejs /app
|
||||
|
||||
USER nextjs
|
||||
# Switch to root to allow permission fixes on startup
|
||||
USER root
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
ENV PORT 3000
|
||||
ENV HOSTNAME "0.0.0.0"
|
||||
ENV PORT=3000
|
||||
ENV HOSTNAME="0.0.0.0"
|
||||
|
||||
CMD ["node", "server.js"]
|
||||
# Create startup script that fixes permissions and starts the app
|
||||
RUN echo '#!/bin/sh' > /start.sh && \
|
||||
echo 'mkdir -p /app/data' >> /start.sh && \
|
||||
echo 'chown -R nextjs:nodejs /app/data' >> /start.sh && \
|
||||
echo 'su-exec nextjs node server.js' >> /start.sh && \
|
||||
chmod +x /start.sh
|
||||
|
||||
CMD ["/start.sh"]
|
||||
Reference in new issue
Block a user