Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
PORT=3000 # Port number for the server
HOST=localhost # Use '0.0.0.0' to give LAN/internet access
NODE_ENV=development # 'development' | 'production'. Development debuggs, production keeps console clean
STREMIO_ADDON=false # Set to 'true' to enable Stremio addon functionality. Usage: host:port/stremio/manifest.json
CORS_ORIGIN="*" # CORS origin for the server. Set to '*' to allow all origins, or a specific origin (e.g., 'http://example.com')

# TMDB Configuration
TMDB_API_KEY=your_tmdb_api_key_here
Expand Down
172 changes: 172 additions & 0 deletions .github/workflows/ghcr-docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
name: Docker Build

on:
workflow_dispatch:
push:
branches: [main]
paths:
- '.github/workflows/docker-build.yml'
- 'Dockerfile'
- 'compose.yml'
- 'package.json'
- 'package-lock.json'
- 'tsconfig.json'
- 'src/**'
- '.env.example'
pull_request:
branches: [main]
paths:
- 'Dockerfile'
- 'compose.yml'
- 'package.json'
- 'package-lock.json'
- 'tsconfig.json'
- 'src/**'
- '.env.example'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

concurrency:
group: docker-build-${{ github.ref }}
cancel-in-progress: true

jobs:
prepare:
runs-on: ubuntu-latest
outputs:
run_date: ${{ steps.meta.outputs.run_date }}
app_version: ${{ steps.meta.outputs.app_version }}
arch_tag_amd64: ${{ steps.meta.outputs.arch_tag_amd64 }}
arch_tag_arm64: ${{ steps.meta.outputs.arch_tag_arm64 }}
steps:
- id: meta
run: |
RUN_DATE="$(date +%Y%m%d)"
APP_VERSION="main-${RUN_DATE}-${{ github.run_number }}"
{
echo "run_date=${RUN_DATE}"
echo "app_version=${APP_VERSION}"
echo "arch_tag_amd64=${APP_VERSION}-amd64"
echo "arch_tag_arm64=${APP_VERSION}-arm64"
} >> "$GITHUB_OUTPUT"
build-amd64:
runs-on: ubuntu-latest
needs: [prepare]
permissions:
contents: read
packages: write
outputs:
digest: ${{ steps.build-push.outputs.digest }}
steps:
- uses: actions/checkout@v4

- name: Set lowercase image name
run: echo "IMAGE_NAME_LC=${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"

- uses: docker/setup-buildx-action@v3

- uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build test image
run: docker buildx build --load -t cinepro-core:test .

- name: Test Docker image
run: |
docker run -d --name cinepro-core-test \
-p 3000:3000 \
-e NODE_ENV=production \
-e HOST=0.0.0.0 \
-e PORT=3000 \
-e CACHE_TYPE=memory \
-e TMDB_API_KEY=dummy-ci-key \
cinepro-core:test
sleep 10
docker logs cinepro-core-test
curl -sf http://localhost:3000 || true
- name: Cleanup test container
if: always()
run: docker rm -f cinepro-core-test || true

- name: Build and push Docker image
id: build-push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
provenance: false
sbom: false
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LC }}:${{ needs.prepare.outputs.arch_tag_amd64 }}
cache-from: type=gha,scope=amd64
cache-to: type=gha,mode=max,scope=amd64

build-arm64:
runs-on: ubuntu-24.04-arm
needs: [prepare]
permissions:
contents: read
packages: write
outputs:
digest: ${{ steps.build-push.outputs.digest }}
steps:
- uses: actions/checkout@v4

- name: Set lowercase image name
run: echo "IMAGE_NAME_LC=${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"

- uses: docker/setup-buildx-action@v3

- uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
id: build-push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/arm64
push: ${{ github.event_name != 'pull_request' }}
provenance: false
sbom: false
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LC }}:${{ needs.prepare.outputs.arch_tag_arm64 }}
cache-from: type=gha,scope=arm64
cache-to: type=gha,mode=max,scope=arm64

manifest:
runs-on: ubuntu-latest
needs: [prepare, build-amd64, build-arm64]
if: github.event_name != 'pull_request'
permissions:
contents: read
packages: write
steps:
- name: Set lowercase image name
run: echo "IMAGE_NAME_LC=${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"

- uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: docker/setup-buildx-action@v3

- name: Create and push multi-arch manifest
run: |
IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LC }}"
AMD64_IMAGE="${IMAGE}:${{ needs.prepare.outputs.arch_tag_amd64 }}"
ARM64_IMAGE="${IMAGE}:${{ needs.prepare.outputs.arch_tag_arm64 }}"
docker buildx imagetools create -t "${IMAGE}:${{ needs.prepare.outputs.app_version }}" "$AMD64_IMAGE" "$ARM64_IMAGE"
docker buildx imagetools create -t "${IMAGE}:main" "$AMD64_IMAGE" "$ARM64_IMAGE"
docker buildx imagetools create -t "${IMAGE}:latest" "$AMD64_IMAGE" "$ARM64_IMAGE"
Loading
Loading