Docker build & push (#2)
* Simple docker build and push * Removed requirement of defining in the config.toml file, everything should be available from the environment * Added workflow dispatch
This commit is contained in:
parent
2da65182cb
commit
7d5eec898d
5 changed files with 68 additions and 19 deletions
57
.github/workflows/docker-build.yml
vendored
57
.github/workflows/docker-build.yml
vendored
|
@ -1,4 +1,4 @@
|
|||
name: Hello World Workflow
|
||||
name: Build and Push Docker images
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
@ -10,8 +10,57 @@ on:
|
|||
- master
|
||||
|
||||
jobs:
|
||||
say-hello:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Say Hello World
|
||||
run: echo "Hello, World!"
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Build frontend Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: app.dockerfile
|
||||
push: false
|
||||
tags: ${{ secrets.DOCKER_USERNAME }}/perplexica-frontend:latest
|
||||
|
||||
- name: Build backend Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: backend.dockerfile
|
||||
push: false
|
||||
tags: ${{ secrets.DOCKER_USERNAME }}/perplexica-backend:latest
|
||||
|
||||
- name: Push frontend Docker image
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: app.dockerfile
|
||||
push: true
|
||||
tags: ${{ secrets.DOCKER_USERNAME }}/perplexica-frontend:latest
|
||||
|
||||
- name: Push backend Docker image
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: backend.dockerfile
|
||||
push: true
|
||||
tags: ${{ secrets.DOCKER_USERNAME }}/perplexica-backend:latest
|
||||
|
||||
- name: Log out from Docker Hub
|
||||
if: github.event_name != 'pull_request'
|
||||
run: docker logout
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
FROM node:alpine
|
||||
|
||||
ARG NEXT_PUBLIC_WS_URL
|
||||
ARG NEXT_PUBLIC_API_URL
|
||||
ARG NEXT_PUBLIC_WS_URL='ws://127.0.0.1:3001'
|
||||
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}
|
||||
|
||||
|
|
|
@ -6,13 +6,10 @@ WORKDIR /home/perplexica
|
|||
|
||||
COPY src /home/perplexica/src
|
||||
COPY tsconfig.json /home/perplexica/
|
||||
COPY config.toml /home/perplexica/
|
||||
COPY drizzle.config.ts /home/perplexica/
|
||||
COPY package.json /home/perplexica/
|
||||
COPY yarn.lock /home/perplexica/
|
||||
|
||||
RUN sed -i "s|SEARXNG = \".*\"|SEARXNG = \"${SEARXNG_API_URL}\"|g" /home/perplexica/config.toml
|
||||
|
||||
RUN mkdir /home/perplexica/data
|
||||
|
||||
RUN yarn install
|
||||
|
|
|
@ -31,9 +31,6 @@ services:
|
|||
build:
|
||||
context: .
|
||||
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
|
||||
depends_on:
|
||||
- perplexica-backend
|
||||
ports:
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import toml from '@iarna/toml';
|
||||
import process from 'process';
|
||||
|
||||
const configFileName = 'config.toml';
|
||||
|
||||
|
@ -29,20 +30,25 @@ const loadConfig = () =>
|
|||
fs.readFileSync(path.join(__dirname, `../${configFileName}`), 'utf-8'),
|
||||
) as any as Config;
|
||||
|
||||
export const getPort = () => loadConfig().GENERAL.PORT;
|
||||
export const getPort = () => process.env.PORT ?? loadConfig().GENERAL.PORT;
|
||||
|
||||
export const getSimilarityMeasure = () =>
|
||||
loadConfig().GENERAL.SIMILARITY_MEASURE;
|
||||
process.env.SIMILARITY_MEASURE ?? loadConfig().GENERAL.SIMILARITY_MEASURE;
|
||||
|
||||
export const getOpenaiApiKey = () => loadConfig().API_KEYS.OPENAI;
|
||||
export const getOpenaiApiKey = () =>
|
||||
process.env.OPENAI_API_KEY ?? loadConfig().API_KEYS.OPENAI;
|
||||
|
||||
export const getGroqApiKey = () => loadConfig().API_KEYS.GROQ;
|
||||
export const getGroqApiKey = () =>
|
||||
process.env.GROQ_API_KEY ?? loadConfig().API_KEYS.GROQ;
|
||||
|
||||
export const getAnthropicApiKey = () => loadConfig().API_KEYS.ANTHROPIC;
|
||||
export const getAnthropicApiKey = () =>
|
||||
process.env.ANTHROPIC_API_KEY ?? loadConfig().API_KEYS.ANTHROPIC;
|
||||
|
||||
export const getSearxngApiEndpoint = () => loadConfig().API_ENDPOINTS.SEARXNG;
|
||||
export const getSearxngApiEndpoint = () =>
|
||||
process.env.SEARXNG_API_ENDPOINT ?? loadConfig().API_ENDPOINTS.SEARXNG;
|
||||
|
||||
export const getOllamaApiEndpoint = () => loadConfig().API_ENDPOINTS.OLLAMA;
|
||||
export const getOllamaApiEndpoint = () =>
|
||||
process.env.OLLAMA_API_ENDPOINT ?? loadConfig().API_ENDPOINTS.OLLAMA;
|
||||
|
||||
export const updateConfig = (config: RecursivePartial<Config>) => {
|
||||
const currentConfig = loadConfig();
|
||||
|
|
Loading…
Add table
Reference in a new issue