This repository has been archived by the owner on Nov 1, 2024. It is now read-only.
forked from checkmarble/marble
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
61 lines (51 loc) · 2.57 KB
/
Makefile
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
.PHONY: all front api firebase-emulator
all: front api firebase-emulator
front:
docker build -t xendit-marble-frontend:latest --secret id=SENTRY_AUTH_TOKEN,src=front/mock_sentry_token.txt -f front/Dockerfile front/
api:
docker build -t xendit-marble-backend:latest -f api/Dockerfile api/
firebase-emulator:
docker build -t xendit-firebase-emulator:latest -f firebase-emulator-docker/Dockerfile.firebase_emulator firebase-emulator-docker
clean:
docker rmi xendit-marble-frontend:latest xendit-marble-backend:latest xendit-firebase-emulator:latest
# Run this goal like this
# pg_dump -h <marble-postgres.rds.amazonaws.com> -p 5432 -U postgres -d marble -F d -v -j 4 --no-owner --no-privileges -f <marble_backup.dump>
# make restore-db-to-dev BACKUP_FILE=<marble_backup.dump>
restore-db-to-dev:
docker-compose stop api cron app firebase_auth
docker cp $(BACKUP_FILE) marble-postgres:/tmp/backup
docker exec marble-postgres dropdb -U postgres marble
docker exec marble-postgres createdb -U postgres marble
docker exec marble-postgres pg_restore -U postgres -d marble -j 4 /tmp/backup
docker-compose start api cron app firebase_auth
delete-table-in-dev:
docker exec marble-postgres psql -U postgres -d marble -c "DROP TABLE IF EXISTS \"org-Xendit\".\"$(TABLE_NAME)\""
docker exec marble-postgres psql -U postgres -d marble -c "DELETE FROM \"marble\".\"data_model_tables\" WHERE name='$(TABLE_NAME)'"
delete-table-in-ec2:
ssh marble 'psql -h marble-postgres.cluster-cinsxnyd7pwn.ap-southeast-1.rds.amazonaws.com -U postgres -d marble -c "DROP TABLE IF EXISTS \"org-Xendit\".\"$(TABLE_NAME)\"" && \
psql -h marble-postgres.cluster-cinsxnyd7pwn.ap-southeast-1.rds.amazonaws.com -U postgres -d marble -c "DELETE FROM \"marble\".\"data_model_tables\" WHERE name='"'"'$(TABLE_NAME)'"'"'"'
# Following targets require ~/.ssh/config to be set up
# Create SSH Config inside ~/.ssh/config
# ```
# Host marble
# HostName 10.103.20.57
# User ec2-user
# IdentityFile ~/.ssh/tms-poc.pem
# ```
# Prerequisite: Install git-archive-all
# ```
# brew install git-archive-all
# ```
# Run this goal like this
# make build-image-on-ec2
build-image-on-ec2:
git-archive-all /tmp/xendit-marble.zip
caffeinate -i rsync -avz --progress -e ssh /tmp/xendit-marble.zip marble:/tmp/
ssh marble 'bash -c "\
rm -rf /tmp/xendit-marble && \
cd /tmp && \
unzip xendit-marble.zip && \
cd /tmp/xendit-marble && \
docker build -t xendit-marble-frontend:latest --secret id=SENTRY_AUTH_TOKEN,src=front/mock_sentry_token.txt -f front/Dockerfile front/ && \
docker build -t xendit-marble-backend:latest -f api/Dockerfile api/ \
"'