Working on docker build improvements

This commit is contained in:
timothycarambat
2023-11-18 13:50:44 -08:00
parent 273456317e
commit ef8d4455d1
4 changed files with 59 additions and 27 deletions
+35 -11
View File
@@ -2,29 +2,53 @@
Running VectorAdmin in Docker is the easily way to get a locally hosted option running as quickly as possible.
## Requirements
- Install [Docker](https://www.docker.com/) on your computer or machine.
- A running Postgres DB (RDS, remote, docker, local host machine)
## How to install
**Note** Failure to use a valid DB connection string prior to building or starting vector-admin will result in a failure.
On boot the `vdbms` database will be created using the connection string.
**Run containerized Postgres DB**
Run this command first to get a dockerized Postgres container running:
`docker-compose up -d --build postgres`
## Run from Docker pre-built image
- `git clone git@github.com:Mintplex-Labs/vector-admin.git`
- `cd vector-admin`
- `cd docker/`
- `cp .env.example .env`.
- Edit `.env` file and update the variables. **please** update all of the following:
```shell
JWT_SECRET="some-random-string"
SYS_EMAIL="root@vectoradmin.com"
SYS_PASSWORD="password"
DATABASE_CONNECTION_STRING="postgresql://vectoradmin:password@host.docker.internal:5433/vdbms" # Valid PG Connection string.
INNGEST_SIGNING_KEY="some-random-string"
```
<!--
## Setup ENVs for Docker image
- `git clone` this repo and `cd vector-admin` to get to the root directory.
- `yarn dev:setup`
- `cd docker/`
- `cp .env.example .env` to create the `.env` file.
- Edit `.env` file and update the variables. **please** update `JWT_SECRET`,`SYS_PASSWORD`, and `INNGEST_SIGNING_KEY`
- Edit `.env` file and update the variables. **please** update all of the following:
```shell
JWT_SECRET="some-random-string"
SYS_EMAIL="root@vectoradmin.com"
SYS_PASSWORD="password"
DATABASE_CONNECTION_STRING="postgresql://vectoradmin:password@host.docker.internal:5433/vdbms" # PG Connection string.
INNGEST_SIGNING_KEY="some-random-string"
```
**Note** You must have a postgres DB running - the default ENV assumes a containerized PG instance running, but it can
be located anywhere (RDS, remote, local host machine). Failure to use a valid DB connection string prior to building
vector-admin will result in a build failure.
- `DATABASE_CONNECTION_STRING` should be a valid connection string. On boot the `vdbms` database will be created for the connection string.
**If running the included containerized Postgres DB**
Run this command first: `docker-compose up -d --build postgres`
**Boot up vector-admin**
- `docker-compose up -d --build vector-admin` to build the image - this will take a few moments.
Your docker host will show the image as online once the build process is completed. This will build the app to `http://localhost:3001`.
Your docker host will show the image as online once the build process is completed. This will build the app to `http://localhost:3001`. -->
## How to use the user interface
+6 -9
View File
@@ -1,19 +1,20 @@
# Setup base image
FROM ubuntu:jammy-20230522 AS base
# Build arguments
ARG DATABASE_CONNECTION_STRING
# Install system dependencies
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
curl libgfortran5 python3 python3-pip tzdata netcat \
curl gnupg libgfortran5 python3 python3-pip tzdata netcat \
libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 \
libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libx11-6 libx11-xcb1 libxcb1 \
libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 \
libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release \
xdg-utils && \
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
apt-get update && \
apt-get install -yq --no-install-recommends nodejs && \
curl -LO https://github.com/yarnpkg/yarn/releases/download/v1.22.19/yarn_1.22.19_all.deb \
&& dpkg -i yarn_1.22.19_all.deb \
@@ -79,10 +80,6 @@ RUN cd /app/document-processor && \
. v-env/bin/activate && \
pip install --no-cache-dir -r requirements.txt
# Reown files and init Prisma Client
RUN cd ./backend && DATABASE_CONNECTION_STRING=$DATABASE_CONNECTION_STRING npx prisma generate --schema=./prisma/schema.prisma
RUN cd ./backend && DATABASE_CONNECTION_STRING=$DATABASE_CONNECTION_STRING npx prisma migrate deploy --schema=./prisma/schema.prisma
# Setup the environment
ENV NODE_ENV=production
ENV PATH=/app/document-processor/v-env/bin:$PATH
+4 -2
View File
@@ -26,8 +26,10 @@ services:
build:
context: ../.
dockerfile: ./docker/Dockerfile
args:
DATABASE_CONNECTION_STRING: ${DATABASE_CONNECTION_STRING}
volumes:
- "./.env:/app/backend/.env"
- "../backend/storage:/app/backend/storage"
- "../document-processor/hotdir/:/app/document-processor/hotdir"
ports:
- "3001:3001"
- "3355:3355"
+14 -5
View File
@@ -1,9 +1,18 @@
#!/bin/bash
# Migrate Postgres using and prisma client
cd /app/backend
DATABASE_CONNECTION_STRING=$DATABASE_CONNECTION_STRING npx prisma migrate deploy --schema=./prisma/schema.prisma
DATABASE_CONNECTION_STRING=$DATABASE_CONNECTION_STRING npx prisma generate --schema=./prisma/schema.prisma
# Start backend server & workers
node /app/backend/index.js &
NODE_ENV=development node /app/workers/index.js &
{ cd /app/workers/ && NODE_ENV=development yarn run inngest-cli dev -u http://0.0.0.0:3355/background-workers; } &
{ FLASK_ENV=production FLASK_APP=wsgi.py cd document-processor && gunicorn --timeout 300 --workers 4 --bind 0.0.0.0:8888 wsgi:api; } &
wait -n
exit $?
yarn run inngest-cli dev -u http://127.0.0.1:3355/background-workers
cd /app/workers/
NODE_ENV=development yarn run inngest-cli dev -u http://0.0.0.0:3355/background-workers &
cd /app/document-processor
FLASK_ENV=production FLASK_APP=wsgi.py gunicorn --timeout 300 --workers 4 --bind 0.0.0.0:8888 wsgi:api &
wait -n
exit $?