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

inputs:
repository:
description: 'The name of the repository to build'
required: true
dockerfile:
description: 'The name of the Dockerfile to build'
required: true
push:
description: 'Whether to push the image to the registry'
required: false
default: false
minify:
description: 'Whether to minify the build'
required: false
default: true
tag:
description: 'Optional Docker tag'
required: false
default: ''
depot-project:
description: 'Depot project ID (required if no depot.json; get it from depot.dev)'
required: false
default: ''

runs:
using: 'composite'
steps:
- uses: aws-actions/configure-aws-credentials@v3
with:
role-session-name: container_pusher
role-to-assume: arn:aws:iam::986677156374:role/actions/build/container_pusher
aws-region: us-east-1

- uses: aws-actions/amazon-ecr-login@v1
id: ecr
with:
mask-password: true

- uses: docker/metadata-action@v4
id: meta
with:
images: ${{ steps.ecr.outputs.registry }}/${{ inputs.repository }}
flavor: |
latest=false
tags: |
type=raw,enable=${{ inputs.tag != '' }},value=${{ inputs.tag }}
type=semver,pattern={{version}}
type=sha,enable=${{ !startsWith(github.ref, 'refs/tags') }},prefix=,format=long

- name: Set BUILD_DATE
id: meta_date
shell: bash
run: |
export TZ=America/Toronto
echo "timestamp=$(date +"%Y-%m-%d %H:%M:%S")" >> "$GITHUB_OUTPUT"

- name: Create ECR Registry
shell: bash
env:
ECR_REPOSITORY: ${{ inputs.repository }}
ECR_REGISTRY: ${{ steps.ecr.outputs.registry }}
run: |
aws --version
aws ecr create-repository --repository-name $ECR_REPOSITORY || true
aws ssm get-parameter --name '/cloud/container-registry/ecr-policy-document' --query 'Parameter.Value' | jq -r > repository-policy.json
aws ecr set-repository-policy --repository-name $ECR_REPOSITORY --policy-text file://repository-policy.json &> /dev/null

- name: Set up Depot CLI
uses: depot/setup-action@v1

- uses: depot/build-push-action@v1
with:
project: ${{ inputs.depot-project }}
build-args: |
MINIFY=${{ inputs.minify }}
DOCKER_TAG=${{ inputs.tag }}
BUILD_DATE=${{ steps.meta_date.outputs.timestamp }}
file: ${{ inputs.dockerfile }}
context: .
push: ${{ inputs.push }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
35 changes: 35 additions & 0 deletions .github/workflows/docker-chat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Build and push Chat Integration Docker

on:
pull_request:
branches:
- master
paths:
- 'integrations/chat/**'
- 'packages/sdk/**'

workflow_dispatch: {}

permissions:
id-token: write
contents: read

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false

jobs:
docker-chat:
runs-on: depot-ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup # FIXME: This should not be necessary, as the Dockerfile should be self-contained
uses: ./.github/actions/setup
with:
extra_filters: '-F @botpresshub/chat'
- uses: ./.github/actions/docker-build
with:
repository: chat-integration
dockerfile: ./integrations/chat/Dockerfile
push: ${{ github.event_name == 'workflow_dispatch' }}
depot-project: ${{ secrets.DEPOT_PROJECT_ID }}
7 changes: 6 additions & 1 deletion integrations/chat/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ COPY patches/source-map-js@1.2.1.patch patches/source-map-js@1.2.1.patch
# install
RUN pnpm install --frozen-lockfile
RUN pnpm install --frozen-lockfile --dir integrations/chat
RUN pnpm --filter @botpress/sdk add @bpinternal/zui --save-prod
RUN pnpm install --frozen-lockfile --dir packages/sdk
RUN pnpm install --frozen-lockfile --dir packages/cli

Expand All @@ -43,6 +44,10 @@ RUN pnpm --filter @botpresshub/chat run build
FROM node:${NODE_VERSION}-bullseye-slim AS deploy

COPY --from=base /usr/app/integrations/chat/.botpress/dist/index.cjs ./index.cjs
RUN echo -e "const server = require('./index.cjs')\nserver.default.start()" > server.js
RUN echo "const server = require('./index.cjs')\nconst port = process.env.PORT ? parseInt(process.env.PORT, 10) : 8081\nserver.default.start(port)" > server.js

# set port env and expose it
ENV PORT=8081
EXPOSE ${PORT}

ENTRYPOINT ["node", "server.js"]
Loading