diff --git a/.github/workflows/apps-api.yaml b/.github/workflows/apps-api.yaml index 153a0f906..103e03f87 100644 --- a/.github/workflows/apps-api.yaml +++ b/.github/workflows/apps-api.yaml @@ -20,62 +20,8 @@ on: jobs: build: - runs-on: ubuntu-latest - - permissions: - contents: read - id-token: write - - strategy: - matrix: - platform: [linux/amd64] - - steps: - - uses: actions/checkout@v4 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Check if Docker Hub secrets are available - run: | - if [ -z "${{ secrets.DOCKERHUB_USERNAME }}" ] || [ -z "${{ secrets.DOCKERHUB_TOKEN }}" ]; then - echo "DOCKERHUB_LOGIN=false" >> $GITHUB_ENV - else - echo "DOCKERHUB_LOGIN=true" >> $GITHUB_ENV - fi - - - name: Login to Docker Hub - uses: docker/login-action@v3 - if: env.DOCKERHUB_LOGIN == 'true' - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: ctrlplane/api - tags: | - type=sha,format=short,prefix= - - - name: Build - uses: docker/build-push-action@v6 - if: github.ref != 'refs/heads/main' - with: - push: false - file: apps/api/Dockerfile - platforms: ${{ matrix.platform }} - tags: ${{ steps.meta.outputs.tags }} - - - name: Build and Push - uses: docker/build-push-action@v6 - if: github.ref == 'refs/heads/main' && env.DOCKERHUB_LOGIN == 'true' - with: - push: true - file: apps/api/Dockerfile - platforms: ${{ matrix.platform }} - tags: ${{ steps.meta.outputs.tags }} + uses: ./.github/workflows/build-image.yaml + secrets: inherit + with: + image-name: ctrlplane/api + dockerfile: apps/api/Dockerfile diff --git a/.github/workflows/apps-relay.yaml b/.github/workflows/apps-relay.yaml index 1b1a3fbf7..ad246d8af 100644 --- a/.github/workflows/apps-relay.yaml +++ b/.github/workflows/apps-relay.yaml @@ -48,68 +48,9 @@ jobs: run: go test -race ./... build: - runs-on: ubuntu-latest - - permissions: - contents: read - id-token: write - - strategy: - matrix: - platform: [linux/amd64] - - defaults: - run: - working-directory: apps/relay - - steps: - - uses: actions/checkout@v4 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Check if Docker Hub secrets are available - run: | - if [ -z "${{ secrets.DOCKERHUB_USERNAME }}" ] || [ -z "${{ secrets.DOCKERHUB_TOKEN }}" ]; then - echo "DOCKERHUB_LOGIN=false" >> $GITHUB_ENV - else - echo "DOCKERHUB_LOGIN=true" >> $GITHUB_ENV - fi - - - name: Login to Docker Hub - uses: docker/login-action@v3 - if: env.DOCKERHUB_LOGIN == 'true' - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: ctrlplane/relay - tags: | - type=sha,format=short,prefix= - - - name: Build - uses: docker/build-push-action@v6 - if: github.ref != 'refs/heads/main' - with: - context: apps/relay - push: false - file: apps/relay/Dockerfile - platforms: ${{ matrix.platform }} - tags: ${{ steps.meta.outputs.tags }} - - - name: Build and Push - uses: docker/build-push-action@v6 - if: github.ref == 'refs/heads/main' && env.DOCKERHUB_LOGIN == 'true' - with: - context: apps/relay - push: true - file: apps/relay/Dockerfile - platforms: ${{ matrix.platform }} - tags: ${{ steps.meta.outputs.tags }} + uses: ./.github/workflows/build-image.yaml + secrets: inherit + with: + image-name: ctrlplane/relay + dockerfile: apps/relay/Dockerfile + context: apps/relay diff --git a/.github/workflows/apps-web.yaml b/.github/workflows/apps-web.yaml index d3c0b8b31..caa9a6431 100644 --- a/.github/workflows/apps-web.yaml +++ b/.github/workflows/apps-web.yaml @@ -14,77 +14,10 @@ on: - "packages/**" workflow_dispatch: -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }}/web - jobs: - build-and-push: - runs-on: ubuntu-latest - - permissions: - contents: read - packages: write - - strategy: - matrix: - platform: [linux/amd64] - - steps: - - uses: actions/checkout@v4 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Check if Docker Hub secrets are available - run: | - if [ -z "${{ secrets.DOCKERHUB_USERNAME }}" ] || [ -z "${{ secrets.DOCKERHUB_TOKEN }}" ]; then - echo "DOCKERHUB_LOGIN=false" >> $GITHUB_ENV - else - echo "DOCKERHUB_LOGIN=true" >> $GITHUB_ENV - fi - - - name: Log in to Container Registry - uses: docker/login-action@v3 - if: env.DOCKERHUB_LOGIN == 'true' - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: ctrlplane/web - tags: | - type=sha,format=short,prefix= - - - name: Build - uses: docker/build-push-action@v6 - if: github.ref != 'refs/heads/main' - with: - push: false - file: apps/web/Dockerfile - platforms: ${{ matrix.platform }} - tags: ${{ steps.meta.outputs.tags }} - - - name: Build and Push - uses: docker/build-push-action@v6 - if: github.ref == 'refs/heads/main' && env.DOCKERHUB_LOGIN == 'true' - with: - push: true - file: apps/web/Dockerfile - platforms: ${{ matrix.platform }} - tags: ${{ steps.meta.outputs.tags }} - - - name: Summary - run: | - echo "### Docker Image Built Successfully! 🚀" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "**Image Tags:**" >> $GITHUB_STEP_SUMMARY - echo '```' >> $GITHUB_STEP_SUMMARY - echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY - echo '```' >> $GITHUB_STEP_SUMMARY + build: + uses: ./.github/workflows/build-image.yaml + secrets: inherit + with: + image-name: ctrlplane/web + dockerfile: apps/web/Dockerfile diff --git a/.github/workflows/apps-workspace-engine-router.yaml b/.github/workflows/apps-workspace-engine-router.yaml index c221c9ac4..7fc8f4ae8 100644 --- a/.github/workflows/apps-workspace-engine-router.yaml +++ b/.github/workflows/apps-workspace-engine-router.yaml @@ -14,73 +14,9 @@ on: jobs: build: - runs-on: ubuntu-latest - - permissions: - contents: read - id-token: write - - strategy: - matrix: - platform: [linux/amd64] - - defaults: - run: - working-directory: apps/workspace-engine-router - - steps: - - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: "1.25" - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Check if Docker Hub secrets are available - run: | - if [ -z "${{ secrets.DOCKERHUB_USERNAME }}" ] || [ -z "${{ secrets.DOCKERHUB_TOKEN }}" ]; then - echo "DOCKERHUB_LOGIN=false" >> $GITHUB_ENV - else - echo "DOCKERHUB_LOGIN=true" >> $GITHUB_ENV - fi - - - name: Login to Docker Hub - uses: docker/login-action@v3 - if: env.DOCKERHUB_LOGIN == 'true' - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: ctrlplane/workspace-engine-router - tags: | - type=sha,format=short,prefix= - - - name: Build - uses: docker/build-push-action@v6 - if: github.ref != 'refs/heads/main' - with: - context: apps/workspace-engine-router - push: false - file: apps/workspace-engine-router/Dockerfile - platforms: ${{ matrix.platform }} - tags: ${{ steps.meta.outputs.tags }} - - - name: Build and Push - uses: docker/build-push-action@v6 - if: github.ref == 'refs/heads/main' && env.DOCKERHUB_LOGIN == 'true' - with: - context: apps/workspace-engine-router - push: true - file: apps/workspace-engine-router/Dockerfile - platforms: ${{ matrix.platform }} - tags: ${{ steps.meta.outputs.tags }} + uses: ./.github/workflows/build-image.yaml + secrets: inherit + with: + image-name: ctrlplane/workspace-engine-router + dockerfile: apps/workspace-engine-router/Dockerfile + context: apps/workspace-engine-router diff --git a/.github/workflows/apps-workspace-engine.yaml b/.github/workflows/apps-workspace-engine.yaml index 78b95207a..6ad04afbf 100644 --- a/.github/workflows/apps-workspace-engine.yaml +++ b/.github/workflows/apps-workspace-engine.yaml @@ -48,68 +48,9 @@ jobs: run: go test -race ./... build: - runs-on: ubuntu-latest - - permissions: - contents: read - id-token: write - - strategy: - matrix: - platform: [linux/amd64] - - defaults: - run: - working-directory: apps/workspace-engine - - steps: - - uses: actions/checkout@v4 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Check if Docker Hub secrets are available - run: | - if [ -z "${{ secrets.DOCKERHUB_USERNAME }}" ] || [ -z "${{ secrets.DOCKERHUB_TOKEN }}" ]; then - echo "DOCKERHUB_LOGIN=false" >> $GITHUB_ENV - else - echo "DOCKERHUB_LOGIN=true" >> $GITHUB_ENV - fi - - - name: Login to Docker Hub - uses: docker/login-action@v3 - if: env.DOCKERHUB_LOGIN == 'true' - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: ctrlplane/workspace-engine - tags: | - type=sha,format=short,prefix= - - - name: Build - uses: docker/build-push-action@v6 - if: github.ref != 'refs/heads/main' - with: - context: apps/workspace-engine - push: false - file: apps/workspace-engine/Dockerfile - platforms: ${{ matrix.platform }} - tags: ${{ steps.meta.outputs.tags }} - - - name: Build and Push - uses: docker/build-push-action@v6 - if: github.ref == 'refs/heads/main' && env.DOCKERHUB_LOGIN == 'true' - with: - context: apps/workspace-engine - push: true - file: apps/workspace-engine/Dockerfile - platforms: ${{ matrix.platform }} - tags: ${{ steps.meta.outputs.tags }} + uses: ./.github/workflows/build-image.yaml + secrets: inherit + with: + image-name: ctrlplane/workspace-engine + dockerfile: apps/workspace-engine/Dockerfile + context: apps/workspace-engine diff --git a/.github/workflows/build-image.yaml b/.github/workflows/build-image.yaml new file mode 100644 index 000000000..115e41997 --- /dev/null +++ b/.github/workflows/build-image.yaml @@ -0,0 +1,97 @@ +name: Reusable / Docker Image Build + +on: + workflow_call: + inputs: + image-name: + required: true + type: string + description: "Docker image name (e.g., ctrlplane/api)" + dockerfile: + required: true + type: string + description: "Path to the Dockerfile" + context: + required: false + type: string + default: "." + description: "Docker build context path" + platform: + required: false + type: string + default: "linux/amd64,linux/arm64" + description: "Target platform for the Docker image" + +jobs: + build: + runs-on: ubuntu-latest + + permissions: + contents: read + id-token: write + + steps: + - uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Check if Docker Hub secrets are available + env: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + run: | + if [ -z "$DOCKERHUB_USERNAME" ] || [ -z "$DOCKERHUB_TOKEN" ]; then + echo "DOCKERHUB_LOGIN=false" >> $GITHUB_ENV + else + echo "DOCKERHUB_LOGIN=true" >> $GITHUB_ENV + fi + + - name: Login to Docker Hub + uses: docker/login-action@v3 + if: env.DOCKERHUB_LOGIN == 'true' + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ inputs.image-name }} + tags: | + type=sha,format=short,prefix= + + - name: Build + uses: docker/build-push-action@v6 + if: github.ref != 'refs/heads/main' + with: + context: ${{ inputs.context }} + push: false + file: ${{ inputs.dockerfile }} + platforms: ${{ inputs.platform }} + tags: ${{ steps.meta.outputs.tags }} + + - name: Build and Push + uses: docker/build-push-action@v6 + if: github.ref == 'refs/heads/main' && env.DOCKERHUB_LOGIN == 'true' + with: + context: ${{ inputs.context }} + push: true + file: ${{ inputs.dockerfile }} + platforms: ${{ inputs.platform }} + tags: ${{ steps.meta.outputs.tags }} + + - name: Summary + env: + IMAGE_TAGS: ${{ steps.meta.outputs.tags }} + run: | + echo "### Docker Image Built Successfully! 🚀" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Image Tags:**" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "$IMAGE_TAGS" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/packages-migrations.yaml b/.github/workflows/packages-migrations.yaml index 092333f19..15b4f5264 100644 --- a/.github/workflows/packages-migrations.yaml +++ b/.github/workflows/packages-migrations.yaml @@ -13,58 +13,11 @@ on: - packages/db/** - .github/workflows/packages-migrations.yaml - packages/validators/src/auth/index.ts + jobs: build: - runs-on: ubuntu-latest - permissions: - contents: read - id-token: write - steps: - - uses: actions/checkout@v4 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Check if Docker Hub secrets are available - run: | - if [ -z "${{ secrets.DOCKERHUB_USERNAME }}" ] || [ -z "${{ secrets.DOCKERHUB_TOKEN }}" ]; then - echo "DOCKERHUB_LOGIN=false" >> $GITHUB_ENV - else - echo "DOCKERHUB_LOGIN=true" >> $GITHUB_ENV - fi - - - name: Login to Docker Hub - uses: docker/login-action@v3 - if: env.DOCKERHUB_LOGIN == 'true' - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: ctrlplane/migrations - tags: | - type=sha,format=short,prefix= - - - name: Build - uses: docker/build-push-action@v6 - if: github.ref != 'refs/heads/main' - with: - push: false - file: packages/db/Dockerfile - platforms: ${{ matrix.platform }} - tags: ${{ steps.meta.outputs.tags }} - - - name: Build and Push - uses: docker/build-push-action@v6 - if: github.ref == 'refs/heads/main' && env.DOCKERHUB_LOGIN == 'true' - with: - push: true - file: packages/db/Dockerfile - platforms: ${{ matrix.platform }} - tags: ${{ steps.meta.outputs.tags }} + uses: ./.github/workflows/build-image.yaml + secrets: inherit + with: + image-name: ctrlplane/migrations + dockerfile: packages/db/Dockerfile diff --git a/apps/web/app/routes/auth/login.tsx b/apps/web/app/routes/auth/login.tsx index d0dba12b6..6449b79fb 100644 --- a/apps/web/app/routes/auth/login.tsx +++ b/apps/web/app/routes/auth/login.tsx @@ -88,7 +88,7 @@ function LoginEmailPassword() { Password - +