Github Action Self-Hosted Runner - Docker builder
brycelund
PROOP

10 months ago

I've read through the guide here: https://docs.railway.com/tutorials/github-actions-runners#known-limitations but I want to make sure I understand correctly.

Am I correct in understanding that it is currently impossible to use a Railway Self-Hosted Runner to build a docker image and push it to AWS ECR?

Example:

name: Build and Deploy API to AWS ECR and ECS

on:
  push:
    branches:
      - master
    paths:
      - 'apps/server/**'
      - '.github/workflows/api-deploy.yml'

jobs:
  build-and-deploy:
    runs-on: railway

    steps:
      # Checkout the repository
      - name: Checkout code
        uses: actions/checkout@v3

      # Setup PNPM with proper caching
      - name: Setup PNPM
        uses: pnpm/action-setup@v2
        with:
          version: latest

      # Setup Node.js
      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: '22'

      # Install dependencies first
      - name: Install Dependencies
        run: pnpm install

      # Cache dependencies after installation
      - name: Cache dependencies
        uses: actions/cache@v3
        with:
          path: |
            **/node_modules
            ~/.pnpm-store
          key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
          restore-keys: |
            ${{ runner.os }}-pnpm-

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

      # Configure AWS credentials
      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v4
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: ${{ secrets.AWS_REGION }}

      # Login to Amazon ECR
      - name: Login to Amazon ECR
        id: login-ecr
        uses: aws-actions/amazon-ecr-login@v2

      # Build and push using Docker Buildx
      - name: Build and push Docker image
        uses: docker/build-push-action@v5
        with:
          context: .
          file: ./apps/server/Dockerfile
          platforms: linux/arm64
          push: true
          tags: ${{ steps.login-ecr.outputs.registry }}/${{ secrets.API_ECR_REPOSITORY }}:latest
          cache-from: type=registry,ref=${{ steps.login-ecr.outputs.registry }}/${{ secrets.API_ECR_REPOSITORY }}:latest
          cache-to: type=inline

      # Deploy to ECS
      - name: Deploy to ECS
        env:
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          AWS_REGION: ${{ secrets.AWS_REGION }}
        run: |
          aws ecs update-service \
            --cluster XXXX \
            --service XXX \
            --force-new-deployment

      # Cleanup ECR login token
      - name: Logout from Amazon ECR
        if: always()
        run: docker logout ${{ steps.login-ecr.outputs.registry }}
Solved

1 Replies

10 months ago

Hello,

Correct, You cannot do Docker-In-Docker on Railway at this time.

Best,
Brody


Status changed to Awaiting User Response Railway 10 months ago


Status changed to Solved brody 10 months ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...