debian package
This commit is contained in:
1 parent
cb87af4f3b
commit
166182f3d4
8 files changed
+160
-6
No files matched your search
@@ -1,4 +1,4 @@
|
||||
include .envrc
|
||||
-include .envrc
|
||||
|
||||
## help: print this help message
|
||||
.PHONY: help
|
||||
@@ -14,17 +14,68 @@ current_time = $(shell date -Iseconds)
|
||||
git_description = $(shell git describe --always --dirty)
|
||||
linker_flags = '-s -X main.buildTime=${current_time} -X main.version=${git_description}'
|
||||
|
||||
production_host = 152.53.236.243
|
||||
production_user = root
|
||||
production_src = /srv/party
|
||||
|
||||
## build/api: build for the current OS and cross-compile for linux/amd64
|
||||
.PHONY: build/api
|
||||
build/api:
|
||||
@echo 'Building cmd/api...'
|
||||
go build -ldflags=${linker_flags} -o=./bin/api ./cmd/api
|
||||
GOOS=linux GOARCH=amd64 go build -ldflags=${linker_flags} -o=./bin/linux_amd64/api ./cmd/api
|
||||
@echo 'Building cmd/party...'
|
||||
go build -ldflags=${linker_flags} -o=./bin/party ./cmd/party
|
||||
GOOS=linux GOARCH=amd64 go build -ldflags=${linker_flags} -o=./bin/linux_amd64/party ./cmd/party
|
||||
|
||||
## build/package: assemble .deb — runs on the production server, not locally
|
||||
.PHONY: build/package
|
||||
build/package:
|
||||
@echo 'Building binary...'
|
||||
go build -ldflags=${linker_flags} -o=./bin/party ./cmd/party
|
||||
@echo 'Assembling .deb...'
|
||||
rm -rf /tmp/party-pkg
|
||||
mkdir -p /tmp/party-pkg/DEBIAN
|
||||
mkdir -p /tmp/party-pkg/usr/bin
|
||||
mkdir -p /tmp/party-pkg/usr/share/party
|
||||
mkdir -p /tmp/party-pkg/lib/systemd/system
|
||||
cp ./bin/party /tmp/party-pkg/usr/bin/party
|
||||
cp -r ./web /tmp/party-pkg/usr/share/party/
|
||||
cp -r ./migrations /tmp/party-pkg/usr/share/party/
|
||||
cp ./deploy/party.service /tmp/party-pkg/lib/systemd/system/
|
||||
cp ./deploy/DEBIAN/postinst /tmp/party-pkg/DEBIAN/postinst
|
||||
cp ./deploy/DEBIAN/prerm /tmp/party-pkg/DEBIAN/prerm
|
||||
cp ./deploy/DEBIAN/postrm /tmp/party-pkg/DEBIAN/postrm
|
||||
chmod 755 /tmp/party-pkg/DEBIAN/postinst /tmp/party-pkg/DEBIAN/prerm /tmp/party-pkg/DEBIAN/postrm
|
||||
printf 'Package: party\nVersion: %s\nArchitecture: amd64\nMaintainer: Vicente Ferrari Smith <vicenteferrarismith@gmail.com>\nDescription: Party\n' \
|
||||
'${git_description}' > /tmp/party-pkg/DEBIAN/control
|
||||
dpkg-deb --build --root-owner-group /tmp/party-pkg ./party.deb
|
||||
@echo 'Package ready: ./party.deb'
|
||||
|
||||
## deploy/configure: one-time production server setup
|
||||
.PHONY: deploy/configure
|
||||
deploy/configure:
|
||||
cat deploy/setup.sh | ssh ${production_user}@${production_host} bash
|
||||
|
||||
## deploy/teardown: remove everything from the production server
|
||||
.PHONY: deploy/teardown
|
||||
deploy/teardown: confirm
|
||||
cat deploy/teardown.sh | ssh ${production_user}@${production_host} bash
|
||||
|
||||
## deploy/migrate: run database migrations on production
|
||||
.PHONY: deploy/migrate
|
||||
deploy/migrate: confirm
|
||||
ssh ${production_user}@${production_host} \
|
||||
'set -a; . /etc/party/environment; set +a; migrate -path /usr/share/party/migrations -database $$PARTY_DB_DSN up'
|
||||
|
||||
## deploy: pull latest, build .deb on server, and install it
|
||||
.PHONY: deploy
|
||||
deploy: confirm
|
||||
ssh -t ${production_user}@${production_host} \
|
||||
'cd ${production_src} && git pull origin main && make build/package && dpkg -i ./party.deb'
|
||||
|
||||
## run/api: run the cmd/api application
|
||||
.PHONY: run/api
|
||||
run/api:
|
||||
@echo "Running the API"
|
||||
go run ./cmd/api -db-dsn=${PARTY_DB_DSN}
|
||||
go run ./cmd/party -db-dsn=${PARTY_DB_DSN}
|
||||
|
||||
.PHONY: db/psql
|
||||
db/psql:
|
||||
|
||||
Reference in new issue
Block a user