include:
  - project: gitlab-ci/kubernetes-base
    ref: v5
    file: panter-kubernetes-base.yml

app-build:
  extends: .app-build
  artifacts:
    paths:
      - $CI_PROJECT_DIR/dist
      - $CI_PROJECT_DIR/.next

.ensureDocker: &ensureDocker |
  function ensureDockerfile() {
    # this is for meteor
      
    if [ ! -f Dockerfile ]; then
      echo "Creating Dockerfile"
      
      cat > Dockerfile <<EOF
  FROM mhart/alpine-node:10 AS builder
  ADD  . /app
  WORKDIR /app
  RUN yarn --production

  FROM mhart/alpine-node:base-10
  WORKDIR /app
  COPY --from=builder /app .
  EXPOSE 8080
    fi

  }

docker-build:
  extends: .docker-build
  before_script:
    - *ensureDocker
    - ensureDockerfile
