Update Docker configuration and documentation for Linux compatibility. Added extra_hosts for Docker Compose and updated GATEWAY_RUN.md to reflect changes in running commands for Linux. Enhanced GitHub Actions workflow for building and pushing Docker images.
Publish telemt-api gateway Docker image / test (push) Has been cancelled
Publish telemt-api gateway Docker image / build-and-push (push) Has been cancelled

This commit is contained in:
Denozordec
2026-03-29 22:54:22 +07:00
parent 91f289c647
commit e9701ca9da
5 changed files with 144 additions and 55 deletions
+72 -33
View File
@@ -1,20 +1,27 @@
name: ci
name: Publish telemt-api gateway Docker image
on:
push:
branches: [main, master]
tags: ["v*"]
pull_request:
branches:
- "**"
tags:
- "*"
workflow_dispatch:
env:
GO_VERSION: "1.22"
REGISTRY: git.shts.su
IMAGE_REPO: ${{ gitea.repository }}
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set up Go
uses: actions/setup-go@v5
@@ -24,38 +31,70 @@ jobs:
- name: Test
run: go mod tidy && go test ./...
docker:
needs: test
build-and-push:
runs-on: ubuntu-latest
needs: test
timeout-minutes: 20
permissions:
contents: read
packages: write
steps:
- name: Checkout
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Build image
run: docker build -t telemt-api:ci .
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
image=moby/buildkit:v0.13.2
- name: Push to registry
if: github.event_name == 'push'
- name: Log in to Gitea Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ gitea.actor }}
password: ${{ secrets.ACTIONS_PAT }}
- name: Prepare Docker tags
id: prep
shell: bash
env:
REGISTRY_IMAGE: ${{ secrets.REGISTRY_IMAGE }}
REGISTRY_URL: ${{ secrets.REGISTRY_URL }}
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
REPO: ${{ gitea.repository }}
SHA: ${{ gitea.sha }}
REF_NAME: ${{ gitea.ref_name }}
run: |
set -e
if [ -z "$REGISTRY_IMAGE" ] || [ -z "$REGISTRY_URL" ] || [ -z "$REGISTRY_USER" ] || [ -z "$REGISTRY_PASSWORD" ]; then
echo "Registry secrets not set (REGISTRY_IMAGE, REGISTRY_URL, REGISTRY_USER, REGISTRY_PASSWORD) — push skipped."
exit 0
fi
echo "$REGISTRY_PASSWORD" | docker login "$REGISTRY_URL" -u "$REGISTRY_USER" --password-stdin
docker tag telemt-api:ci "${REGISTRY_IMAGE}:sha-${GITHUB_SHA}"
docker push "${REGISTRY_IMAGE}:sha-${GITHUB_SHA}"
if [ "${GITHUB_REF}" = "refs/heads/main" ] || [ "${GITHUB_REF}" = "refs/heads/master" ]; then
docker tag telemt-api:ci "${REGISTRY_IMAGE}:latest"
docker push "${REGISTRY_IMAGE}:latest"
fi
if echo "${GITHUB_REF}" | grep -q '^refs/tags/'; then
TAG="${GITHUB_REF#refs/tags/}"
docker tag telemt-api:ci "${REGISTRY_IMAGE}:${TAG}"
docker push "${REGISTRY_IMAGE}:${TAG}"
fi
set -euo pipefail
IMAGE="${REGISTRY}/${REPO}"
BRANCH_OR_TAG="${REF_NAME:-unknown}"
SAFE_REF="$(echo "${BRANCH_OR_TAG}" | tr '/' '-')"
SHORT_SHA="$(echo "${SHA}" | cut -c1-12)"
TAGS="$(printf '%s\n%s\n%s\n' \
"${IMAGE}:latest" \
"${IMAGE}:${SAFE_REF}" \
"${IMAGE}:sha-${SHORT_SHA}")"
echo "tags<<EOF" >> "${GITHUB_OUTPUT}"
echo "${TAGS}" >> "${GITHUB_OUTPUT}"
echo "EOF" >> "${GITHUB_OUTPUT}"
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64
cache-from: |
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}:latest
cache-to: type=inline
tags: ${{ steps.prep.outputs.tags }}
labels: |
org.opencontainers.image.title=telemt-api-gateway
org.opencontainers.image.description=HTTP gateway with IP whitelist and Telemt Control API proxy by alias
org.opencontainers.image.revision=${{ gitea.sha }}
org.opencontainers.image.source=${{ gitea.server_url }}/${{ gitea.repository }}
provenance: false