Skip to content

Commit 873c511

Browse files
authored
feat: Add helm chart for the app (#65)
1 parent 3842562 commit 873c511

11 files changed

Lines changed: 929 additions & 9 deletions

File tree

.github/workflows/release.yml

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,55 @@ jobs:
3232
platforms: linux/amd64,linux/arm64
3333
tags: |
3434
ghcr.io/${{ github.actor }}/3proxy:latest
35-
ghcr.io/${{ github.actor }}/3proxy:${{ steps.slug.outputs.version-semantic }}
35+
ghcr.io/${{ github.actor }}/3proxy:${{ steps.slug.outputs.version }}
3636
ghcr.io/${{ github.actor }}/3proxy:${{ steps.slug.outputs.version-major }}.${{ steps.slug.outputs.version-minor }}
3737
ghcr.io/${{ github.actor }}/3proxy:${{ steps.slug.outputs.version-major }}
3838
docker.io/tarampampam/3proxy:latest
39-
docker.io/tarampampam/3proxy:${{ steps.slug.outputs.version-semantic }}
39+
docker.io/tarampampam/3proxy:${{ steps.slug.outputs.version }}
4040
docker.io/tarampampam/3proxy:${{ steps.slug.outputs.version-major }}.${{ steps.slug.outputs.version-minor }}
4141
docker.io/tarampampam/3proxy:${{ steps.slug.outputs.version-major }}
42+
43+
helm-pack:
44+
name: Pack the Helm chart
45+
runs-on: ubuntu-latest
46+
defaults: {run: {working-directory: ./deployments/helm}}
47+
steps:
48+
- uses: actions/checkout@v4
49+
- uses: azure/setup-helm@v4
50+
- {uses: gacts/github-slug@v1, id: slug}
51+
- run: |
52+
helm package \
53+
--app-version "${{ steps.slug.outputs.version }}" \
54+
--version "${{ steps.slug.outputs.version }}" .
55+
- uses: actions/upload-artifact@v4
56+
with:
57+
name: helm-chart
58+
path: ./deployments/helm/*.tgz
59+
if-no-files-found: error
60+
retention-days: 1
61+
62+
helm-publish:
63+
name: Put the Helm chart to the GitHub pages branch
64+
runs-on: ubuntu-latest
65+
needs: [helm-pack]
66+
steps:
67+
- {uses: actions/checkout@v4, with: {ref: gh-pages}}
68+
- uses: azure/setup-helm@v4
69+
- uses: actions/download-artifact@v4
70+
with: {name: helm-chart, path: ./helm-charts}
71+
- name: Update the index.yaml
72+
run: |
73+
helm repo index \
74+
--url https://${{ github.actor }}.github.io/${{ github.event.repository.name }}/helm-charts/ \
75+
--merge \
76+
./helm-charts/index.yaml \
77+
./helm-charts
78+
- uses: yKicchan/generate-directory-listing-action@v1
79+
with: {target: ., ignore: "**/index.html", override: true}
80+
- name: Commit and push the changes
81+
run: |
82+
git config user.name "${{ github.actor }}"
83+
git config user.email "${{ github.actor }}@users.noreply.github.com"
84+
git add .
85+
git commit -m "Helm chart release"
86+
git push origin gh-pages

.github/workflows/tests.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,39 @@ jobs:
2424
- {uses: actions/checkout@v4, with: {fetch-depth: 0}}
2525
- uses: gacts/gitleaks@v1
2626

27+
filter:
28+
name: Filter files
29+
runs-on: ubuntu-latest
30+
permissions: {pull-requests: read}
31+
outputs:
32+
docker: ${{ steps.filter.outputs.docker }}
33+
helm: ${{ steps.filter.outputs.helm }}
34+
steps:
35+
- uses: dorny/paths-filter@v3
36+
id: filter
37+
with:
38+
filters: |
39+
docker: [Dockerfile, '*docker*', '*3proxy*']
40+
helm: ['deployments/helm/**', '*kube*']
41+
42+
lint-charts:
43+
name: Lint the chart
44+
runs-on: ubuntu-latest
45+
needs: [filter]
46+
if: needs.filter.outputs.helm == 'true'
47+
defaults: {run: {working-directory: ./deployments/helm}}
48+
steps:
49+
- uses: actions/checkout@v4
50+
- uses: azure/setup-helm@v4
51+
- run: helm dependency update .
52+
- run: helm template . > /dev/null
53+
- run: helm lint --strict .
54+
2755
build-image:
2856
name: Build the docker image
2957
runs-on: ubuntu-latest
58+
needs: [filter] # since this is the initial step, we can filter out the rest of the jobs right here to skip them
59+
if: needs.filter.outputs.docker == 'true'
3060
steps:
3161
- uses: actions/checkout@v4
3262
- run: docker build -f ./Dockerfile --tag 3proxy:local .

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
FROM gcc:13.3.0 AS builder
44

5-
# renovate: source=github-tags name=z3APA3A/3proxy
5+
# renovate: source=github-tags name=3proxy/3proxy
66
ARG Z3PROXY_VERSION=0.9.4
77

88
# Fetch 3proxy sources
99
RUN set -x \
10-
&& git -c advice.detachedHead=false clone --depth 1 --branch "${Z3PROXY_VERSION}" https://github.com/z3APA3A/3proxy.git /tmp/3proxy
10+
&& git -c advice.detachedHead=false clone --depth 1 --branch "${Z3PROXY_VERSION}" https://github.com/3proxy/3proxy.git /tmp/3proxy
1111

1212
WORKDIR /tmp/3proxy
1313

1414
# Patch sources
1515
RUN set -x \
1616
&& echo '#define ANONYMOUS 1' >> ./src/3proxy.h \
17-
# proxy.c source: <https://github.com/z3APA3A/3proxy/blob/0.9.3/src/proxy.c>
17+
# proxy.c source: <https://github.com/3proxy/3proxy/blob/0.9.3/src/proxy.c>
1818
&& sed -i 's~\(<\/head>\)~<style>:root{--color-bg-primary:#fff;--color-text-primary:#131313;--color-text-secondary:#232323}\
1919
@media (prefers-color-scheme: dark){:root{--color-bg-primary:#212121;--color-text-primary:#fafafa;--color-text-secondary:#bbb}}\
2020
html,body{height:100%;font-family:sans-serif;background-color:var(--color-bg-primary);color:var(--color-text-primary);margin:0;\

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ Image: ghcr.io/tarampampam/3proxy:1.8.2
7070
| `EXTRA_CONFIG` | Additional 3proxy configuration (appended to the **end** of the config file, but before `proxy` and `flush`) | `# line 1\n# line 2` |
7171
| `LOG_OUTPUT` | Path for log output (`/dev/stdout` by default; set to `/dev/null` to disable logging) | `/tmp/3proxy.log` |
7272

73+
## Helm Chart
74+
75+
To install it on Kubernetes (K8s), please use the Helm chart from [ArtifactHUB][artifact-hub].
76+
77+
[artifact-hub]:https://artifacthub.io/packages/helm/proxy-3proxy/proxy-3proxy
78+
7379
## How to Use This Image
7480

7581
Example usage:
@@ -78,7 +84,7 @@ Example usage:
7884
docker run --rm -d \
7985
-p "3128:3128/tcp" \
8086
-p "1080:1080/tcp" \
81-
ghcr.io/tarampampam/3proxy:latest
87+
ghcr.io/tarampampam/3proxy:1
8288
```
8389

8490
With authentication and custom resolver settings:
@@ -90,15 +96,15 @@ docker run --rm -d \
9096
-e "PROXY_LOGIN=evil" \
9197
-e "PROXY_PASSWORD=live" \
9298
-e "PRIMARY_RESOLVER=2001:4860:4860::8888" \
93-
ghcr.io/tarampampam/3proxy:latest
99+
ghcr.io/tarampampam/3proxy:1
94100
```
95101

96102
Docker compose example:
97103

98104
```yaml
99105
services:
100106
3proxy:
101-
image: ghcr.io/tarampampam/3proxy:latest
107+
image: ghcr.io/tarampampam/3proxy:1
102108
environment:
103109
PROXY_LOGIN: evil
104110
PROXY_PASSWORD: live
@@ -142,4 +148,4 @@ This project is licensed under the WTFPL. Use it freely and enjoy!
142148
[link_docker_tags]:https://hub.docker.com/r/tarampampam/3proxy/tags
143149
[link_docker_hub]:https://hub.docker.com/r/tarampampam/3proxy/
144150
[link_ghcr]:https://github.com/tarampampam/3proxy-docker/pkgs/container/3proxy
145-
[link_3proxy]:https://github.com/z3APA3A/3proxy
151+
[link_3proxy]:https://github.com/3proxy/3proxy

deployments/helm/Chart.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/chart.json
2+
3+
apiVersion: v2
4+
name: proxy-3proxy
5+
description: Powerful and lightweight proxy server, written in pure C
6+
7+
type: application
8+
version: 0.0.0 # will be replaced by the release workflow
9+
appVersion: 0.0.0 # will be replaced by the release workflow
10+
icon: https://github.com/user-attachments/assets/023186cf-b153-459c-8417-038fd87a2065
11+
home: https://github.com/3proxy/3proxy
12+
sources: [https://github.com/tarampampam/3proxy-docker]
13+
keywords: [proxy, 3proxy, http, socks]

deployments/helm/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# 3proxy
2+
3+
Important note: Since the chart is released together with the app under the same version (i.e., the chart version
4+
matches the app version), its versioning is not compatible with semantic versioning (SemVer). I will do my best to
5+
avoid non-backward-compatible changes in the chart, but due to Murphy's Law, I cannot guarantee that they will
6+
never occur.
7+
8+
Also, this chart does not include Ingress configuration. If you need it, please, create it manually.
9+
10+
## Usage
11+
12+
```shell
13+
helm repo add proxy-3proxy https://tarampampam.github.io/3proxy-docker/helm-charts
14+
helm repo update
15+
16+
helm install my-3proxy proxy-3proxy/proxy-3proxy --version <version_here>
17+
```
18+
19+
Alternatively, add the following lines to your `Chart.yaml`:
20+
21+
```yaml
22+
dependencies:
23+
- name: proxy-3proxy
24+
version: <version_here>
25+
repository: https://tarampampam.github.io/3proxy-docker/helm-charts
26+
```
27+
28+
And override the default values in your `values.yaml`:
29+
30+
```yaml
31+
proxy-3proxy:
32+
# ...
33+
service: {ports: {http: 3128}}
34+
# ...
35+
```
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{{/* Define namespace of chart, useful for multi-namespace deployments */}}
2+
{{- define "proxy-3proxy.namespace" -}}
3+
{{- if .Values.namespaceOverride }}
4+
{{- .Values.namespaceOverride }}
5+
{{- else }}
6+
{{- .Release.Namespace }}
7+
{{- end }}
8+
{{- end }}
9+
10+
{{/* Expand the name of the chart */}}
11+
{{- define "proxy-3proxy.name" -}}
12+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
13+
{{- end }}
14+
15+
{{/*
16+
Create a default fully qualified app name.
17+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
18+
If release name contains chart name it will be used as a full name.
19+
*/}}
20+
{{- define "proxy-3proxy.fullname" -}}
21+
{{- if .Values.fullnameOverride }}
22+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
23+
{{- else }}
24+
{{- $name := default .Chart.Name .Values.nameOverride }}
25+
{{- if contains $name .Release.Name }}
26+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
27+
{{- else }}
28+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
29+
{{- end }}
30+
{{- end }}
31+
{{- end }}
32+
33+
{{/* Create chart name and version as used by the chart label */}}
34+
{{- define "proxy-3proxy.chart" -}}
35+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
36+
{{- end }}
37+
38+
{{/* Common labels */}}
39+
{{- define "proxy-3proxy.commonLabels" -}}
40+
helm.sh/chart: {{ include "proxy-3proxy.chart" . }}
41+
{{ include "proxy-3proxy.selectorLabels" . }}
42+
{{- if .Chart.AppVersion }}
43+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
44+
{{- end }}
45+
app.kubernetes.io/managed-by: {{ .Release.Service }}
46+
{{- end }}
47+
48+
{{/* Selector labels */}}
49+
{{- define "proxy-3proxy.selectorLabels" -}}
50+
app.kubernetes.io/name: {{ include "proxy-3proxy.name" . }}
51+
app.kubernetes.io/instance: {{ .Release.Name }}
52+
{{- end }}

0 commit comments

Comments
 (0)