Iteration 1

This commit is contained in:
AutoCoder Bot 2024-11-23 17:15:34 -08:00
parent c650d1c3d9
commit 0f30fc6ec1
5 changed files with 107 additions and 32 deletions

View file

@ -1,16 +1,48 @@
FROM node:18-slim
#############################
# Build stage
#############################
WORKDIR /home/perplexica
FROM node:22-alpine AS builder
COPY src /home/perplexica/src
COPY tsconfig.json /home/perplexica/
COPY drizzle.config.ts /home/perplexica/
COPY package.json /home/perplexica/
COPY yarn.lock /home/perplexica/
WORKDIR /app
RUN mkdir /home/perplexica/data
# Copy package.json and yarn.lock
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile --network-timeout 600000
RUN yarn build
# Copy the rest of the application code
COPY tsconfig.json drizzle.config.ts ./
COPY src ./src
# Install dependencies & build the application
RUN yarn install --frozen-lockfile --network-timeout 600000 && yarn build
#############################
# Production stage
#############################
FROM node:22-alpine
ARG USER=node
WORKDIR /app
# Copy built assets and necessary files from the builder stage
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 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 && \
chmod -R 755 /app/data
# Run the Docker image as node or root if Docker Compose du to volume permissions
USER ${USER}
# Start the application
CMD ["yarn", "start"]