2
0

Docker improvements (#760)

Closes #758 and #716
This commit is contained in:
Baptiste Arnaud
2023-09-04 14:43:48 +02:00
committed by GitHub
parent 5092e142ec
commit 66dc570527
3 changed files with 75 additions and 5 deletions

View File

@ -8,7 +8,7 @@ on:
branches: [main] branches: [main]
jobs: jobs:
build: build-amd:
env: env:
DATABASE_URL: 'postgresql://' DATABASE_URL: 'postgresql://'
strategy: strategy:
@ -30,6 +30,9 @@ jobs:
type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}} type=semver,pattern={{major}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- if: github.event_name != 'pull_request' - if: github.event_name != 'pull_request'
name: Log in to Docker Hub name: Log in to Docker Hub
uses: docker/login-action@v2 uses: docker/login-action@v2
@ -38,11 +41,67 @@ jobs:
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build image - name: Build image
uses: docker/build-push-action@v3 id: docker_build
uses: docker/build-push-action@v4
with: with:
context: .
push: ${{ github.event_name != 'pull_request' }} push: ${{ github.event_name != 'pull_request' }}
context: .
tags: ${{ steps.image-meta.outputs.tags }} tags: ${{ steps.image-meta.outputs.tags }}
labels: ${{ steps.image-meta.outputs.labels }} labels: ${{ steps.image-meta.outputs.labels }}
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: | build-args: |
SCOPE=${{ matrix.app }} SCOPE=${{ matrix.app }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
build-arm:
env:
DATABASE_URL: 'postgresql://'
strategy:
matrix:
app: ['builder', 'viewer']
runs-on: buildjet-2vcpu-ubuntu-2204-arm
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Extract existing image metadata
id: image-meta
uses: docker/metadata-action@v4
with:
images: baptistearno/typebot-${{ matrix.app }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- if: github.event_name != 'pull_request'
name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build image
id: docker_build
uses: docker/build-push-action@v4
with:
push: ${{ github.event_name != 'pull_request' }}
context: .
tags: ${{ steps.image-meta.outputs.tags }}
labels: ${{ steps.image-meta.outputs.labels }}
platforms: linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
SCOPE=${{ matrix.app }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

3
.gitignore vendored
View File

@ -35,4 +35,5 @@ typebotsToFix.json
snapshots snapshots
.env .env
.typebot-build

View File

@ -4,7 +4,17 @@ cd apps/builder;
node -e "const { configureRuntimeEnv } = require('next-runtime-env/build/configure'); configureRuntimeEnv();" node -e "const { configureRuntimeEnv } = require('next-runtime-env/build/configure'); configureRuntimeEnv();"
cd ../..; cd ../..;
./wait-for-it.sh $DATABASE_URL -- ./node_modules/.bin/prisma migrate deploy --schema=packages/prisma/postgresql/schema.prisma; export DB_HOST=$(echo $DATABASE_URL | awk -F[@//] '{print $4}')
export DB_PORT=$(echo $DATABASE_URL | awk -F[@//:] '{print $5}')
./wait-for-it.sh $DB_HOST:$DB_PORT -t 60 --strict
if [ $? -ne 0 ]; then
echo "Timed out waiting for database to be ready"
exit 1
fi
./node_modules/.bin/prisma migrate deploy --schema=packages/prisma/postgresql/schema.prisma;
node apps/builder/server.js; node apps/builder/server.js;