Skip to content

Commit

Permalink
Add a Docker build step.
Browse files Browse the repository at this point in the history
And misc pnpm improvements.
  • Loading branch information
kixelated committed Oct 3, 2023
1 parent fdea379 commit a145daf
Show file tree
Hide file tree
Showing 16 changed files with 380 additions and 147 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
node_modules
dist
10 changes: 4 additions & 6 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ jobs:
- uses: actions/setup-node@v3
- uses: pnpm/action-setup@v2
with:
run_install: true
run_install: true

- name: build
run: pnpm -r build

- name: lint
run: pnpm -r lint
- run: pnpm ci
- run: pnpm build
- run: pnpm lint
61 changes: 61 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Release Docker Image

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
push:
branches: ["main"]

env:
# Use the free Github repository
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write

# Only one release at a time and cancel prior releases
concurrency:
group: release
cancel-in-progress: true

steps:
- name: Checkout repository
uses: actions/checkout@v3

# I'm paying for Depot for faster ARM builds.
- uses: depot/setup-action@v1

# Login against a Docker registry
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Depot
- name: Build and push Docker image
id: build-and-push
uses: depot/build-push-action@v1
with:
project: hppp3x0qjc
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# See: https://pnpm.io/docker
FROM node:lts AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

COPY . /app
WORKDIR /app

FROM base AS prod-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile

FROM base AS build
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run build

FROM base
COPY --from=prod-deps /app/node_modules /app/node_modules
COPY --from=build /app/web/dist /app/web/dist

ENV HOST=0.0.0.0
ENV PORT=443
EXPOSE 443

CMD [ "node", "./web/dist/server/entry.mjs" ]
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ You'll either need to run a local server using [moq-rs](https://github.com/kixel
Join the [Discord](https://discord.gg/FCYF3p99mr) for updates and discussion.

## Setup

Install the dependencies with `pnpm`:

```bash
pnpm install
```

## Development

Run the development web server:

```bash
pnpm dev --open
pnpm dev
```

## License
Expand Down
5 changes: 1 addition & 4 deletions lib/common/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"extends": "../tsconfig.json",
"include": ["."],
"compilerOptions": {
"types": ["web"]
}
"include": ["."]
}
2 changes: 1 addition & 1 deletion lib/contribute/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "../tsconfig.json",
"include": ["."],
"compilerOptions": {
"types": ["dom-mediacapture-transform", "dom-webcodecs", "web"]
"types": ["dom-mediacapture-transform", "dom-webcodecs"]
},
"references": [
{
Expand Down
2 changes: 1 addition & 1 deletion lib/media/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "../tsconfig.json",
"include": ["."],
"compilerOptions": {
"types": ["mp4box", "web"]
"types": ["mp4box"]
},
"references": [
{
Expand Down
7 changes: 3 additions & 4 deletions lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
"repository": "github:kixelated/moq-js",
"scripts": {
"build": "tsc -b . && cp README.md package.json ../LICENSE* ./dist",
"release": "pnpm run build && pnpm publish ./dist",
"release": "pnpm build && pnpm publish ./dist",
"lint": "eslint .",
"fmt": "prettier --write ."
},
"devDependencies": {
"@types/audioworklet": "^0.0.50",
"@types/dom-mediacapture-transform": "^0.1.6",
"@types/dom-webcodecs": "^0.1.8",
"@types/web": "^0.0.113",
"@typescript/lib-dom": "npm:@types/web@^0.0.115",
"@typescript-eslint/eslint-plugin": "^6.4.0",
"@typescript-eslint/parser": "^6.4.0",
"eslint": "^8.47.0",
Expand All @@ -25,6 +25,5 @@
},
"dependencies": {
"mp4box": "^0.5.2"
},
"packageManager": "[email protected]"
}
}
2 changes: 1 addition & 1 deletion lib/playback/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"include": ["."],
"exclude": ["./worklet"],
"compilerOptions": {
"types": ["dom-mediacapture-transform", "dom-webcodecs", "web"]
"types": ["dom-mediacapture-transform", "dom-webcodecs"]
},
"references": [
{
Expand Down
3 changes: 0 additions & 3 deletions lib/transport/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"extends": "../tsconfig.json",
"include": ["."],
"compilerOptions": {
"types": ["web"]
},
"references": [
{
"path": "../common"
Expand Down
4 changes: 2 additions & 2 deletions lib/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"sourceMap": true,
"isolatedModules": true,
"types": [], // Don't automatically import any @types modules.
"lib": ["es2022"],
"typeRoots": ["./types", "./node_modules/@types"]
"lib": ["es2022", "dom"],
"typeRoots": ["./types", "../node_modules/@types"]
},
"references": [
{
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"nameweb": "moq-js",
"workspaces": [
"lib",
"web"
"lib",
"web"
],
"private": true,
"scripts": {
Expand All @@ -11,5 +11,5 @@
"lint": "pnpm -r lint",
"fmt": "pnpm -r fmt"
},
"packageManager": "pnpm@8.7.6"
}
"packageManager": "pnpm@8.8.0"
}
Loading

0 comments on commit a145daf

Please sign in to comment.