-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·144 lines (108 loc) · 5.46 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
include Makefile.ansible
volumes:
mkdir -p ./.docker/volumes/go/tls-certificates
mkdir -p ./.docker/volumes/postgresql/data
env-docker-compose-development:
rm -f docker-compose.yml
ln -s ./docker/compose/development/docker-compose.yml docker-compose.yml
cp .development.env .env
env-docker-compose-production:
rm -f docker-compose.yml
ln -s ./docker/compose/production/docker-compose.yml docker-compose.yml
cp .production.env .env
env-up:
docker-compose -f docker-compose.yml --env-file .env up -d
postgres-test-run:
docker exec readytotouch_postgres_db psql -U yaaws_user -d yaaws -c "SELECT VERSION();"
logs:
docker logs readytotouch_go_app
app:
docker exec -it readytotouch_go_app sh
pg:
docker exec -it readytotouch_postgres_db bash
pg-users:
cat ./fixtures/postgres/users.sql | docker exec -i readytotouch_postgres_db psql -d yaaws -U yaaws_user
env-down:
docker-compose -f docker-compose.yml --env-file .env down
env-down-with-clear:
docker-compose -f docker-compose.yml --env-file .env down --remove-orphans -v # --rmi=all
app-build:
docker exec readytotouch_go_app go build -o /bin/yaaws-server ./cmd/main.go
app-start:
docker exec readytotouch_go_app yaaws-server
app-stop:
docker exec readytotouch_go_app pkill yaaws-server || echo "yaaws-server already stopped"
app-restart: app-build app-stop app-start
test:
docker exec readytotouch_go_app go test ./... -v -count=1
bench:
docker exec readytotouch_go_app go test ./... -v -run=$$^ -bench=. -benchmem -benchtime=1000x
# make migrate-pgsql-create NAME=init
migrate-pgsql-create:
goose -dir ./internal/storage/postgres/migrations -table schema_migrations postgres create $(NAME) sql
migrate-pgsql-up:
docker exec readytotouch_postgres_goose_migrations \
goose --dir=/db/migrations --table=schema_migrations \
up
migrate-pgsql-redo:
docker exec readytotouch_postgres_goose_migrations \
goose --dir=/db/migrations --table=schema_migrations \
redo
migrate-pgsql-down:
docker exec readytotouch_postgres_goose_migrations \
goose --dir=/db/migrations --table=schema_migrations \
down-to 20230815012800
migrate-pgsql-reset:
docker exec readytotouch_postgres_goose_migrations \
goose --dir=/db/migrations --table=schema_migrations \
reset
migrate-pgsql-status:
docker exec readytotouch_postgres_goose_migrations \
goose --dir=/db/migrations --table=schema_migrations \
status
generate-template:
# go get -u github.com/valyala/quicktemplate/qtc
qtc -dir=./internal/templates/v1 -skipLineComments
git add .
generate-sqlc:
sqlc generate
esbuild-minify:
npm --prefix=client i
MINIFY=true npm run --prefix=client esbuild
tree -h ./public/assets/js
esbuild:
MINIFY=false npm run --prefix=client esbuild
tree -h ./public/assets/js
# make design DESIGN="~/go/src/github.com/readytotouch/readytotouch.github.io"
design:
$(eval DESIGN := ~/go/src/github.com/readytotouch/readytotouch.github.io)
rm -rf ./public/assets/images ./public/design
mkdir -p ./public/assets/images ./public/design
cp -r $(DESIGN)/public/assets/images/* ./public/assets/images
cp -r $(DESIGN)/public/*.html ./public/design
git add .
# POSTGRES_PASSWORD=$(echo "$RANDOM$RANDOM" | sha256sum | head -c 32; echo;) JWT_SECRET_KEY=$(echo "$RANDOM$RANDOM" | sha256sum | head -c 32; echo;) make generate-production-environment-file
generate-production-environment-file:
touch .production.env
grep -qF 'ENVIRONMENT=' .production.env || echo 'ENVIRONMENT="production"' >> .production.env
# Database
grep -qF 'POSTGRES_USER=' .production.env || echo 'POSTGRES_USER="u8user"' >> .production.env
grep -qF 'POSTGRES_PASSWORD=' .production.env || echo 'POSTGRES_PASSWORD="$(POSTGRES_PASSWORD)"' >> .production.env
grep -qF 'POSTGRES_DB=' .production.env || echo 'POSTGRES_DB="yaaws"' >> .production.env
grep -qF 'POSTGRES_DSN=' .production.env || echo 'POSTGRES_DSN="postgresql://u8user:$(POSTGRES_PASSWORD)@postgres:5432/yaaws?sslmode=disable"' >> .production.env
grep -qF 'HOSTS=' .production.env || echo 'HOSTS="readytotouch.com,dev.readytotouch.com,www.readytotouch.com"' >> .production.env
grep -qF 'JWT_SECRET_KEY=' .production.env || echo 'JWT_SECRET_KEY="$(JWT_SECRET_KEY)"' >> .production.env
grep -qF 'GITHUB_CLIENT_ID=' .production.env || echo 'GITHUB_CLIENT_ID="8dce25b763367e846763"' >> .production.env
grep -qF 'GITHUB_CLIENT_SECRET=' .production.env || echo 'GITHUB_CLIENT_SECRET=""' >> .production.env
grep -qF 'GITHUB_REDIRECT_URL=' .production.env || echo 'GITHUB_REDIRECT_URL="https://readytotouch.com/auth/github/callback"' >> .production.env
grep -qF 'GITLAB_CLIENT_ID=' .production.env || echo 'GITLAB_CLIENT_ID="1f8bc1174d17998654c82400ff7a230c87d4e633327c17c2414f315f62b80d28"' >> .production.env
grep -qF 'GITLAB_CLIENT_SECRET=' .production.env || echo 'GITLAB_CLIENT_SECRET=""' >> .production.env
grep -qF 'GITLAB_REDIRECT_URL=' .production.env || echo 'GITLAB_REDIRECT_URL="https://readytotouch.com/auth/gitlab/callback"' >> .production.env
grep -qF 'BITBUCKET_CLIENT_ID=' .production.env || echo 'BITBUCKET_CLIENT_ID="PY4qXGrqgvCS34DuqT"' >> .production.env
grep -qF 'BITBUCKET_CLIENT_SECRET=' .production.env || echo 'BITBUCKET_CLIENT_SECRET=""' >> .production.env
grep -qF 'BITBUCKET_REDIRECT_URL=' .production.env || echo 'BITBUCKET_REDIRECT_URL="https://readytotouch.com/auth/bitbucket/callback"' >> .production.env
cat .production.env
ssh:
ssh -t root@70.34.247.27 "cd /var/go/readytotouch/; bash --login"
ssh-copy-tls-certificates:
scp -r root@70.34.247.27:/var/go/readytotouch/.docker/volumes/go/tls-certificates ./.docker/volumes/go