From e888965b831f75a88ba063f677dbeae4288af353 Mon Sep 17 00:00:00 2001 From: David Janowski Date: Tue, 20 Feb 2024 09:55:56 +0100 Subject: [PATCH] initial commit --- .gitignore | 194 +++++++++++++++++++++++++++++++++++++++ .gitmodules | 4 + build/package/Dockerfile | 24 +++++ build/package/README.md | 34 +++++++ thrid_party/grpc-proto | 1 + 5 files changed, 257 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 build/package/Dockerfile create mode 100644 build/package/README.md create mode 160000 thrid_party/grpc-proto diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f7b74d3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,194 @@ +# File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig +# Created by https://www.toptal.com/developers/gitignore/api/windows,visualstudiocode,goland,go +# Edit at https://www.toptal.com/developers/gitignore?templates=windows,visualstudiocode,goland,go + +### Go ### +# If you prefer the allow list template instead of the deny list, see community template: +# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore +# +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +# vendor/ + +# Go workspace file +go.work + +### GoLand ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### GoLand Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +# Azure Toolkit for IntelliJ plugin +# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij +.idea/**/azureSettings.xml + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.toptal.com/developers/gitignore/api/windows,visualstudiocode,goland,go + +# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option) + +.idea/* +/.run/* + + +*.env \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..604dc88 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "thrid_party/grpc-proto"] + path = thrid_party/grpc-proto + url = https://git.dragse.it/anthrove/grpc-proto.git + branch = release/v1.0.0 \ No newline at end of file diff --git a/build/package/Dockerfile b/build/package/Dockerfile new file mode 100644 index 0000000..74ae9ca --- /dev/null +++ b/build/package/Dockerfile @@ -0,0 +1,24 @@ +FROM golang:alpine AS builder + +ARG PLUG_NAME + +WORKDIR /go/src/git.dragse.it/anthrove/plug-$PLUG_NAME + +RUN apk add -U --no-cache ca-certificates && update-ca-certificates + +COPY go.mod ./ +RUN go mod download + +COPY . ./ + +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags "-w -s" -o /app ./cmd/ + +FROM scratch + +WORKDIR / + +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ +COPY --from=builder /app ./ + +EXPOSE 8080 +CMD ["/app"] \ No newline at end of file diff --git a/build/package/README.md b/build/package/README.md new file mode 100644 index 0000000..0481767 --- /dev/null +++ b/build/package/README.md @@ -0,0 +1,34 @@ +# Building a Plug + +When building a Plug use the following command and replace the _test_ placeholder with the plugs name. It is also im ortend that you are in the root folder of the project. +````bash +docker build --build-arg="PLUG_NAME=test" -t test -f .\build\package\Dockerfile . +```` + +Dockerfile: +````dockerfile +FROM golang:alpine AS builder + +ARG PLUG_NAME + +WORKDIR /go/src/git.dragse.it/anthrove/plug-$PLUG_NAME + +RUN apk add -U --no-cache ca-certificates && update-ca-certificates + +COPY go.mod ./ +RUN go mod download + +COPY . ./ + +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags "-w -s" -o /app ./cmd/ + +FROM scratch + +WORKDIR / + +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ +COPY --from=builder /app ./ + +EXPOSE 8080 +CMD ["/app"] +```` \ No newline at end of file diff --git a/thrid_party/grpc-proto b/thrid_party/grpc-proto new file mode 160000 index 0000000..5c6b676 --- /dev/null +++ b/thrid_party/grpc-proto @@ -0,0 +1 @@ +Subproject commit 5c6b67694d0876068fc6ff55f643e09b8c72e41a