This commit is contained in:
Damien Laureaux 2024-11-19 12:41:57 +04:00 committed by GitHub
commit df38fb9a5a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 106 additions and 33 deletions

3
.env.example Normal file
View file

@ -0,0 +1,3 @@
NEXT_PUBLIC_WS_URL=ws://127.0.0.1:3001
NEXT_PUBLIC_API_URL=http://127.0.0.1:3001/api
SEARXNG_API_URL=http://searxng:8080

View file

@ -77,13 +77,25 @@ There are mainly 2 ways of installing Perplexica - With Docker, Without Docker.
- `SIMILARITY_MEASURE`: The similarity measure to use (This is filled by default; you can leave it as is if you are unsure about it.) - `SIMILARITY_MEASURE`: The similarity measure to use (This is filled by default; you can leave it as is if you are unsure about it.)
5. Ensure you are in the directory containing the `docker-compose.yaml` file and execute: 5. Rename the `.env.example` file to `.env` and fill in all necessary fields.
```bash
mv .env.example .env
```
6. Rename the `./ui/.env.example` file to `./ui/.env` and fill in all necessary fields.
```bash
mv ./ui/.env.example ./ui/.env
```
7. Ensure you are in the directory containing the `docker-compose.yaml` file and execute:
```bash ```bash
docker compose up -d docker compose up -d
``` ```
6. Wait a few minutes for the setup to complete. You can access Perplexica at http://localhost:3000 in your web browser. 8. Wait a few minutes for the setup to complete. You can access Perplexica at http://localhost:3000 in your web browser.
**Note**: After the containers are built, you can start Perplexica directly from Docker without having to open a terminal. **Note**: After the containers are built, you can start Perplexica directly from Docker without having to open a terminal.

View file

@ -1,15 +1,39 @@
FROM node:alpine #############################
# Build stage
#############################
ARG NEXT_PUBLIC_WS_URL=ws://127.0.0.1:3001 FROM node:22-alpine AS builder
ARG NEXT_PUBLIC_API_URL=http://127.0.0.1:3001/api
ENV NEXT_PUBLIC_WS_URL=${NEXT_PUBLIC_WS_URL}
ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
WORKDIR /home/perplexica WORKDIR /app
COPY ui /home/perplexica/ # Copy package.json and yarn.lock
COPY ui/package.json ui/yarn.lock ./
RUN yarn install --frozen-lockfile # Copy the rest of the application code
RUN yarn build COPY ui .
# Install dependencies & build the application
RUN yarn install --frozen-lockfile && yarn build
#############################
# Production stage
#############################
FROM node:22-alpine
ENV NEXT_PUBLIC_WS_URL=ws://localhost:3001
ENV NEXT_PUBLIC_API_URL=http://localhost:3001/api
WORKDIR /app
# Copy built assets from the builder stage
COPY --chown=node:node --from=builder /app/.next ./.next
COPY --chown=node:node --from=builder /app/node_modules ./node_modules
COPY --chown=node:node --from=builder /app/package.json ./package.json
COPY --chown=node:node --from=builder /app/public ./public
# Run the Docker image as node instead of root
USER node
# Start the application
CMD ["yarn", "start"] CMD ["yarn", "start"]

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 WORKDIR /app
COPY tsconfig.json /home/perplexica/
COPY drizzle.config.ts /home/perplexica/
COPY package.json /home/perplexica/
COPY yarn.lock /home/perplexica/
RUN mkdir /home/perplexica/data # Copy package.json and yarn.lock
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile --network-timeout 600000 # Copy the rest of the application code
RUN yarn build 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"] CMD ["yarn", "start"]

View file

@ -12,30 +12,29 @@ services:
perplexica-backend: perplexica-backend:
build: build:
context: . context: .
args:
- USER=root
dockerfile: backend.dockerfile dockerfile: backend.dockerfile
image: itzcrazykns1337/perplexica-backend:main image: itzcrazykns1337/perplexica-backend:main
environment:
- SEARXNG_API_URL=http://searxng:8080
depends_on: depends_on:
- searxng - searxng
ports: ports:
- 3001:3001 - 3001:3001
volumes: volumes:
- backend-dbstore:/home/perplexica/data - backend-dbstore:/app/data:rw
- ./config.toml:/home/perplexica/config.toml - ./config.toml:/app/config.toml:rw
extra_hosts: extra_hosts:
- 'host.docker.internal:host-gateway' - 'host.docker.internal:host-gateway'
networks: networks:
- perplexica-network - perplexica-network
env_file:
- ./.env
restart: unless-stopped restart: unless-stopped
perplexica-frontend: perplexica-frontend:
build: build:
context: . context: .
dockerfile: app.dockerfile dockerfile: app.dockerfile
args:
- NEXT_PUBLIC_API_URL=http://127.0.0.1:3001/api
- NEXT_PUBLIC_WS_URL=ws://127.0.0.1:3001
image: itzcrazykns1337/perplexica-frontend:main image: itzcrazykns1337/perplexica-frontend:main
depends_on: depends_on:
- perplexica-backend - perplexica-backend
@ -43,6 +42,8 @@ services:
- 3000:3000 - 3000:3000
networks: networks:
- perplexica-network - perplexica-network
env_file:
- ./.env
restart: unless-stopped restart: unless-stopped
networks: networks:

View file

@ -1,2 +1,3 @@
NEXT_PUBLIC_WS_URL=ws://localhost:3001 NEXT_PUBLIC_WS_URL=ws://127.0.0.1:3001
NEXT_PUBLIC_API_URL=http://localhost:3001/api NEXT_PUBLIC_API_URL=http://127.0.0.1:3001/api
SEARXNG_API_URL=http://searxng:8080