Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
socheatsok78 committed Jun 25, 2024
0 parents commit 03c6844
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: "Build"

on:
push:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4

- 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:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

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

- name: Generate Docker metadata
id: docker-meta
uses: docker/metadata-action@v5
with:
images: |
docker.io/${{ github.repository }}
ghcr.io/${{ github.repository }}
flavor: latest=false
tags: |
type=ref,event=branch
- name: Generate GitHub metadata
id: github-meta
uses: dockerbakery/github-metadata-action@v2

- name: Build and push
uses: docker/bake-action@v4
with:
push: ${{ github.event_name != 'pull_request' }}
files: |
./docker-bake.hcl
${{ steps.docker-meta.outputs.bake-file }}
${{ steps.github-meta.outputs.bake-file }}
set: |
*.cache-from=type=gha
*.cache-to=type=gha,mode=max
- name: Docker Metadata Summary
uses: dockerbakery/docker-metadata-summary@v1
3 changes: 3 additions & 0 deletions Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:80 {
reverse_proxy {$TARGET_TASK_ADDR}
}
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ARG CADDY_VERSION="latest"
FROM caddy:${CADDY_VERSION}

ENV TARGET_TASK_ADDR=localhost
COPY Caddyfile /etc/caddy/Caddyfile
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
make:
docker buildx bake local --load
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# About

A simple Docker Swarm's Task proxy service that forwards requests to the appropriate a single service that binds to a specific address and port.

Why? It useful when you have a service that required high availability setup with pesky advertise address interface and port binding.
29 changes: 29 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
variable "CADDY_VERSION" { default = "latest" }

target "docker-metadata-action" {}
target "github-metadata-action" {}

target "default" {
inherits = [ "docker-task-proxy" ]
platforms = [
"linux/amd64",
"linux/arm64"
]
}

target "local" {
inherits = [ "docker-task-proxy" ]
tags = [ "swarmlibs/docker-task-proxy:local" ]
}

target "docker-task-proxy" {
context = "."
dockerfile = "Dockerfile"
inherits = [
"docker-metadata-action",
"github-metadata-action",
]
args = {
CADDY_VERSION = "${CADDY_VERSION}"
}
}

0 comments on commit 03c6844

Please sign in to comment.