dokku/github-action

Dokku action doesn't pick up the built dist folder from github action.

Closed this issue · 3 comments

Description of problem

How reproducible

Steps to Reproduce

  1. Build a project(node app for example) in github action
  2. Try to copy the generated dist folder from you Dockerfile

Actual Results

Getting this error:

remote: COPY failed: stat /var/lib/docker/tmp/docker-builder573270465/packages/api/dist: no such file or directory        

Expected Results

For the dokku action to pick up the built dist folder from github action.

Additional information

This is my github action:

name: Deploy
on:
  push:
    branches:
      - master

jobs:
  build-api:
    name: Deploy API(Prod)
    runs-on: ubuntu-latest
    env:
      ACTIONS_ALLOW_UNSECURE_COMMANDS: true
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

      - name: Run deploy script
        run: |
          source ./envSetter
          echo "::set-env name=BOTH_ENV::$BOTH"
          echo "::set-env name=API_ENV::$API"
          echo "::set-env name=WEB_ENV::$WEB"
        env:
          BEFORE: ${{ github.event.before }}
          SHA: ${{ github.sha }}

      - name: Remove irrelevant package.json's
        if: env.API_ENV == 'true' || env.BOTH_ENV == 'true'
        run: rm packages/web/package.json

      - name: Get yarn cache directory path
        id: yarn-cache-dir-path
        if: env.API_ENV == 'true' || env.BOTH_ENV == 'true'
        run: echo "::set-output name=dir::$(yarn cache dir)"

      - uses: actions/cache@v2
        id: yarn-cache
        if: env.API_ENV == 'true' || env.BOTH_ENV == 'true'
        with:
          path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
          key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
          restore-keys: |
            ${{ runner.os }}-yarn-
      - name: Yarn install server
        if: env.API_ENV == 'true' || env.BOTH_ENV == 'true'
        run: yarn install

      - name: Build server
        if: env.API_ENV == 'true' || env.BOTH_ENV == 'true'
        run: yarn build:api

      - name: Push to dokku
        uses: dokku/github-action@master
        with:
          git_remote_url: ${{ secrets.SSH_URL_API }}
          ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}

This is my Dockerfile:

FROM node

WORKDIR /tour

COPY ./package.json .
COPY ./yarn.lock .
COPY ./packages/common/package.json ./packages/common/
COPY ./packages/api/package.json ./packages/api/
COPY ./packages/api/tsconfig.json ./packages/api/
COPY ./packages/api/prisma ./packages/api/prisma/

RUN yarn install --production --unsafe-perm

COPY ./packages/api/dist ./packages/api/dist/
COPY ./packages/common/dist ./packages/common/dist/

WORKDIR ./packages/api

ENV NODE_ENV production

EXPOSE 4000

CMD ["node", "dist/src/main"]

Before i used dokku i used heroku with this github action: jctaveras/heroku-deploy@v2.0.0, which picked up the built dist folder properly.

From my understanding this action (as well as dokku itself) only care about what's actually comitted to the repository. Your dist directory is not and hence will not end up on the dokku instance where the actual docker image is build.

What @matthiasrohmer said. The other action you linked to built the dockerfile, pushed that image to the heroku registry, and then deployed it.

We can probably support a similar workflow now that git:from-image exists, but do not at this time.

Thank you both for you answer, should i keep this open?