fix(docker): fix the permissions issue when running Docker Compose
Docker Compose mount the volumes as root by default and the node user can't access the SQLite DB (read-only)
This commit is contained in:
parent
eda2c3975a
commit
2351c5c125
2 changed files with 11 additions and 6 deletions
|
@ -2,7 +2,7 @@
|
|||
# Build stage
|
||||
#############################
|
||||
|
||||
FROM node:18-alpine AS builder
|
||||
FROM node:22-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
|
@ -20,7 +20,9 @@ RUN yarn install --frozen-lockfile --network-timeout 600000 && yarn build
|
|||
# Production stage
|
||||
#############################
|
||||
|
||||
FROM node:18-alpine
|
||||
FROM node:22-alpine
|
||||
|
||||
ARG USER=node
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
|
@ -29,17 +31,18 @@ COPY --chown=node:node --from=builder /app/dist ./dist
|
|||
COPY --chown=node:node --from=builder /app/node_modules ./node_modules
|
||||
|
||||
# Copy the rest of the application code
|
||||
COPY --chown=node:node src ./src
|
||||
COPY --chown=node:node drizzle.config.ts ./
|
||||
COPY --chown=node:node tsconfig.json ./
|
||||
COPY --chown=node:node src/db/schema.ts ./src/db/schema.ts
|
||||
COPY --chown=node:node package.json ./package.json
|
||||
|
||||
# Create data directory & set permissions to node user
|
||||
RUN mkdir /app/data && \
|
||||
chown -R node:node /app/data
|
||||
chown -R node:node /app/data && \
|
||||
chmod -R 755 /app/data
|
||||
|
||||
# Run the Docker image as node instead of root
|
||||
USER node
|
||||
# Run the Docker image as node or root if Docker Compose du to volume permissions
|
||||
USER ${USER}
|
||||
|
||||
# Start the application
|
||||
CMD ["yarn", "start"]
|
|
@ -12,6 +12,8 @@ services:
|
|||
perplexica-backend:
|
||||
build:
|
||||
context: .
|
||||
args:
|
||||
- USER=root
|
||||
dockerfile: backend.dockerfile
|
||||
image: itzcrazykns1337/perplexica-backend:main
|
||||
depends_on:
|
||||
|
|
Loading…
Add table
Reference in a new issue