Skip to content

Commit

Permalink
perf: switch to Bun, adjust upload buttons, update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bouassaba authored Jun 30, 2024
1 parent 24a8c56 commit 3133b1b
Show file tree
Hide file tree
Showing 18 changed files with 282 additions and 16,095 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/.idea
/.run
.idea
.run
156 changes: 156 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,162 @@ docker compose up -d \
mailhog
```

### Run Infrastructure Services From Binaries on macOS

#### Install Languages and Runtimes

Install Bun for your platform:

https://bun.sh

Install [NVM](https://github.com/nvm-sh/nvm?tab=readme-ov-file#installing-and-updating).

Install Node.js v20.x with NVM and set it as default:

```shell
nvm install lts/iron
```

```shell
nvm alias default lts/iron
```

Install Go for your platform:

https://go.dev

Install .NET for your platform:

http://dot.net

Install latest JDK with [SDKMAN!](https://sdkman.io):

```shell
sdk install java
```

Install latest Gradle with [SDKMAN!](https://sdkman.io):

```shell
sdk install gradle
```

Install [PDM](https://pdm-project.org/en/latest).

Install Python 3.12 with PDM:

```shell
pdm py install [email protected]
```

#### CockroachDB

Download the [binary archive](https://www.cockroachlabs.com/docs/releases/?filters=mac) and extract the archive.

Start CockroachDB:

```shell
./cockroach start-single-node --insecure --http-addr=0.0.0.0:18080
```

Using DBeaver or any PostgreSQL GUI, connect with `root` and no password, then create a user and database:

```sql
CREATE DATABASE voltaserve;
CREATE USER voltaserve;
GRANT ALL PRIVILEGES ON DATABASE voltaserve TO voltaserve;
```

Run the [postgres/schema.sql]() in the newly created database.

#### Redis

Download the [source archive](https://redis.io/docs/latest/operate/oss_and_stack/install/install-redis/install-redis-from-source/) and follow the guide to build from the source.

Start Redis:

```shell
./src/redis-server
```

#### MinIO

Download the [binary](https://min.io/docs/minio/macos/index.html) and move it into its own folder like: `minio`.

Assign execute permission to the binary:

```shell
chmod +x ./minio
```

Start MinIO:

```shell
MINIO_ROOT_USER=voltaserve MINIO_ROOT_PASSWORD=voltaserve ./minio server ./data --console-address ":9001"
```

#### Meilisearch

Download the [binary](https://github.com/meilisearch/meilisearch/releases/tag/v1.8.3) and move it into its own folder like: `meilisearch`.

This [guide](https://www.meilisearch.com/docs/learn/getting_started/installation) might be useful.

Assign execute permission to the binary:

```shell
chmod +x ./meilisearch
```

_Note: the binary will have a suffix matching the architecture of your computer._

#### Mailhog

Install:

```shell
go install github.com/mailhog/MailHog@latest
```

Start Mailhog:

```shell
MailHog
```

### Install Command Line Tools

```shell
brew install --cask libreoffice
```

```shell
npm i -g gltf-pipeline
```

```shell
npm i -g @shopify/screenshot-glb
```

```shell
brew install ocrmypdf
```

```shell
brew install exiftool
```

```shell
brew install poppler
```

```shell
brew install imagemagick
```

```shell
brew install ffmpeg
```

### Run Microservices

Start each microservice separately in a new terminal as described here:
Expand Down
10 changes: 5 additions & 5 deletions api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ Build binary:
go build .
```

Build Docker image:
Lint code:

```shell
docker build -t voltaserve/api .
golangci-lint run
```

Run code linter:
Build Docker image:

```shell
golangci-lint run
docker build -t voltaserve/api .
```

## Generate and Publish Documentation
## Generate Documentation

Format swag comments:

Expand Down
10 changes: 5 additions & 5 deletions conversion/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ Build binary:
go build .
```

Build Docker image:
Lint code:

```shell
docker build -t voltaserve/conversion .
golangci-lint run
```

Run code linter:
Build Docker image:

```shell
golangci-lint run
docker build -t voltaserve/conversion .
```

## Generate and Publish Documentation
## Generate Documentation

Format swag comments:

Expand Down
8 changes: 4 additions & 4 deletions conversion/pipeline/mosaic_pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/minio/minio-go/v7"
)

type moasicPipeline struct {
type mosaicPipeline struct {
videoProc *processor.VideoProcessor
fileIdent *identifier.FileIdentifier
s3 *infra.S3Manager
Expand All @@ -23,7 +23,7 @@ type moasicPipeline struct {
}

func NewMosaicPipeline() model.Pipeline {
return &moasicPipeline{
return &mosaicPipeline{
videoProc: processor.NewVideoProcessor(),
fileIdent: identifier.NewFileIdentifier(),
s3: infra.NewS3Manager(),
Expand All @@ -32,7 +32,7 @@ func NewMosaicPipeline() model.Pipeline {
}
}

func (p *moasicPipeline) Run(opts client.PipelineRunOptions) error {
func (p *mosaicPipeline) Run(opts client.PipelineRunOptions) error {
inputPath := filepath.FromSlash(os.TempDir() + "/" + helper.NewID() + filepath.Ext(opts.Key))
if err := p.s3.GetFile(opts.Key, inputPath, opts.Bucket, minio.GetObjectOptions{}); err != nil {
return err
Expand Down Expand Up @@ -64,7 +64,7 @@ func (p *moasicPipeline) Run(opts client.PipelineRunOptions) error {
return nil
}

func (p *moasicPipeline) create(inputPath string, opts client.PipelineRunOptions) error {
func (p *mosaicPipeline) create(inputPath string, opts client.PipelineRunOptions) error {
if p.fileIdent.IsImage(opts.Key) {
if _, err := p.mosaicClient.Create(client.MosaicCreateOptions{
Path: inputPath,
Expand Down
20 changes: 16 additions & 4 deletions idp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,31 @@
Install dependencies:

```shell
npm i --legacy-peer-deps
bun i
```

Run for development:

```shell
npm run dev
bun run dev
```

Run for production:

```shell
npm run start
bun run start
```

Lint code:

```shell
bun run lint
```

Format code:

```shell
bun run format
```

Build Docker image:
Expand All @@ -26,7 +38,7 @@ Build Docker image:
docker build -t voltaserve/idp .
```

## Generate and Publish Documentation
## Generate Documentation

Generate `swagger.json`:

Expand Down
Binary file added idp/bun.lockb
Binary file not shown.
Loading

0 comments on commit 3133b1b

Please sign in to comment.