Merge pull request 'fix: Run prisma db push as root, then switch to nextjs user for app' (#15) from develop into main
All checks were successful
Personal/recall/pipeline/head This commit looks good
All checks were successful
Personal/recall/pipeline/head This commit looks good
Reviewed-on: #15
This commit was merged in pull request #15.
This commit is contained in:
11
Dockerfile
11
Dockerfile
@@ -41,7 +41,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& groupadd --system --gid 1001 nodejs \
|
||||
&& useradd --system --uid 1001 nextjs \
|
||||
&& mkdir -p /home/nextjs && chown nextjs:nextjs /home/nextjs
|
||||
&& mkdir -p /home/nextjs && chown nextjs:nextjs /home/nextjs \
|
||||
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder /app/.next/standalone ./
|
||||
@@ -55,10 +56,8 @@ COPY --from=builder /app/prisma/schema.prisma /app/schema.prisma
|
||||
COPY docker-entrypoint.sh /usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
||||
|
||||
# Create data directory and initialize database as root
|
||||
RUN mkdir -p /app/data && chown -R nextjs:nodejs /app
|
||||
|
||||
USER nextjs
|
||||
# Create data directory with proper permissions
|
||||
RUN mkdir -p /app/data && chown -R nextjs:nextjs /app
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
@@ -67,5 +66,5 @@ ENV HOSTNAME="0.0.0.0"
|
||||
ENV DATABASE_URL="file:./data/dev.db"
|
||||
ENV HOME=/home/nextjs
|
||||
|
||||
ENTRYPOINT ["docker-entrypoint.sh"]
|
||||
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
||||
CMD ["node", "server.js"]
|
||||
|
||||
@@ -4,12 +4,11 @@ set -e
|
||||
# Initialize database if it doesn't exist or schema changed
|
||||
echo "Checking database..."
|
||||
|
||||
# Create data directory and set proper permissions
|
||||
# Ensure data directory exists with proper permissions
|
||||
mkdir -p /app/data
|
||||
chmod 755 /app/data
|
||||
|
||||
# Use local prisma version from node_modules
|
||||
./node_modules/prisma/build/index.js db push
|
||||
|
||||
echo "Starting application..."
|
||||
exec "$@"
|
||||
exec su nextjs -c "cd /app && node server.js"
|
||||
|
||||
Reference in New Issue
Block a user