-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_and_deploy.sh
36 lines (24 loc) · 1.03 KB
/
build_and_deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
set -e # Abort script if any command fails
export AWS_REGION="$bamboo_AWS_REGION"
export AWS_ACCESS_KEY_ID="$bamboo_AWS_SVC_PROD_ACCESS_KEY"
export AWS_SECRET_ACCESS_KEY="$bamboo_AWS_SVC_PROD_SECRET_ACCESS_KEY"
# Check if AWS credentials are valid
aws sts get-caller-identity >/dev/null
# Build the Docker image
docker build . -t lightdash
# Create a unique container ID
CID=$(docker create lightdash)
# Copy the build artifacts from the Docker container to the local "dist" directory
docker cp "${CID}":app/build ./dist
# Clean up the Docker container
docker rm "${CID}"
# Validate AWS S3 connectivity
aws s3 ls >/dev/null
# Move the contents of the "lightdash" directory in the S3 bucket to a backup directory
# aws s3 mv s3://ghrc-web-services/lightdash s3://ghrc-web-services-backup/lightdash --recursive
# # Sync the local "dist" directory to the "lightdash" directory in the S3 bucket
# aws s3 sync ./dist s3://ghrc-web-services/lightdash
# Cleanup the "dist" directory
rm -rf ./dist
echo "Deployment completed successfully."