Skip to content
Merged
57 changes: 46 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: CI
# See https://help.github.com/en/actions/reference/events-that-trigger-workflows
on: [push, pull_request]
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
clippy_check:
name: Run clippy check
Expand All @@ -14,16 +20,11 @@ jobs:
toolchain: nightly
components: clippy
override: true

- name: Install gui library packages
run: sudo apt-get update && sudo apt-get install -y libwebkit2gtk-4.0-dev build-essential libayatana-appindicator3-dev librsvg2-dev libgtk-3-dev libsoup2.4-dev libjavascriptcoregtk-4.0-dev

- name: Install trunk
uses: actions-rs/cargo@v1
with:
command: install
args: --locked --debug trunk

- name: Install webassembly rust target
run: rustup target add wasm32-unknown-unknown

Expand All @@ -45,7 +46,6 @@ jobs:
run: cargo build
working-directory: .


rustfmt:
name: Check style
runs-on: ubuntu-latest
Expand All @@ -66,7 +66,42 @@ jobs:
with:
command: fmt
args: --all -- --check

image:
name: Build docker image
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install docker
uses: docker/setup-buildx-action@v2
- name: Get image tag
id: vars
run: |
rel="$( echo "${GITHUB_REF#refs/*/}" )"
if grep -qE '^\d+\.\d+\.\d+' <<< "$rel" ; then
echo "Using $rel as image tag"
echo "IMAGE_TAG=$rel" >> $GITHUB_ENV
elif [ "$rel" = "main" ]; then
echo "Using dev as image tag"
echo "IMAGE_TAG=dev" >> $GITHUB_ENV
else
rel=$(echo "$GITHUB_SHA" | cut -c1-7)
echo "Using $rel as image tag"
echo "IMAGE_TAG=$rel" >> $GITHUB_ENV
fi
- name: 'Auth to GitHub Container Registry'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- name: Build and push image
env:
IMAGE_TAG: ${{ env.IMAGE_TAG }}
run: >-
docker buildx build --platform linux/arm64/v8,linux/amd64
--push -t "ghcr.io/joshrmcdaniel/privaxy:${IMAGE_TAG}" .
ci:
name: Build
runs-on: ${{ matrix.os }}
Expand All @@ -78,7 +113,7 @@ jobs:
rust: stable
target: x86_64-unknown-linux-gnu
- build: linux
os: ubuntu-latest
os: ubuntu-24.04-arm
rust: stable
target: aarch64-unknown-linux-gnu
steps:
Expand Down Expand Up @@ -128,11 +163,11 @@ jobs:
args: --release --target ${{ matrix.target }} --bin privaxy --target-dir target
- name: Build deb
run: cargo install cargo-deb && cargo deb -p privaxy --target ${{ matrix.target }} -o target/${{ matrix.target }}/release
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: privaxy-deb-${{ matrix.target }}
path: target/${{ matrix.target }}/release/privaxy_*.deb
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: privaxy-${{ matrix.target }}
path: |
Expand Down
44 changes: 44 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# syntax=docker/dockerfile:1

ARG PRIVAXY_BASE_PATH="/conf"

FROM rust:1 AS builder
WORKDIR /app

RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash \
& rustup target add wasm32-unknown-unknown \
&& cargo binstall trunk
RUN apt-get update && apt-get install -qy \
pkg-config \
build-essential \
cmake \
clang \
libssl-dev \
git
RUN curl -fsSL https://deb.nodesource.com/setup_23.x -o nodesource_setup.sh \
&& bash nodesource_setup.sh \
&& apt-get install -qy nodejs

COPY . .

RUN cd web_frontend \
&& npm i \
&& trunk build --release \
&& cd .. && cargo build --release

FROM gcr.io/distroless/cc-debian12:nonroot

COPY --from=builder /app/target/release/privaxy /app/privaxy

ARG PRIVAXY_BASE_PATH="/conf"
ENV PRIVAXY_BASE_PATH="${PRIVAXY_BASE_PATH}"
# todo: add support for reading proxy vars
ARG PRIVAXY_PROXY_PORT=8100
ARG PRIVAXY_WEB_PORT=8200

VOLUME [ "${PRIVAXY_BASE_PATH}" ]


EXPOSE ${PRIVAXY_PROXY_PORT} ${PRIVAXY_WEB_PORT}
WORKDIR /app
ENTRYPOINT ["/app/privaxy"]
2 changes: 1 addition & 1 deletion privaxy/src/resources/error.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h1 class="text-4xl font-extrabold text-gray-900 tracking-tight sm:text-5xl">Bad
</p>
<p class="mt-1 text-base text-gray-500">
Reason:
<div class="font-mono bg-gray-100 rounded-md">#{request_error_reson}#</div>
<div class="font-mono bg-gray-100 rounded-md">#{request_error_reason}#</div>
</p>
</div>
</div>
Expand Down
5 changes: 1 addition & 4 deletions privaxy/src/server/configuration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,9 @@ impl Configuration {
}

pub(crate) fn get_config_file() -> PathBuf {
get_base_directory()
.unwrap()
.join(CONFIGURATION_FILE_NAME)
get_base_directory().unwrap().join(CONFIGURATION_FILE_NAME)
}


fn get_base_directory() -> ConfigurationResult<PathBuf> {
let base_directory: PathBuf = match env::var("PRIVAXY_BASE_PATH") {
Ok(val) => PathBuf::from(&val),
Expand Down
2 changes: 1 addition & 1 deletion privaxy/src/server/proxy/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pub(crate) async fn serve(
fn get_informative_error_response(reason: &str) -> Response<Body> {
let mut response_body = String::from(include_str!("../../resources/head.html"));
response_body +=
&include_str!("../../resources/error.html").replace("#{request_error_reson}#", reason);
&include_str!("../../resources/error.html").replace("#{request_error_reason}#", reason);

let mut response = Response::new(Body::from(response_body));
*response.status_mut() = http::StatusCode::BAD_GATEWAY;
Expand Down
Loading