title: Deploy Vue + Go as single binary to Heroku
body: <p>I have merged my seperate frontend and backend repo to a single one. My gitlab-ci pipeline worked perfectly for the seperate projects but I can not get it to work as a single project.</p>
  <p>The pipeline for the single backend project:</p>
  <pre><code>...
  
  staging:
    image: ruby
    stage: deployment
    script:
      - apt-get update -qy
      - apt-get install -y ruby-dev
      - gem install dpl
      - dpl --provider=heroku --app=$HEROKU_APP_STAGING --api-key=$HEROKU_API_KEY
    environment:
      name: Staging
    only:
      - staging
  </code></pre>
  <p>The pipeline for the single frontend project:</p>
  <pre><code>...
  
  build site:
    image: node
    stage: build
    script:
      - yarn install --progress=false
      - yarn build
    artifacts:
      expire_in: 1 week
      paths:
        - dist
  
  staging:
    image: ruby
    stage: deployment
    script:
      - apt-get update -qy
      - apt-get install -y ruby-dev
      - gem install dpl
      - dpl --provider=heroku --app=$$HEROKU_APP_STAGING --api-key=$HEROKU_API_KEY
    environment:
      name: Staging
    only:
      - staging
  </code></pre>
  <p>I then decided to merge both projects together. The project structure looks like this:</p>
  <pre><code>Project
   |
   +-- backend
   |    
   +-- frontend
   |  |  
   |  +-- dist
   |  |  
   |  +-- package.json
   |    
   +-- Procfile
   |    
   +-- .gitlab-ci.yml
  </code></pre>
  <p>The Go backend serves the Vue frontend on a static route. So I need to build the frontend before the backend and then reference the generated dist directory in my backend build.</p>
  <p>This is the Procfile:</p>
  <pre><code>web: backend
  </code></pre>
  <p>This is my current state of my gitlab-ci.yml:</p>
  <pre><code>...
  
  build frontend:
    image: node
    stage: frontend
    script:
      - cd frontend
      - yarn install --progress=false
      - yarn build
    artifacts:
      name: &quot;frontend&quot;
      expire_in: 1 week
      paths:
        - frontend/dist
  
  build backend:
    image: golang
    stage: backend
    script:
      - cd backend
      - go build
      - ls -la
    artifacts:
      name: &quot;backend&quot;
      expire_in: 1 week
      paths:
        - backend/backend
  
  staging:
    image: ruby
    stage: deployment
    script:
      - apt-get update -qy
      - apt-get install -y ruby-dev
      - gem install dpl
      - dpl  --skip_cleanup --provider=heroku --app=$HEROKU_APP_STAGING --api-key=$HEROKU_API_KEY
    environment:
      name: Staging
    only:
      - staging
  </code></pre>
  <p>This version of the pipeline fails on the deployment with following error:</p>
  <pre><code>-----&gt; App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/go.tgz
         More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
   !     Push failed
  deploy failed
  </code></pre>
  <p>There is no further information to check what exactly has been uploaded. To my understanding it should only be the binary which should not fail.</p>
  <p>What am I doing wrong or what are my missunderstandings?</p>
  <p>EDIT:
  Updated staging part:</p>
  <pre><code>staging:
    image: ruby
    stage: deployment
    script:
      - ./detect backend
      - cd backend
      - apt-get update -qy
      - apt-get install -y ruby-dev
      - gem install dpl
      - ls -la ../frontend/dist
      - ls -la
      - dpl --skip_cleanup --provider=heroku --app=$HEROKU_APP_STAGING --api-key=$HEROKU_API_KEY
      - ls -la
  </code></pre>
  <p>Returns:</p>
  <pre><code>$ ./detect backend
  Go
  
  $ ls -la
  total 30896
  drwxrwxrwx 5 root root     4096 Sep 21 11:39 .
  drwxrwxrwx 5 root root     4096 Sep 21 11:03 ..
  drwxrwxrwx 2 root root     4096 Sep 18 15:03 controllers
  -rw-rw-rw- 1 root root     1306 Sep 21 10:11 go.mod
  -rw-rw-rw- 1 root root    56556 Sep 21 10:11 go.sum
  -rw-rw-rw- 1 root root      251 Sep 18 13:14 main.go
  -rwxr-xr-x 1 root root 31527936 Sep 21 11:38 backend
  drwxrwxrwx 2 root root     4096 Sep 18 13:14 middleware
  drwxrwxrwx 2 root root     4096 Sep 18 13:14 model
  
  ...
         Detected the following main packages to install:
              backend
         
  -----&gt; Running: go install -v -tags heroku backend 
  ...
  
  github.com/jackc/pgx/v4
  github.com/jackc/pgx/v4/stdlib
   !     Push rejected, failed to compile Go app.
   !     Push failed
  deploy failed
  </code></pre>