Skip to content

Commit

Permalink
refactor!: simplify setup and add multi arch build
Browse files Browse the repository at this point in the history
  • Loading branch information
segadora committed Nov 1, 2024
1 parent ab9e442 commit 4ab3ff3
Show file tree
Hide file tree
Showing 13 changed files with 484 additions and 463 deletions.
14 changes: 5 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,20 @@ name: CI

on:
pull_request:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22.x"
- uses: actions/checkout@v4
go-version-file: 'go.mod'

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest

docker-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build the Docker image
run: docker build . --file Dockerfile --tag iptv-proxy:ci-build --target executable
12 changes: 12 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Docker build

on:
pull_request:

jobs:
docker-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build the Docker image
run: docker build . --file Dockerfile --tag iptv-proxy:ci-build --target executable
120 changes: 90 additions & 30 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ on:
branches:
- master

permissions:
contents: write
pull-requests: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
release-please:
Expand All @@ -24,54 +24,114 @@ jobs:
config-file: release-please-config.json
manifest-file: .release-please-manifest.json

push_to_registry:
build:
needs: [ release-please ]
name: Push Docker image
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm/v6
- linux/arm/v7
- linux/arm64
if: ${{ needs.release-please.outputs.release }}
permissions:
packages: write
contents: read
attestations: write
id-token: write
if: ${{ needs.release-please.outputs.release }}
env:
IMAGE_NAME: ${{ github.repository }}
REGISTRY: ghcr.io
packages: write
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Log in to Docker
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push Docker image
id: push
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest, ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.release-please.outputs.tag }}
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true

- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.build.outputs.digest }}
push-to-registry: true

- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}
81 changes: 81 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,86 @@
# Changelog

## [2.0.8](https://github.com/segadora/iptv-proxy/compare/v2.0.7...v2.0.8) (2024-11-01)


### Miscellaneous

