-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·41 lines (34 loc) · 821 Bytes
/
deploy.sh
File metadata and controls
executable file
·41 lines (34 loc) · 821 Bytes
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
37
38
39
40
41
#!/bin/sh
SUPPORTED_ENVS="dev stage prod"
MIGRATION_FLAG=false
# Parse command line arguments
while getopts ":m" opt; do
case ${opt} in
m)
MIGRATION_FLAG=true
;;
\?)
echo "Invalid option: $OPTARG" 1>&2
exit 1
;;
esac
done
shift $((OPTIND - 1))
# Check environment argument
if [ "$#" -ne 1 ]; then
echo "Usage: $0 [-m] <env>"
echo "Supported environments: $SUPPORTED_ENVS"
exit 1
fi
ENV=$1
if ! echo "$SUPPORTED_ENVS" | grep -wq "$ENV"; then
echo "Error: Unsupported environment '$ENV'"
echo "Supported environments: $SUPPORTED_ENVS"
exit 1
fi
# Run docker compose
docker compose -f .docker/${ENV}-docker-compose.yml --env-file=.envs/.${ENV} up -d --build
# If migration flag is true, run test.sh
if [ "$MIGRATION_FLAG" = true ]; then
sh .scripts/auto-migration.sh $ENV
fi