Skip to content

Commit

Permalink
Docker support (#60)
Browse files Browse the repository at this point in the history
* Added Dockerfile

* Minor changes to API OpenAPI spec documentation
  • Loading branch information
matvp91 authored Oct 14, 2024
1 parent c2da271 commit 1de7818
Show file tree
Hide file tree
Showing 48 changed files with 892 additions and 475 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ Video from source to consumer is a hard task to get right, [howvideo.works](http
## Getting Started

```shell
# Clone repository locally.
git clone git@github.com:matvp91/mixwave.git
cd mixwave
# We have prebuilt containers, see docker/docker-compose.yml

cp config.env.example config.env
# Open config.env and change the variables.
Expand All @@ -60,8 +58,9 @@ docker compose up -d
We try to make it as easy for you to run Mixwave locally. Install [Bun](https://bun.sh/) (v1.1.30 or above), and [pnpm](https://pnpm.io/installation). Next up, make sure you have the `config.env` file configured properly as well. We recommend [Redis Stack](https://redis.io/docs/latest/operate/oss_and_stack/install/install-stack/) in your dev env. Run the following commands at the root of the project:

```shell
pnpm install
pnpm dev # That's it!
pnpm install-bin # Helper to install ffmpeg, packager
pnpm install # Install npm dependencies
pnpm dev # Run dev env
```

Go to `http://localhost:52000` and you're good to go!
Expand Down
57 changes: 0 additions & 57 deletions docker-compose.yml

This file was deleted.

6 changes: 6 additions & 0 deletions docker/build-container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
echo mixwave/$1
cd ./packages/$1
pnpm run build
docker build . --no-cache --tag=mixwave/$1:latest
docker push mixwave/$1:latest
56 changes: 56 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
version: "3"

volumes:
mixwave_redis_data:

services:
mixwave-dashboard:
image: "mixwave/dashboard:latest"
ports:
- 52000:52000
environment:
- PUBLIC_API_ENDPOINT=http://localhost:52001
- PUBLIC_STITCHER_ENDPOINT=http://localhost:52002

mixwave-api:
image: "mixwave/api:latest"
restart: always
ports:
- 52001:52001
depends_on:
- mixwave-redis
env_file: config.env
environment:
- REDIS_HOST=mixwave-redis
- REDIS_PORT=6379

mixwave-stitcher:
image: "mixwave/stitcher:latest"
restart: always
ports:
- 52002:52002
depends_on:
- mixwave-redis
env_file: config.env
environment:
- REDIS_HOST=mixwave-redis
- REDIS_PORT=6379

mixwave-artisan:
image: "mixwave/artisan:latest"
restart: always
depends_on:
- mixwave-redis
env_file: config.env
environment:
- REDIS_HOST=mixwave-redis
- REDIS_PORT=6379

mixwave-redis:
image: redis/redis-stack-server:7.2.0-v6
ports:
- 6379:6379
healthcheck:
test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
volumes:
- mixwave_redis_data:/data
79 changes: 65 additions & 14 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,70 @@ next:

## Docker Compose

Since Mixwave consists of several packages that need to work together, the easiest way to get yourself familiar is to use [Docker](https://docs.docker.com/engine/install/).

First, clone the repository.

::: code-group

```sh [shell]
$ git clone git@github.com:matvp91/mixwave.git
$ cd mixwave
If you're familiar with [Docker](https://docs.docker.com/engine/install/), we suggest you use our hosted Docker images.

Create a new folder with a fresh `docker-compose.yml` file and copy it from below. The original file can be found on [GitHub](https://github.com/matvp91/mixwave/tree/main/docker/docker-compose.yml).

```yaml
version: "3"

volumes:
mixwave_redis_data:

services:
mixwave-dashboard:
image: "mixwave/dashboard:latest"
ports:
- 52000:52000
environment:
- PUBLIC_API_ENDPOINT=http://localhost:52001
- PUBLIC_STITCHER_ENDPOINT=http://localhost:52002

mixwave-api:
image: "mixwave/api:latest"
restart: always
ports:
- 52001:52001
depends_on:
- mixwave-redis
env_file: config.env
environment:
- REDIS_HOST=mixwave-redis
- REDIS_PORT=6379

mixwave-stitcher:
image: "mixwave/stitcher:latest"
restart: always
ports:
- 52002:52002
depends_on:
- mixwave-redis
env_file: config.env
environment:
- REDIS_HOST=mixwave-redis
- REDIS_PORT=6379

mixwave-artisan:
image: "mixwave/artisan:latest"
restart: always
depends_on:
- mixwave-redis
env_file: config.env
environment:
- REDIS_HOST=mixwave-redis
- REDIS_PORT=6379

mixwave-redis:
image: redis/redis-stack-server:7.2.0-v6
ports:
- 6379:6379
healthcheck:
test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
volumes:
- mixwave_redis_data:/data
```
:::

Create a `config.env` file at the root of the project. Make sure you use the same keys defined in `config.env.example`.
Create a `config.env` file in the same folder. The original example can be found on [GitHub](https://github.com/matvp91/mixwave/blob/main/config.env.example).

::: code-group

Expand All @@ -40,12 +90,12 @@ PUBLIC_S3_ENDPOINT=https://s3.us-east-1.amazonaws.com/mixwave

:::

Build and start the necessary services with [Docker Compose](https://docs.docker.com/compose/).
Start the necessary services with [Docker Compose](https://docs.docker.com/compose/).

::: code-group

```sh [shell]
$ docker compose up -d --build
$ docker compose up -d
```

:::
Expand Down Expand Up @@ -79,6 +129,7 @@ Make sure you have a config.env file at the root, and it contains the right info
We aim to make it as easy for you to get started with development. All you'll have to do is install the dependencies (once), and call the dev script.

```sh
pnpm install-bin # helper to install ffmpeg, packager
pnpm install
pnpm dev
```
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"build": "turbo build",
"lint": "turbo lint",
"typecheck": "turbo typecheck",
"test": "turbo test"
"test": "turbo test",
"install-bin": "turbo install-bin"
},
"packageManager": "pnpm@8.15.1",
"devDependencies": {
Expand Down
25 changes: 6 additions & 19 deletions packages/api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
FROM node:20-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
RUN pnpm install turbo@^2 -g
FROM oven/bun:1

FROM base AS builder
WORKDIR /app
COPY . .
RUN turbo prune @mixwave/api --docker
WORKDIR /usr/src/app
COPY ./dist .

FROM base AS installer
WORKDIR /app
COPY --from=builder /app/out/json/ .
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
COPY --from=builder /app/out/full/ .

FROM oven/bun:1 as runner
WORKDIR /app
COPY --from=installer ./app .
CMD [ "bun", "run", "./packages/api/src/index.ts" ]
USER bun
EXPOSE 52001/tcp
CMD [ "bun", "run", "./index.js" ]
Loading

0 comments on commit 1de7818

Please sign in to comment.