Visitar URL original
Docker Integration and CI Improvements by federicofantini · Pull Request #91 · leproxy/leproxy · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
895a886
upload base version
invalid-email-address Apr 30, 2025
e6252c5
added .idea to .gitignore
federicofantini May 2, 2025
b741f0d
lightened docker image from 400MB to 70MB
federicofantini May 2, 2025
ee05e2e
fixed branch list names
federicofantini May 2, 2025
067cbb2
Endless 'Waiting for a runner to pick up this job...'
federicofantini May 2, 2025
7e4cc58
added test number
federicofantini May 2, 2025
7417fb4
I'm trying to fix the acceptance tests
federicofantini May 2, 2025
0a4d78a
removed duplicates ipv4 in ipv6 tests
federicofantini May 2, 2025
7596750
currently the service has a problem but the test must not fail
federicofantini May 2, 2025
52cbac2
fixed typo
federicofantini May 2, 2025
0680fb2
added 503 status code to test pass comment
federicofantini May 2, 2025
d9beeea
updated readme file
federicofantini May 2, 2025
2208e95
Merge pull request #1 from federicofantini/test
federicofantini May 2, 2025
77e656c
Merge pull request #2 from federicofantini/develop
federicofantini May 2, 2025
cb9fd9f
added missing healthcheck
federicofantini May 2, 2025
7284dff
fixed healthcheck
federicofantini May 2, 2025
4701c81
fixed again healthcheck
federicofantini May 2, 2025
a09edc2
moved healthcheck to bash script
federicofantini May 2, 2025
d80c3fd
fixed empty tag when pushing docker image
federicofantini May 2, 2025
d4f552b
fixed typo
federicofantini May 2, 2025
2585919
removed platform
federicofantini May 2, 2025
686e48a
specified dockerfile
federicofantini May 2, 2025
4387e70
fixed context (squashed)
federicofantini May 6, 2025
2feccf3
removed unused alias
federicofantini May 6, 2025
162148c
applied check to all containers
federicofantini May 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ name: CI

on:
push:
branches:
- main
- develop
pull_request:

jobs:
PHPUnit:
name: PHPUnit (PHP ${{ matrix.php }})
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
strategy:
matrix:
php:
Expand All @@ -20,7 +23,7 @@ jobs:
- 5.5
- 5.4
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: RELEASE

on:
push:
tags: [ 'v*.*.*' ]


jobs:
healthcheck:
runs-on: ubuntu-latest
services:
docker:
image: docker
options: --privileged

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose

- name: Launch Docker Compose
working-directory: .
run: |
docker-compose up -d
echo "Waiting healthcheck..."
sleep 20
docker-compose ps
for container_id in $(docker-compose ps -q); do
status=$(docker inspect --format='{{json .State.Health.Status}}' "$container_id")
echo "Container $container_id health status: $status"
if [ "$status" != "\"healthy\"" ]; then
echo "ERROR: Container $container_id is not healthy"
exit 1
fi
done

push-image:
needs: healthcheck
runs-on: ubuntu-latest

steps:
- name: Log in to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Checkout code
uses: actions/checkout@v4

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ./
file: ./docker/Dockerfile
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/leproxy:${{ github.ref_name }}
${{ secrets.DOCKERHUB_USERNAME }}/leproxy:latest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/vendor/
/leproxy-*.php
.idea
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ accepting both common HTTP and SOCKS proxy protocols on a single listening port.

## Install

### PHP

LeProxy requires only PHP.
*PHP 7+ is highly recommended*, but it runs on any system that uses PHP 5.4+ or
HHVM.
Expand Down Expand Up @@ -60,6 +62,9 @@ You did it!! Really simple, huh?
If you're interested in the more technical details of this file, you may want
to check out the [development instructions](#development) below.

### Docker
To start the project, just give the command `docker compose up`. Instead, to configure new listening services, just customize the `docker-compose.yml` file following the options supported in the documentation.

## Usage

Once [installed](#install), you can start LeProxy by simply running:
Expand Down
60 changes: 60 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
x-defaults:
service: &service-defaults
network_mode: host
image: leproxy
build:
context: .
dockerfile: docker/Dockerfile
command: sh -c 'php leproxy.php "$${LISTENING}"'
healthcheck:
test: ["CMD", "bash", "/app/docker/healthcheck.sh"]
interval: 10s
timeout: 3s
retries: 5

services:
leproxy-ipv4-unprotected:
<<: *service-defaults
container_name: leproxy-ipv4-unprotected
expose:
- 1080
volumes:
- logs-leproxy-ipv4-unprotected:/var/log
environment:
LISTENING: "0.0.0.0:1080"

leproxy-ipv4-protected:
<<: *service-defaults
container_name: leproxy-ipv4-protected
expose:
- 1081
volumes:
- logs-leproxy-ipv4-protected:/var/log
environment:
LISTENING: "username:password@0.0.0.0:1081"

leproxy-ipv6-unprotected:
<<: *service-defaults
container_name: leproxy-ipv6-unprotected
expose:
- 1082
volumes:
- logs-leproxy-ipv6-unprotected:/var/log
environment:
LISTENING: "[::]:1082"

leproxy-ipv6-protected:
<<: *service-defaults
container_name: leproxy-ipv6-protected
expose:
- 1083
volumes:
- logs-leproxy-ipv6-protected:/var/log
environment:
LISTENING: "username:password@[::]:1083"

volumes:
logs-leproxy-ipv4-unprotected:
logs-leproxy-ipv4-protected:
logs-leproxy-ipv6-unprotected:
logs-leproxy-ipv6-protected:
19 changes: 19 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM php:7.4.33-zts-alpine

# apt dependencies
RUN apk add --no-cache --upgrade bash shadow curl zip unzip git libzip-dev net-tools

# install php extensions provided by docker image
RUN docker-php-ext-install zip sockets

# install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# composer need to run as user
RUN addgroup -S appgroup && adduser -S appuser -G appgroup -s $(which bash)
USER appuser
WORKDIR /app
COPY . /app

# application install
RUN composer install --no-dev --optimize-autoloader && composer clear-cache
11 changes: 11 additions & 0 deletions docker/healthcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

PORT="${LISTENING##*:}"

netstat -an | grep ":$PORT" > /dev/null
if [ $? -ne 0 ]; then
echo "Port $PORT not listening"
exit 1
fi

exit 0
Loading