* move permissions ([c14d49d](https://github.com/segadora/iptv-proxy/commit/c14d49db14a9a09b9ae55b312a38af668c711a6c))

## [2.0.7](https://github.com/segadora/iptv-proxy/compare/v2.0.6...v2.0.7) (2024-11-01)


### Bug Fixes

* fix merge fails ([7021070](https://github.com/segadora/iptv-proxy/commit/70210706e21935b62399653bfd967fda53fef13d))

## [2.0.6](https://github.com/segadora/iptv-proxy/compare/v2.0.5...v2.0.6) (2024-11-01)


### Bug Fixes

* fix missing permissions on merge ([2c0f036](https://github.com/segadora/iptv-proxy/commit/2c0f036b1112996a3e349f6f031a7fff4f6527bf))

## [2.0.5](https://github.com/segadora/iptv-proxy/compare/v2.0.4...v2.0.5) (2024-11-01)


### Bug Fixes

* fix job failing ([e8b32ce](https://github.com/segadora/iptv-proxy/commit/e8b32ce46f69599f5d90ae8b525b23e6de8a7b73))


### Miscellaneous

* change actions ([c4d68c5](https://github.com/segadora/iptv-proxy/commit/c4d68c515efdc5eb769d5041b637f45602eb95b9))
* remove unnessesary permission ([560f296](https://github.com/segadora/iptv-proxy/commit/560f296413f0d11ed99cf6ddef5f6c992847154a))

## [2.0.4](https://github.com/segadora/iptv-proxy/compare/v2.0.3...v2.0.4) (2024-11-01)


### Bug Fixes

* fix image should be pushed to ghcr.io ([c6511eb](https://github.com/segadora/iptv-proxy/commit/c6511ebd3a420c569c6155f72ef7a319aca7ce3a))


### Miscellaneous

* fix 'as' should be uppercase ([ca49a84](https://github.com/segadora/iptv-proxy/commit/ca49a840123f3276dbba06800f261d95d55d051f))

## [2.0.3](https://github.com/segadora/iptv-proxy/compare/v2.0.2...v2.0.3) (2024-11-01)


### Miscellaneous

* matrix pipeline building (test) ([347d926](https://github.com/segadora/iptv-proxy/commit/347d92674a1650931381d0f0084eb0248068c60f))

## [2.0.2](https://github.com/segadora/iptv-proxy/compare/v2.0.1...v2.0.2) (2024-11-01)


### Bug Fixes

* possible fix of 403 forbidden ([32e28c8](https://github.com/segadora/iptv-proxy/commit/32e28c80a6dff4013d7cadb5aaf39781dfc227f7))

## [2.0.1](https://github.com/segadora/iptv-proxy/compare/v2.0.0...v2.0.1) (2024-11-01)


### Bug Fixes

* fix broken workflow ([182d7c9](https://github.com/segadora/iptv-proxy/commit/182d7c935afdebf0527933dd82636ad3c1716fbf))

## [2.0.0](https://github.com/segadora/iptv-proxy/compare/v1.1.0...v2.0.0) (2024-11-01)


### ⚠ BREAKING CHANGES

* simplify setup and add multi arch build

### Miscellaneous

* add note ([4b71992](https://github.com/segadora/iptv-proxy/commit/4b71992a4f3cbbed8fb3d7aaa450ba9b64fdacc7))
* rerun workflow ([ab8a144](https://github.com/segadora/iptv-proxy/commit/ab8a144e342a254311849f0499dea5ec784f664e))
* simplify setup and add multi arch build ([82e5d57](https://github.com/segadora/iptv-proxy/commit/82e5d5761be0766ff0fbf0eea4ebcacf6a2c79a5))
* update readme to use gluetun ([56f983f](https://github.com/segadora/iptv-proxy/commit/56f983fa37c6065ac0fbf3d4dc899a148b957d78))

## [1.1.0](https://github.com/segadora/iptv-proxy/compare/v1.0.0...v1.1.0) (2024-06-19)


Expand Down
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.23-alpine as build
FROM golang:1.23-alpine AS build

WORKDIR /app

Expand All @@ -9,8 +9,12 @@ RUN go get -d -v ./...

RUN CGO_ENABLED=0 GOOS=linux go build -o iptv-proxy *.go

FROM alpine:3 as executable
FROM alpine:3 AS executable

COPY --from=build /app/iptv-proxy /

RUN apk add curl

HEALTHCHECK --interval=5s --timeout=5s --start-period=10s --retries=3 CMD curl --fail http://localhost:1323/health || exit 1

ENTRYPOINT ["/iptv-proxy"]
41 changes: 23 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Description

Iptv-Proxy is a project to proxyfie an m3u file
Iptv-Proxy is acting as a reverse proxy and serving the stream though go to allow use of a proxy in docker compose.

### M3u Example

Expand All @@ -23,37 +23,42 @@ http://iptvexample.net:1234/15/test/4
```

What M3U proxy IPTV do
- convert chanels url to new endpoints
- convert original m3u file with new routes pointing to the proxy
- convert chanels url to new endpoints
- convert original m3u file with new routes pointing to internal routes

## Docker compose example with nordvpn

Uses docker container from [edgd1er/nordvpn-proxy](https://github.com/edgd1er/nordvpn-proxy).

The following urls will be available for you.

M3U: `http://127.0.0.1:1323/playlist.m3u`
M3U: `http://127.0.0.1:1323/get/m3u`

EPG: `http://127.0.0.1:1323/epg`
EPG: `http://127.0.0.1:1323/get/epg`

Health endpoint: `http://127.0.0.1:1323/health`

```yaml
services:
proxy:
image: edgd1er/nordvpn-proxy:latest
restart: unless-stopped
container_name: proxy
# additional config will be needed, see
ports:
# iptv proxy
- 1323:1323
# see gluetun https://github.com/qdm12/gluetun
gluetun:
container_name: gluetun
image: qmcgaw/gluetun
# add rest

iptv-proxy:
image: ghcr.io/segadora/iptv-proxy:latest
container_name: "iptv-proxy"
network_mode: service:proxy # route traffic though vpn container
depends_on:
- proxy
network_mode: service:gluetun # https://github.com/qdm12/gluetun-wiki/blob/main/setup/connect-a-container-to-gluetun.md
restart: on-failure
environment:
M3U_URL: https://xeev.net/get/m3u/xxxxxxxxxxxxxxxxxxxxx
EPG_URL: https://xeev.net/get/epg/xxxxxxxxxxxxxxxxxxxxx
IPTV_PLAYLIST: https://xeev.net/get/m3u/xxxxxxxxxxxxxxxxxxxxx
IPTV_EPG: https://xeev.net/get/epg/xxxxxxxxxxxxxxxxxxxxx
depends_on:
gluetun:
condition: service_healthy
```
## Notes
- Does not work with HLS
24 changes: 0 additions & 24 deletions config.go

This file was deleted.

Loading

0 comments on commit 4ab3ff3

Please sign in to comment.