馃悰  [Bug] prod:migrate up fails on prodution
Created by: ulfgebhardt
馃悰  Bugreport
The backend yarn prod:migrate up fails on production on our wir.social cluster.
Steps to reproduce the behavior
Given is this job
kind: Job
apiVersion: batch/v1
metadata:
  name: job-{{ .Release.Name }}-db-migrate
  labels:
    app.kubernetes.io/name:	"{{ .Chart.Name }}"
    app.kubernetes.io/instance:	"{{ .Release.Name }}"
    app.kubernetes.io/version: "{{ .Chart.AppVersion }}"
    app.kubernetes.io/component: "job-db-migrate"
    app.kubernetes.io/part-of:	"{{ .Chart.Name }}"
    app.kubernetes.io/managed-by: "{{ .Release.Service }}"
    helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
  annotations:
    "helm.sh/hook": post-install, post-upgrade
    "helm.sh/hook-delete-policy": hook-succeeded, hook-failed
    "helm.sh/hook-weight": "5"
spec:
  template:
    spec:
      restartPolicy: Never
      containers:
        - name: job-{{ .Release.Name }}-db-migrations
          image: "{{ .Values.BACKEND.DOCKER_IMAGE_REPO }}:{{ .Chart.AppVersion }}"
          command: ["/bin/sh", "-c", "yarn prod:migrate up"]
          envFrom:
          - configMapRef:
              name: configmap-{{ .Release.Name }}-backend
          - secretRef:
              name: secret-{{ .Release.Name }}-backend
It runs the command /bin/sh -c yarn prod:migrate up on the backend container, which is build on the production stage
##############################################################################
  # JOB: DOCKER BUILD PRODUCTION BACKEND #######################################
  ##############################################################################
  build_production_backend:
    name: Docker Build Production - Backend
    runs-on: ubuntu-latest
    needs: [prepare]
    steps:
      ##########################################################################
      # CHECKOUT CODE ##########################################################
      ##########################################################################
      - name: Checkout code
        uses: actions/checkout@v2
      ##########################################################################
      # SET ENVS ###############################################################
      ##########################################################################
      - name: ENV - VERSION
        run: echo "VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV
      - name: ENV - BUILD_DATE
        run: echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
      - name: ENV - BUILD_VERSION
        run: echo "BUILD_VERSION=${VERSION}.${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV
      - name: ENV - BUILD_COMMIT
        run: echo "BUILD_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV
      ##########################################################################
      # BUILD BACKEND DOCKER IMAGE (production) ################################
      ##########################################################################
      - name: backend | Build `production` image
        run: |
          docker build --target production -t "ocelotsocialnetwork/backend:latest" -t "ocelotsocialnetwork/backend:${VERSION}" -t "ocelotsocialnetwork/backend:${BUILD_VERSION}" backend/
          docker save "ocelotsocialnetwork/backend" > /tmp/backend.tar
      - name: Upload Artifact
        uses: actions/upload-artifact@v2
        with:
          name: docker-backend-production
          path: /tmp/backend.tar
It builds the docker with docker build --target production backend/
Which will result in an error when executed on the cluster:
yarn run v1.22.5
$ migrate --migrations-dir ./dist/db/migrations --store ./dist/db/migrate/store.js up
WARN: No `.env` file found in `/app` (docker) or `/backend` (no docker)
No migrations found in database. If it's the first time you run migrations, then this is normal.
  error : Error: ENOENT: no such file or directory, scandir '/app/dist/db/migrations'
[Error: ENOENT: no such file or directory, scandir '/app/dist/db/migrations'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'scandir',
  path: '/app/dist/db/migrations'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Expected behavior
Successful termination of the yarn prod:migrate up command in production

