Skip to content
Open
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
67 changes: 67 additions & 0 deletions .github/actions/build-docker-image/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Build docker image
description: Build and push the Documenso Docker image to a registry

inputs:
registry_url:
description: Container registry hostname
required: false
default: ghcr.io
registry_username:
description: Registry username
required: true
registry_password:
description: Registry password or token
required: true
docker_image:
description: Repository/image name
required: true
docker_file:
description: Dockerfile path
required: false
default: ./docker/Dockerfile
docker_tag:
description: Docker tag to publish
required: false
default: latest
next_private_telemetry_key:
description: Optional telemetry key passed at build time
required: false
default: ''
next_private_telemetry_host:
description: Optional telemetry host passed at build time
required: false
default: ''

runs:
using: composite
steps:
- name: Login to registry
uses: docker/login-action@v3
with:
registry: ${{ inputs.registry_url }}
username: ${{ inputs.registry_username }}
password: ${{ inputs.registry_password }}

- name: Normalize image name
id: image
shell: bash
run: echo "name=$(echo '${{ inputs.docker_image }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT"

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push image
uses: docker/build-push-action@v6
with:
context: .
file: ${{ inputs.docker_file }}
push: true
tags: ${{ inputs.registry_url }}/${{ steps.image.outputs.name }}:${{ inputs.docker_tag }}
cache-from: type=registry,ref=${{ inputs.registry_url }}/${{ steps.image.outputs.name }}:${{ inputs.docker_tag }}-cache
cache-to: type=registry,ref=${{ inputs.registry_url }}/${{ steps.image.outputs.name }}:${{ inputs.docker_tag }}-cache,mode=max
build-args: |
NEXT_PRIVATE_TELEMETRY_KEY=${{ inputs.next_private_telemetry_key }}
NEXT_PRIVATE_TELEMETRY_HOST=${{ inputs.next_private_telemetry_host }}
64 changes: 64 additions & 0 deletions .github/workflows/production-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Deploy Production

env:
ENVIRONMENT: 'production'
IMAGE_NAME: ${{ github.repository }}
DOCKER_TAG: 'latest'

on:
push:
tags:
- 'v*'
branches:
- master
- main
workflow_dispatch:

permissions:
contents: read
packages: write

concurrency:
group: production-release-${{ github.ref }}-1
cancel-in-progress: true

jobs:
docker-build-production:
name: Build Latest Image
if: github.ref_type == 'branch'
runs-on: ubuntu-latest
environment:
name: 'production'
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build production image
uses: ./.github/actions/build-docker-image
with:
registry_username: ${{ github.actor }}
registry_password: ${{ secrets.GITHUB_TOKEN }}
docker_image: ${{ env.IMAGE_NAME }}
docker_tag: ${{ env.DOCKER_TAG }}
next_private_telemetry_key: ${{ secrets.NEXT_PRIVATE_TELEMETRY_KEY }}
next_private_telemetry_host: ${{ secrets.NEXT_PRIVATE_TELEMETRY_HOST }}

docker-build-tag:
name: Build tag image
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
environment:
name: 'production'
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build tagged image
uses: ./.github/actions/build-docker-image
with:
registry_username: ${{ github.actor }}
registry_password: ${{ secrets.GITHUB_TOKEN }}
docker_image: ${{ env.IMAGE_NAME }}
docker_tag: ${{ github.ref_name }}
next_private_telemetry_key: ${{ secrets.NEXT_PRIVATE_TELEMETRY_KEY }}
next_private_telemetry_host: ${{ secrets.NEXT_PRIVATE_TELEMETRY_HOST }}
40 changes: 40 additions & 0 deletions .github/workflows/staging-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Deploy Staging

env:
ENVIRONMENT: 'staging'
IMAGE_NAME: ${{ github.repository }}

on:
push:
branches:
- staging
- staging-*
workflow_dispatch:

permissions:
contents: read
packages: write

concurrency:
group: staging-release-${{ github.ref }}-1
cancel-in-progress: true

jobs:
docker-build-staging:
name: Build Staging Image
runs-on: ubuntu-latest
environment:
name: 'staging'
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build staging image
uses: ./.github/actions/build-docker-image
with:
registry_username: ${{ github.actor }}
registry_password: ${{ secrets.GITHUB_TOKEN }}
docker_image: ${{ env.IMAGE_NAME }}
docker_tag: ${{ env.ENVIRONMENT }}
next_private_telemetry_key: ${{ secrets.NEXT_PRIVATE_TELEMETRY_KEY }}
next_private_telemetry_host: ${{ secrets.NEXT_PRIVATE_TELEMETRY_HOST }}
Loading