mirror of
https://github.com/gabehf/koito-multi-proxy.git
synced 2026-03-07 21:48:14 -08:00
docker and workflow
This commit is contained in:
parent
656b5fd9c5
commit
e60b83ebc8
3 changed files with 63 additions and 1 deletions
30
.github/workflows/docker.yml
vendored
Normal file
30
.github/workflows/docker.yml
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
name: Build and Push Docker Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Log in to Docker registry
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build Docker image
|
||||||
|
run: |
|
||||||
|
docker build -t gabehf/koito-multi-proxy:latest .
|
||||||
|
|
||||||
|
- name: Push Docker image
|
||||||
|
run: |
|
||||||
|
docker push gabehf/koito-multi-proxy:latest
|
||||||
27
Dockerfile
Normal file
27
Dockerfile
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
# Stage 1: Build Go binary using lightweight Alpine
|
||||||
|
FROM golang:1.24-alpine AS builder
|
||||||
|
|
||||||
|
# Set workdir
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy go.mod/go.sum and download dependencies
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
RUN go mod download
|
||||||
|
|
||||||
|
# Copy source code
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Build Go binary
|
||||||
|
RUN GOOS=linux go build -o koito-multi-proxy .
|
||||||
|
|
||||||
|
# Stage 2: Runtime on Ubuntu 24.04
|
||||||
|
FROM ubuntu:24.04
|
||||||
|
|
||||||
|
# Avoid interactive prompts during apt installs
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
# Copy Go binary from builder stage
|
||||||
|
COPY --from=builder /app/koito-multi-proxy /usr/local/bin/koito-multi-proxy
|
||||||
|
|
||||||
|
# Entrypoint
|
||||||
|
ENTRYPOINT ["koito-multi-proxy"]
|
||||||
7
main.go
7
main.go
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
|
|
@ -24,7 +25,11 @@ var urlMap map[string]string
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// 1. Load and Parse Config
|
// 1. Load and Parse Config
|
||||||
if err := loadConfig("config.yml"); err != nil {
|
cfgDir := os.Getenv("KMP_CONFIG_DIR")
|
||||||
|
if cfgDir == "" {
|
||||||
|
cfgDir = "/etc/kmp"
|
||||||
|
}
|
||||||
|
if err := loadConfig(path.Join(cfgDir, "config.yml")); err != nil {
|
||||||
log.Fatalf("Failed to load configuration: %v", err)
|
log.Fatalf("Failed to load configuration: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue