| 1 | version: 0.2 |
| 2 | |
| 3 | env: |
| 4 | variables: |
| 5 | REACT_APP_BASE_URL: "http://localhost:5001/" |
| 6 | CLOUDFRONT_ID: "E1VDTBR7TV8GO0" |
| 7 | FRONTEND_BUCKET: "hygo.real-e-state.frontend" |
| 8 | CACHE_BUCKET: "hygo.real-e-state.cache" |
| 9 | ARTIFACT_BUCKET: "hygo.real-e-state.artifacts" |
| 10 | |
| 11 | phases: |
| 12 | install: |
| 13 | commands: |
| 14 | - echo Installing dependencies... |
| 15 | - cd Client && npm i |
| 16 | - cd ../server && npm i |
| 17 | - echo Ensuring artifact bucket |
| 18 | - aws s3api create-bucket --bucket $ARTIFACT_BUCKET --create-bucket-configuration LocationConstraint=us-west-1 |
| 19 | - echo Ensuring cache bucket |
| 20 | - aws s3api create-bucket --bucket $CACHE_BUCKET --create-bucket-configuration LocationConstraint=us-west-1 |
| 21 | - echo Ensuring frontend bucket |
| 22 | - aws s3api create-bucket --bucket $FRONTEND_BUCKET --create-bucket-configuration LocationConstraint=us-west-1 |
| 23 | - aws s3api delete-public-access-block --bucket $FRONTEND_BUCKET |
| 24 | - aws s3api put-bucket-policy --bucket $FRONTEND_BUCKET --policy file://Client/bucket-policy.json |
| 25 | - aws s3 website --bucket $FRONTEND_BUCKET --index index.html --error index.html |
| 26 | |
| 27 | build: |
| 28 | commands: |
| 29 | - cd Client |
| 30 | - echo Running npm run build in the Client folder... |
| 31 | - npm run build |
| 32 | |
| 33 | post_build: |
| 34 | commands: |
| 35 | |
| 36 | - echo Copying build files to S3 bucket... |
| 37 | - aws s3 website |
| 38 | - aws s3 sync ./Client/build/ "s3://$FRONTEND_BUCKET/" --delete |
| 39 | cache: |
| 40 | paths: |
| 41 | - Client/node_modules |
| 42 | - server/node_modules |