fix: docker permission again.
Some checks failed
Build and Push Docker Image / buildx (push) Has been cancelled
Some checks failed
Build and Push Docker Image / buildx (push) Has been cancelled
This commit is contained in:
10
Dockerfile
10
Dockerfile
@@ -11,8 +11,9 @@ FROM base AS production
|
|||||||
COPY --from=deps /app/node_modules ./node_modules
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Create directory for database with proper permissions
|
# Copy init script
|
||||||
RUN mkdir -p /app/data && chown -R 1001:1001 /app/data
|
COPY scripts/init-data-dir.sh /usr/local/bin/init-data-dir.sh
|
||||||
|
RUN chmod +x /usr/local/bin/init-data-dir.sh
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
@@ -20,9 +21,14 @@ EXPOSE 3000
|
|||||||
RUN addgroup -g 1001 -S nodejs
|
RUN addgroup -g 1001 -S nodejs
|
||||||
RUN adduser -S nextjs -u 1001
|
RUN adduser -S nextjs -u 1001
|
||||||
|
|
||||||
|
# Create directory for database
|
||||||
|
RUN mkdir -p /app/data
|
||||||
|
|
||||||
USER nextjs
|
USER nextjs
|
||||||
|
|
||||||
# Set environment variable for database path
|
# Set environment variable for database path
|
||||||
ENV DB_PATH=/app/data/data.db
|
ENV DB_PATH=/app/data/data.db
|
||||||
|
|
||||||
|
# Use init script as entrypoint wrapper
|
||||||
|
ENTRYPOINT ["/usr/local/bin/init-data-dir.sh"]
|
||||||
CMD ["node", "server.js"]
|
CMD ["node", "server.js"]
|
||||||
|
|||||||
@@ -16,3 +16,11 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- ./data:/app/data
|
- ./data:/app/data
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
depends_on:
|
||||||
|
- init-data-dir
|
||||||
|
|
||||||
|
init-data-dir:
|
||||||
|
image: alpine:latest
|
||||||
|
command: chown -R 1001:1001 /app/data
|
||||||
|
volumes:
|
||||||
|
- ./data:/app/data
|
||||||
|
|||||||
14
scripts/init-data-dir.sh
Normal file
14
scripts/init-data-dir.sh
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Create data directory if it doesn't exist
|
||||||
|
mkdir -p /app/data
|
||||||
|
|
||||||
|
# Try to set permissions for the data directory
|
||||||
|
# This might fail in some environments, but that's okay
|
||||||
|
chown -R 1001:1001 /app/data 2>/dev/null || true
|
||||||
|
chmod 755 /app/data 2>/dev/null || true
|
||||||
|
|
||||||
|
echo "Data directory initialized"
|
||||||
|
|
||||||
|
# Execute the main command
|
||||||
|
exec "$@"
|
||||||
Reference in New Issue
Block a user