forked from canonical/aproxy
-
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.
- Loading branch information
Showing
5 changed files
with
162 additions
and
39 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,53 @@ | ||
name: Build RPM | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
tests: | ||
uses: ./.github/workflows/tests.yaml | ||
|
||
integration-tests: | ||
uses: ./.github/workflows/integration-tests.yaml | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
arch: [amd64, arm64] | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Build Dependencies | ||
run: | | ||
sudo apt update | ||
sudo apt install -y rpm golang-go | ||
- name: Build RPM - ${{ matrix.arch }} | ||
run: | | ||
# Get the release name | ||
release_name=$(echo "${GITHUB_REF}" | awk -F'/' '{print $NF}') | ||
# Extract the version from the release name | ||
version=$(echo "${release_name}" | grep -oE "[0-9]+\.[0-9]+\.[0-9]+") | ||
make build ARCH=${{ matrix.arch }} VERSION=${version} | ||
make rpm ARCH=${{ matrix.arch }} VERSION=${version} | ||
- name: Upload RPMs to Release | ||
uses: softprops/action-gh-release@v2 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
files: | | ||
rpmbuild/RPMS/**/*.rpm | ||
out/* | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Job fail | ||
continue-on-error: true | ||
run: | | ||
make clean |
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,53 @@ | ||
# Makefile for building aproxy | ||
|
||
# Go compiler | ||
GO := go | ||
|
||
# Output directory | ||
OUT_DIR := out | ||
|
||
# Binary name | ||
BINARY_NAME := aproxy | ||
|
||
LOCAL_ARCH := $(shell go env GOARCH) | ||
|
||
# Flags for the Go build command | ||
GO_BUILD_FLAGS := -v | ||
|
||
# Default target | ||
.DEFAULT_GOAL := help | ||
|
||
.PHONY: help | ||
help: ## Display this help message | ||
@echo "Usage: make [target]" | ||
@echo "Available targets:" | ||
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9_-]+:.*?## / {printf " %-15s %s\n", $$1, $$2}' $(MAKEFILE_LIST) | ||
|
||
.PHONY: build | ||
build: ## Build the Go binary for the specified architecture (e.g., make build ARCH=amd64) | ||
@if [ -z "$(ARCH)" ]; then \ | ||
echo "ARCH is not set. Using local architecture: $(LOCAL_ARCH)"; \ | ||
GOARCH=$(LOCAL_ARCH) $(GO) build $(GO_BUILD_FLAGS) -o $(OUT_DIR)/$(BINARY_NAME).$(LOCAL_ARCH); \ | ||
else \ | ||
echo "Using specified architecture: $(ARCH)"; \ | ||
GOARCH=$(ARCH) $(GO) build $(GO_BUILD_FLAGS) -o $(OUT_DIR)/$(BINARY_NAME).$(ARCH); \ | ||
fi | ||
|
||
.PHONY: rpm | ||
rpm: ## Build the RPM package for the specified architecture (e.g., make rpm ARCH=amd64) | ||
@if [ -z "$(ARCH)" ]; then \ | ||
echo "ARCH is not set. Using local architecture: $(LOCAL_ARCH)"; \ | ||
rpmbuild -bb --define "_topdir $(PWD)/rpmbuild" --define "ARCH $(LOCAL_ARCH)" --define "VERSION $(VERSION)" --target $(LOCAL_ARCH) aproxy.spec; \ | ||
else \ | ||
echo "Using specified architecture: $(ARCH)"; \ | ||
rpmbuild -bb --define "_topdir $(PWD)/rpmbuild" --define "ARCH $(ARCH)" --define "VERSION $(VERSION)" --target $(ARCH) aproxy.spec; \ | ||
fi | ||
|
||
|
||
.PHONY: clean | ||
clean: ## Clean the build artifacts | ||
rm -rf $(OUT_DIR) | ||
rm -rf rpmbuild | ||
|
||
.PHONY: all | ||
all: clean build rpm ## Build all binaries |
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,12 @@ | ||
[Unit] | ||
Description=Aproxy Service | ||
After=network.target | ||
|
||
[Service] | ||
Type=simple | ||
EnvironmentFile=/etc/aproxy/config.env | ||
ExecStart=/usr/bin/aproxy -proxy ${PROXY_URL} | ||
Restart=always | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
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,44 @@ | ||
# RPM spec file for aproxy | ||
|
||
%define name aproxy | ||
%define version ${VERSION} | ||
%define release 1 | ||
%define _arch %{ARCH} | ||
|
||
Name: aproxy | ||
Release: 1%{?dist} | ||
Version: %{VERSION} | ||
Summary: Transparent proxy for HTTP and HTTPS/TLS connections | ||
License: ASL 2.0 | ||
|
||
%description | ||
Aproxy is a transparent proxy for HTTP and HTTPS/TLS connections. By pre-reading the Host header in HTTP requests and the SNI in TLS client hellos, it forwards HTTP proxy requests with the hostname, therefore, complies with HTTP proxies requiring destination hostname for auditing or access control. | ||
|
||
%install | ||
# Create destination directory for the binary | ||
install -d %{buildroot}/usr/bin | ||
# Copy the built binary to the destination directory | ||
install -m 755 %{_topdir}/../out/aproxy.%{ARCH} %{buildroot}/usr/bin/aproxy | ||
# Copy the systemd unit file to the destination directory | ||
install -d %{buildroot}/usr/lib/systemd/system/ | ||
install -m 644 %{_topdir}/../aproxy.service %{buildroot}/usr/lib/systemd/system/ | ||
# Create the config.env file | ||
install -d %{buildroot}/etc/aproxy | ||
echo "PROXY_URL=127.0.0.1:3128" > %{buildroot}/etc/aproxy/config.env | ||
|
||
%files | ||
# Installed binary | ||
/usr/bin/aproxy | ||
# Systemd unit file | ||
/usr/lib/systemd/system/aproxy.service | ||
# Config file | ||
/etc/aproxy/* | ||
|
||
%post | ||
%systemd_post aproxy.service | ||
|
||
%preun | ||
%systemd_preun aproxy.service | ||
|
||
%postun | ||
%systemd_postun_with_restart aproxy.service |