-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create multi-yml actions config read and OS packages
- Loading branch information
Showing
17 changed files
with
414 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ jobs: | |
|
||
- name: Run Linters | ||
run: | | ||
make install-linters | ||
make install-deps | ||
echo | ||
make lint | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,9 @@ PACKAGES:=$(shell go list ./... | grep -v /vendor/) | |
BUILT_ON := $(shell date -u) | ||
COMMIT_HASH:=$(shell git log -n 1 --pretty=format:"%H") | ||
GO_LINUX := GOOS=linux GOARCH=amd64 | ||
LDFLAGS := '-s -w -X "main.builtOn=$(BUILT_ON)" -X "main.commitHash=$(COMMIT_HASH)"' | ||
GO_ARM := GOOS=linux GOARCH=arm64 | ||
VERSION := 1.0.0 | ||
LDFLAGS := '-s -w -X "main.builtOn=$(BUILT_ON)" -X "main.commitHash=$(COMMIT_HASH)" -X "main.version=$(VERSION)"' | ||
|
||
|
||
.PHONY: test | ||
|
@@ -17,9 +19,19 @@ build: | |
linux: | ||
CGO_ENABLED=0 $(GO_LINUX) go build -a -installsuffix cgo -o $(MAIN_PACKAGE) -ldflags $(LDFLAGS) . | ||
|
||
arm64: | ||
CGO_ENABLED=0 $(GO_ARM) go build -a -installsuffix cgo -o $(MAIN_PACKAGE) -ldflags $(LDFLAGS) . | ||
|
||
clean: | ||
find . -name *_gen.go -type f -delete | ||
rm -f ./$(MAIN_PACKAGE) | ||
rm -f ./localhost.* | ||
rm -f ./*.deb | ||
rm -f ./*.rpm | ||
|
||
cleanall: clean | ||
docker rm -f pal || true | ||
rm -rf ./pal.db | ||
|
||
fmt: | ||
go fmt ./... | ||
|
@@ -28,30 +40,44 @@ lint: fmt | |
$(GOPATH)/bin/staticcheck $(PACKAGES) | ||
$(GOPATH)/bin/golangci-lint run | ||
$(GOPATH)/bin/gosec -quiet -no-fail ./... | ||
if command -v shellcheck; then find . -name "*.sh" -type f -exec shellcheck {} \;; fi | ||
|
||
run: | ||
./pal -c ./pal.yml -a ./test/pal-actions.yml | ||
./pal -c ./pal.yml -d ./test | ||
|
||
test: | ||
./test/test.sh | ||
|
||
install-linters: | ||
install-deps: | ||
go install honnef.co/go/tools/cmd/[email protected] | ||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.61.0 | ||
curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b $(GOPATH)/bin v2.21.4 | ||
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest | ||
|
||
update-deps: | ||
go get -u ./... | ||
go mod tidy | ||
|
||
certs: | ||
openssl req -x509 -newkey rsa:4096 -nodes -keyout localhost.key -out localhost.pem -days 365 -sha256 -subj '/CN=localhost' -addext 'subjectAltName=IP:127.0.0.1' | ||
openssl req -x509 -newkey rsa:4096 -nodes -keyout localhost.key -out localhost.pem -days 365 -sha256 -subj '/CN=localhost' -addext "subjectAltName=IP:127.0.0.1,DNS:localhost" | ||
|
||
docker: | ||
sudo docker build -t pal:latest . | ||
sudo docker rm -f pal || true | ||
mkdir -p ./pal.db | ||
sudo docker run -d --name=pal -p 8443:8443 -e HTTP_LISTEN='0.0.0.0:8443' \ | ||
-v $(PWD)/upload:/pal/upload:rw -v $(PWD)/pal.db:/pal/pal.db:rw \ | ||
sudo docker run -d --name=pal -p 8443:8443 -e HTTP_UI_BASIC_AUTH='admin p@LLy' \ | ||
-e HTTP_AUTH_HEADER='X-Pal-Auth PaLLy!@#890-' -e HTTP_SESSION_SECRET='P@llY^S3$$h' -e DB_ENCRYPT_KEY='8c755319-fd2a-4a89-b0d9-ae7b8d26' \ | ||
--health-cmd 'curl -sfk https://127.0.0.1:8443/v1/pal/health || exit 1' --restart=unless-stopped pal:latest | ||
|
||
pkg: linux | ||
VERSION=$(VERSION) ARCH=amd64 nfpm pkg --packager deb --target ./ | ||
VERSION=$(VERSION) ARCH=amd64 nfpm pkg --packager rpm --target ./ | ||
$(MAKE) arm64 | ||
VERSION=$(VERSION) ARCH=arm64 nfpm pkg --packager deb --target ./ | ||
VERSION=$(VERSION) ARCH=arm64 nfpm pkg --packager rpm --target ./ | ||
|
||
vagrant: pkg | ||
vagrant destroy -f || true | ||
vagrant up | ||
sleep 10 | ||
$(MAKE) test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
Vagrant.configure(2) do |config| | ||
config.vm.box = "debian/bookworm64" | ||
config.vm.hostname = "debian12" | ||
config.vm.provider "virtualbox" do |v| | ||
v.name = "debian12" | ||
v.memory = 2048 | ||
v.cpus = 1 | ||
v.customize ["modifyvm", :id, "--natdnsproxy1", "on"] | ||
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] | ||
v.customize ["modifyvm", :id, "--uartmode1", "file", File::NULL] | ||
end | ||
config.vm.network "forwarded_port", guest: 8443, host: 8443 | ||
config.vm.synced_folder ".", "/vagrant", SharedFoldersEnableSymlinksCreate: true | ||
config.vm.provision "shell", inline: <<-SHELL | ||
# Setup Base Packages | ||
ACCEPT_EULA=Y DEBIAN_FRONTEND=noninteractive apt-get update && \ | ||
apt-get upgrade -y && \ | ||
apt-get dist-upgrade -y && \ | ||
apt-get install -y --no-install-recommends \ | ||
curl \ | ||
ca-certificates \ | ||
jq && \ | ||
apt-get clean | ||
# Setup pal | ||
dpkg -i /vagrant/pal*amd64.deb | ||
# Create Self-Signed Certs | ||
cd /pal | ||
openssl req -x509 -newkey rsa:4096 -nodes -keyout /pal/localhost.key -out /pal/localhost.pem -days 365 -sha256 -subj '/CN=localhost' -addext "subjectAltName=IP:127.0.0.1,DNS:localhost" | ||
chown -Rf pal:pal /pal | ||
# Copy Insecure Test Configs | ||
cp -f /vagrant/pal.yml /pal/ | ||
cp -f /vagrant/test/*.yml /pal/actions/ | ||
# Configure Paths for /pal In pal.yml | ||
sed -i "s|listen:.*|listen: 0.0.0.0:8443|" /pal/pal.yml | ||
sed -i "s| key:.*| key: /pal/localhost.key|" /pal/pal.yml | ||
sed -i "s|cert:.*|cert: /pal/localhost.pem|" /pal/pal.yml | ||
sed -i "s|upload_dir:.*|upload_dir: /pal/upload|" /pal/pal.yml | ||
sed -i "s|path:.*|path: /pal/pal.db|" /pal/pal.yml | ||
# Run pal Systemd Service | ||
systemctl daemon-reload | ||
systemctl enable pal | ||
systemctl restart pal | ||
SHELL | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.