diff --git a/.github/workflows/publish_docker_images.yml b/.github/workflows/publish_docker_images.yml index 7a8ec747b..4c289c3bd 100644 --- a/.github/workflows/publish_docker_images.yml +++ b/.github/workflows/publish_docker_images.yml @@ -8,7 +8,7 @@ on: branches: [main] jobs: - build: + build-amd: env: DATABASE_URL: 'postgresql://' strategy: @@ -30,6 +30,9 @@ jobs: 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 @@ -38,11 +41,67 @@ jobs: password: ${{ secrets.DOCKER_PASSWORD }} - name: Build image - uses: docker/build-push-action@v3 + id: docker_build + uses: docker/build-push-action@v4 with: - context: . push: ${{ github.event_name != 'pull_request' }} + context: . tags: ${{ steps.image-meta.outputs.tags }} labels: ${{ steps.image-meta.outputs.labels }} + platforms: linux/amd64 + 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 }} + + 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 }} diff --git a/.gitignore b/.gitignore index 0236cd30b..448d5668f 100644 --- a/.gitignore +++ b/.gitignore @@ -35,4 +35,5 @@ typebotsToFix.json snapshots -.env \ No newline at end of file +.env +.typebot-build \ No newline at end of file diff --git a/scripts/builder-entrypoint.sh b/scripts/builder-entrypoint.sh index 69a6f1cf4..2d6353fbd 100644 --- a/scripts/builder-entrypoint.sh +++ b/scripts/builder-entrypoint.sh @@ -4,7 +4,17 @@ cd apps/builder; node -e "const { configureRuntimeEnv } = require('next-runtime-env/build/configure'); configureRuntimeEnv();" 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; \ No newline at end of file