Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
joente committed Nov 30, 2023
1 parent da36956 commit b2637b1
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 17 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: cesbit
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install libcleri
run: |
git clone https://github.com/cesbit/libcleri.git
cd ./libcleri/Release/
make
sudo make install
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libuv1-dev libpcre2-dev libyajl-dev libcurl4-nss-dev valgrind
- name: Run tests
run: |
cd ./Release/
make test
- name: Compile code
run: |
cd ./Release/
CFLAGS="-Werror -Winline -std=gnu11" make
47 changes: 47 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Deploy

on:
push:
tags:
- "v*-*" # v1.2.3-alpha0 etc.

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/cesbit/tlsproxy

- name: Get the version
id: get_version
run: echo "VERSION=$(echo $GITHUB_REF | cut -d / -f 3)" >> $GITHUB_OUTPUT

- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
push: true
file: Dockerfile
tags: ghcr.io/cesbit/tlsproxy:${{ steps.get_version.outputs.VERSION }}
labels: ${{ steps.meta.outputs.labels }}
48 changes: 48 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release

on:
push:
tags:
- "v*"
- "!v*-*" # v1.2.3-alphd0

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/cesbit/tlsproxy

- name: Get the version
id: get_version
run: echo "VERSION=$(echo $GITHUB_REF | cut -d / -f 3)" >> $GITHUB_OUTPUT

- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
push: true
file: Dockerfile
tags: ghcr.io/cesbit/tlsproxy:${{ steps.get_version.outputs.VERSION }},ghcr.io/cesbit/tlsproxy:latest
labels: ${{ steps.meta.outputs.labels }}
11 changes: 7 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o /tlsproxy

# Expose (accept client connections)
EXPOSE 443
EXPOSE 9200
EXPOSE 8000

ENV TLSPROXY_TARGET "localhost"
ENV TLSPROXY_PORTS "443:80"
ENV TLSPROXY_CERT_FILE "server.crt"
ENV TLSPROXY_KEY_FILE "server.key"
ENV TLSPROXY_PORTS "443:80,8000"
ENV TLSPROXY_CERT_FILE "certificates/server.crt"
ENV TLSPROXY_KEY_FILE "certificates/server.key"

VOLUME "/certificates"

# Run
WORKDIR /
CMD ["/tlsproxy"]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Release Version](https://img.shields.io/github/release/thingsdb/go-thingsdb)](https://github.com/thingsdb/go-thingsdb/releases)
[![Release Version](https://img.shields.io/github/release/cesbit/tlsproxy)](https://github.com/cesbit/tlsproxy/releases)

# ThingsDB using TLS
# TLS Proxy

## Installation

Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions tlsproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"net/http"
"os"
"os/signal"
"path/filepath"
"regexp"
"strconv"
"strings"
Expand Down Expand Up @@ -133,13 +134,13 @@ func main() {
certFileEnv := os.Getenv("TLSPROXY_CERT_FILE")
if certFileEnv == "" {
log.Println("Missing or empty TLSPROXY_CERT_FILE, using 'server.crt' as default value")
certFileEnv = "server.crt"
certFileEnv = filepath.Join("certificates", "server.crt")
}

keyFileEnv := os.Getenv("TLSPROXY_KEY_FILE")
if keyFileEnv == "" {
log.Println("Missing or empty TLSPROXY_KEY_FILE, using 'server.key' as default value")
keyFileEnv = "server.key"
keyFileEnv = filepath.Join("certificates", "server.key")
}

r := regexp.MustCompile(`([0-9]+)(:([0-9]+))?`)
Expand Down
10 changes: 1 addition & 9 deletions version.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
package main

// Version exposes the go-thingsdb version
// Version exposes the TLS Proxy version
const Version = "0.1.0"

//Publish module:
//
// go mod tidy
// go test ./...
// git tag {VERSION}
// git push origin {VERSION}
// GOPROXY=proxy.golang.org go list -m github.com/thingsdb/go-thingsdb@{VERSION}

0 comments on commit b2637b1

Please sign in to comment.