feat: initial commit

This commit is contained in:
2023-11-15 20:38:25 +01:00
commit e199fe3d26
67 changed files with 4152 additions and 0 deletions

View File

@ -0,0 +1,35 @@
{
"client_id": "oidc-test",
"client_name": "OIDC Test",
"client_secret": "oidc-test-123456",
"client_uri": "http://localhost:8080",
"grant_types": [
"authorization_code",
"refresh_token",
"client_credentials",
"implicit"
],
"jwks": {},
"logo_uri": "",
"metadata": {},
"owner": "",
"policy_uri": "",
"post_logout_redirect_uris": [
"http://localhost:8080"
],
"redirect_uris": [
"http://localhost:8080/oauth2/callback"
],
"request_object_signing_alg": "RS256",
"response_types": [
"token",
"code",
"id_token"
],
"scope": "openid profile email",
"skip_consent": false,
"subject_type": "public",
"token_endpoint_auth_method": "client_secret_basic",
"tos_uri": "",
"userinfo_signed_response_alg": "none"
}

33
misc/docker/Dockerfile Normal file
View File

@ -0,0 +1,33 @@
FROM golang:1.21 AS build
ARG HTTP_PROXY=
ARG HTTPS_PROXY=
ARG http_proxy=
ARG https_proxy=
RUN apt-get update && apt-get install -y build-essential git bash
RUN mkdir -p /src
WORKDIR /src
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
RUN make ARCH_TARGETS=amd64 release
FROM busybox
COPY --from=build /src/release/server-linux-amd64 /app
WORKDIR /app
RUN mkdir ./data
EXPOSE 3000
CMD ["bin/server", "-workdir", "/app", "-config", "server.yml"]

119
misc/script/release.sh Normal file
View File

@ -0,0 +1,119 @@
#!/bin/bash
set -eo pipefail
OS_TARGETS=(linux)
ARCH_TARGETS=${ARCH_TARGETS:-amd64 arm 386}
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
PROJECT_DIR="$DIR/../.."
function build {
local name=$1
local srcdir=$2
local os=$3
local arch=$4
local dirname="$name-$os-$arch"
local destdir="$PROJECT_DIR/release/$dirname"
rm -rf "$destdir"
mkdir -p "$destdir"
echo "building $dirname..."
CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" go build \
-ldflags="-s -w -X 'main.GitRef=$(current_commit_ref)' -X 'main.ProjectVersion=$(current_version)' -X 'main.BuildDate=$(current_date)'" \
-gcflags=-trimpath="${PWD}" \
-asmflags=-trimpath="${PWD}" \
-o "$destdir/bin/$name" \
"$srcdir"
if [ ! -z "$(which upx)" ]; then
upx --best "$destdir/bin/$name"
fi
}
function current_date {
date '+%Y-%m-%d %H:%M'
}
function current_commit_ref {
git log -n 1 --pretty="format:%h"
}
function current_version {
git describe --always
}
function copy {
local name=$1
local os=$2
local arch=$3
local src=$4
local dest=$5
local dirname="$name-$os-$arch"
local destdir="$PROJECT_DIR/release/$dirname"
echo "copying '$src' to '$destdir/$dest'..."
mkdir -p "$(dirname $destdir/$dest)"
cp -rfL $src "$destdir/$dest"
}
function dump_default_conf {
# Generate and copy configuration file
local command=$1
local os=$2
local arch=$3
local tmp_conf=$(mktemp)
go run "$PROJECT_DIR/cmd/$command" -dump-config > "$tmp_conf"
copy "$command" $os $arch "$tmp_conf" "$command.yml"
rm -f "$tmp_conf"
}
function compress {
local name=$1
local os=$2
local arch=$3
local dirname="$name-$os-$arch"
local destdir="$PROJECT_DIR/release/$dirname"
echo "compressing $dirname..."
tar -czf "$destdir.tar.gz" -C "$destdir/../" "$dirname"
}
function release_server {
local os=$1
local arch=$2
build 'server' "$PROJECT_DIR/cmd/server" $os $arch
dump_default_conf 'server' $os $arch
copy 'server' $os $arch "$PROJECT_DIR/README.md" "README.md"
copy 'server' $os $arch "$PROJECT_DIR/public" "public"
copy 'server' $os $arch "$PROJECT_DIR/template" "template"
compress 'server' $os $arch
}
function main {
for os in ${OS_TARGETS[@]}; do
for arch in ${ARCH_TARGETS[@]}; do
release_server $os $arch
done
done
}
main