version: 0.2
env:
  variables:
    APP_NAME: "magalies-pharma"
    BUCKET_NAME: "heisenberg-frontend-prod-overdrive"
    BUILD_COMMAND: "./node_modules/@angular/cli/bin/ng build --prod --aot" # We'll see if we need this variable still
phases:
  install:
    runtime-versions:
      nodejs: 14
    commands:
      - echo Build environment starting
      - npm install && npm install -g @angular/cli # install dependencies
  pre_build:
    commands:
      - sudo apt-get update
      - sudo apt-get install -y zip ca-certificates python3-pip python3-dev build-essential
      - pip install awscli --upgrade --user
      - export PATH=~/.local/bin:$PATH # Required for awscli. We'll see if this is needed in CodeBuild
      - aws --version  # Print out aws cli version for debugging. Keeping this from GitLab
      - npm install
  build:
    commands:
      - echo build process started 
      - $BUILD_COMMAND # We'll see if we need this or if we can sub in the command directly
  post_build:
    commands:
      - echo build process finished, drop files in S3 bucket
      - cd dist/$APP_NAME
      - ls -la 
      - aws s3 sync . s3://$BUCKET_NAME