add makefile support
This commit is contained in:
		@ -7,11 +7,11 @@ tmp_dir = "tmp"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
[build]
 | 
					[build]
 | 
				
			||||||
# Just plain old shell command. You could use `make` as well.
 | 
					# Just plain old shell command. You could use `make` as well.
 | 
				
			||||||
cmd = "go build -o ./tmp/main ./cmd/web/"
 | 
					cmd = "make"
 | 
				
			||||||
# Binary file yields from `cmd`.
 | 
					# Binary file yields from `cmd`.
 | 
				
			||||||
bin = "tmp main"
 | 
					bin = "dist/gostripe"
 | 
				
			||||||
# Customize binary.
 | 
					# Customize binary.
 | 
				
			||||||
full_bin = "STRIPE_SECRET= STRIPE_KEY= ./tmp/main"
 | 
					full_bin = "STRIPE_SECRET= STRIPE_KEY= ./dist/gostripe"
 | 
				
			||||||
# Watch these filename extensions.
 | 
					# Watch these filename extensions.
 | 
				
			||||||
include_ext = ["go", "tpl", "tmpl", "html", "gohtml"]
 | 
					include_ext = ["go", "tpl", "tmpl", "html", "gohtml"]
 | 
				
			||||||
# Ignore these filename extensions or directories.
 | 
					# Ignore these filename extensions or directories.
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										60
									
								
								Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								Makefile
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,60 @@
 | 
				
			|||||||
 | 
					STRIPE_SECRET=$(shell sed '2q;d' cred.txt)
 | 
				
			||||||
 | 
					STRIPE_KEY=$(shell sed '2q;d' cred.txt)
 | 
				
			||||||
 | 
					GOSTRIPE_PORT=4000
 | 
				
			||||||
 | 
					API_PORT=4001
 | 
				
			||||||
 | 
					DSN=root@tcp(localhost:6379)/widgets?parseTime=true&tls=false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## build: builds all binaries
 | 
				
			||||||
 | 
					build: clean build_front build_back
 | 
				
			||||||
 | 
						@printf "All binaries built!\n"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## clean: cleans all binaries and runs go clean
 | 
				
			||||||
 | 
					clean:
 | 
				
			||||||
 | 
						@echo "Cleaning..."
 | 
				
			||||||
 | 
						@- rm -f dist/*
 | 
				
			||||||
 | 
						@go clean
 | 
				
			||||||
 | 
						@echo "Cleaned!"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## build_front: builds the front end
 | 
				
			||||||
 | 
					build_front:
 | 
				
			||||||
 | 
						@echo "Building front end..."
 | 
				
			||||||
 | 
						@go build -o dist/gostripe ./cmd/web
 | 
				
			||||||
 | 
						@echo "Front end built!"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## build_back: builds the back end
 | 
				
			||||||
 | 
					build_back:
 | 
				
			||||||
 | 
						@echo "Building back end..."
 | 
				
			||||||
 | 
						@go build -o dist/gostripe_api ./cmd/api
 | 
				
			||||||
 | 
						@echo "Back end built!"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## start: starts front and back end
 | 
				
			||||||
 | 
					start: start_front start_back
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					## start_front: starts the front end
 | 
				
			||||||
 | 
					start_front: build_front
 | 
				
			||||||
 | 
						@echo "Starting the front end..."
 | 
				
			||||||
 | 
						@env STRIPE_KEY=${STRIPE_KEY} STRIPE_SECRET=${STRIPE_SECRET} ./dist/gostripe -port=${GOSTRIPE_PORT} -dsn="${DSN}" &
 | 
				
			||||||
 | 
						@echo "Front end running!"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## start_back: starts the back end
 | 
				
			||||||
 | 
					start_back: build_back
 | 
				
			||||||
 | 
						@echo "Starting the back end..."
 | 
				
			||||||
 | 
						@env STRIPE_KEY=${STRIPE_KEY} STRIPE_SECRET=${STRIPE_SECRET} ./dist/gostripe_api -port=${API_PORT}  -dsn="${DSN}" &
 | 
				
			||||||
 | 
						@echo "Back end running!"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## stop: stops the front and back end
 | 
				
			||||||
 | 
					stop: stop_front stop_back
 | 
				
			||||||
 | 
						@echo "All applications stopped"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## stop_front: stops the front end
 | 
				
			||||||
 | 
					stop_front:
 | 
				
			||||||
 | 
						@echo "Stopping the front end..."
 | 
				
			||||||
 | 
						@-pkill -SIGTERM -f "gostripe -port=${GOSTRIPE_PORT}"
 | 
				
			||||||
 | 
						@echo "Stopped front end"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## stop_back: stops the back end
 | 
				
			||||||
 | 
					stop_back:
 | 
				
			||||||
 | 
						@echo "Stopping the back end..."
 | 
				
			||||||
 | 
						@-pkill -SIGTERM -f "gostripe_api -port=${API_PORT}"
 | 
				
			||||||
 | 
						@echo "Stopped back end"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -64,6 +64,12 @@ func main() {
 | 
				
			|||||||
		"development",
 | 
							"development",
 | 
				
			||||||
		"Application environment {development|production}",
 | 
							"Application environment {development|production}",
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
 | 
						flag.StringVar(
 | 
				
			||||||
 | 
							&cfg.db.dsn,
 | 
				
			||||||
 | 
							"dsn",
 | 
				
			||||||
 | 
							"root@tcp(localhost:6379)/widgets?parseTime=true&tls=false",
 | 
				
			||||||
 | 
							"Application environment {development|production}",
 | 
				
			||||||
 | 
						)
 | 
				
			||||||
	flag.StringVar(&cfg.api, "api", "http://localhost:4001", "URL to api")
 | 
						flag.StringVar(&cfg.api, "api", "http://localhost:4001", "URL to api")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	flag.Parse()
 | 
						flag.Parse()
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user