docker
This commit is contained in:
3
.dockerignore
Normal file
3
.dockerignore
Normal file
@@ -0,0 +1,3 @@
|
||||
.env
|
||||
.vscode
|
||||
.idea
|
||||
29
.github/workflows/docker-image.yml
vendored
Normal file
29
.github/workflows/docker-image.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
name: Docker Image CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v1
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Build and Push Docker Image
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
push: true # Will only build if this is not here
|
||||
tags: |
|
||||
ghcr.io/developerdurp/durpapi:latest
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,5 +1,4 @@
|
||||
__debug_bin
|
||||
docs
|
||||
.vscode
|
||||
.env
|
||||
.idea
|
||||
23
Dockerfile
Normal file
23
Dockerfile
Normal file
@@ -0,0 +1,23 @@
|
||||
# Use golang:1.17 as the base image
|
||||
FROM golang:1.20
|
||||
|
||||
ENV GOPATH /go
|
||||
ENV PATH $PATH:$GOPATH/bin
|
||||
|
||||
# Set the working directory inside the container
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the Go project files into the container
|
||||
COPY . .
|
||||
|
||||
# Run swag init to generate Swagger documentation
|
||||
RUN go install && go install github.com/swaggo/swag/cmd/swag@latest && swag init
|
||||
|
||||
# Build the Go application inside the container
|
||||
RUN go build -o main .
|
||||
|
||||
# Expose the port the application listens on
|
||||
EXPOSE 8080
|
||||
|
||||
# Run the application
|
||||
CMD ["./main"]
|
||||
180
docs/docs.go
Normal file
180
docs/docs.go
Normal file
@@ -0,0 +1,180 @@
|
||||
// Code generated by swaggo/swag. DO NOT EDIT.
|
||||
|
||||
package docs
|
||||
|
||||
import "github.com/swaggo/swag"
|
||||
|
||||
const docTemplate = `{
|
||||
"schemes": {{ marshal .Schemes }},
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"description": "{{escape .Description}}",
|
||||
"title": "{{.Title}}",
|
||||
"termsOfService": "http://swagger.io/terms/",
|
||||
"contact": {
|
||||
"name": "API Support",
|
||||
"url": "http://www.swagger.io/support",
|
||||
"email": "support@swagger.io"
|
||||
},
|
||||
"license": {
|
||||
"name": "Apache 2.0",
|
||||
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
|
||||
},
|
||||
"version": "{{.Version}}"
|
||||
},
|
||||
"host": "{{.Host}}",
|
||||
"basePath": "{{.BasePath}}",
|
||||
"paths": {
|
||||
"/openai/general": {
|
||||
"get": {
|
||||
"description": "Ask ChatGPT a general question",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"text/plain"
|
||||
],
|
||||
"tags": [
|
||||
"openai"
|
||||
],
|
||||
"summary": "Gerneral ChatGPT",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Ask ChatGPT a general question",
|
||||
"name": "message",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "response",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/openai/travelagent": {
|
||||
"get": {
|
||||
"description": "Ask ChatGPT for suggestions as if it was a travel agent",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"text/plain"
|
||||
],
|
||||
"tags": [
|
||||
"openai"
|
||||
],
|
||||
"summary": "Travel Agent ChatGPT",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Ask ChatGPT for suggestions as a travel agent",
|
||||
"name": "message",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "response",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/unraid/powerusage": {
|
||||
"get": {
|
||||
"description": "Gets the PSU Data from unraid",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"unraid"
|
||||
],
|
||||
"summary": "Unraid PSU Stats",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "response",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"securityDefinitions": {
|
||||
"ApiKeyAuth": {
|
||||
"description": "Description for what is this security definition being used",
|
||||
"type": "apiKey",
|
||||
"name": "Authorization",
|
||||
"in": "header"
|
||||
},
|
||||
"BasicAuth": {
|
||||
"type": "basic"
|
||||
},
|
||||
"OAuth2AccessCode": {
|
||||
"type": "oauth2",
|
||||
"flow": "accessCode",
|
||||
"authorizationUrl": "https://example.com/oauth/authorize",
|
||||
"tokenUrl": "https://example.com/oauth/token",
|
||||
"scopes": {
|
||||
"admin": "\t\t\t\t\t\t\tGrants read and write access to administrative information"
|
||||
}
|
||||
},
|
||||
"OAuth2Application": {
|
||||
"type": "oauth2",
|
||||
"flow": "application",
|
||||
"tokenUrl": "https://example.com/oauth/token",
|
||||
"scopes": {
|
||||
"admin": "\t\t\t\t\t\t\tGrants read and write access to administrative information",
|
||||
"write": "\t\t\t\t\t\t\tGrants write access"
|
||||
}
|
||||
},
|
||||
"OAuth2Implicit": {
|
||||
"type": "oauth2",
|
||||
"flow": "implicit",
|
||||
"authorizationUrl": "https://example.com/oauth/authorize",
|
||||
"scopes": {
|
||||
"admin": "\t\t\t\t\t\t\tGrants read and write access to administrative information",
|
||||
"write": "\t\t\t\t\t\t\tGrants write access"
|
||||
}
|
||||
},
|
||||
"OAuth2Password": {
|
||||
"type": "oauth2",
|
||||
"flow": "password",
|
||||
"tokenUrl": "https://example.com/oauth/token",
|
||||
"scopes": {
|
||||
"admin": "\t\t\t\t\t\t\tGrants read and write access to administrative information",
|
||||
"read": "\t\t\t\t\t\t\t\tGrants read access",
|
||||
"write": "\t\t\t\t\t\t\tGrants write access"
|
||||
}
|
||||
}
|
||||
}
|
||||
}`
|
||||
|
||||
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
||||
var SwaggerInfo = &swag.Spec{
|
||||
Version: "1.0",
|
||||
Host: "localhost:8080",
|
||||
BasePath: "/api/v1",
|
||||
Schemes: []string{},
|
||||
Title: "DurpAPI",
|
||||
Description: "This is a sample server celler server.",
|
||||
InfoInstanceName: "swagger",
|
||||
SwaggerTemplate: docTemplate,
|
||||
}
|
||||
|
||||
func init() {
|
||||
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
|
||||
}
|
||||
157
docs/swagger.json
Normal file
157
docs/swagger.json
Normal file
@@ -0,0 +1,157 @@
|
||||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"description": "This is a sample server celler server.",
|
||||
"title": "DurpAPI",
|
||||
"termsOfService": "http://swagger.io/terms/",
|
||||
"contact": {
|
||||
"name": "API Support",
|
||||
"url": "http://www.swagger.io/support",
|
||||
"email": "support@swagger.io"
|
||||
},
|
||||
"license": {
|
||||
"name": "Apache 2.0",
|
||||
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
|
||||
},
|
||||
"version": "1.0"
|
||||
},
|
||||
"host": "localhost:8080",
|
||||
"basePath": "/api/v1",
|
||||
"paths": {
|
||||
"/openai/general": {
|
||||
"get": {
|
||||
"description": "Ask ChatGPT a general question",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"text/plain"
|
||||
],
|
||||
"tags": [
|
||||
"openai"
|
||||
],
|
||||
"summary": "Gerneral ChatGPT",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Ask ChatGPT a general question",
|
||||
"name": "message",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "response",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/openai/travelagent": {
|
||||
"get": {
|
||||
"description": "Ask ChatGPT for suggestions as if it was a travel agent",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"text/plain"
|
||||
],
|
||||
"tags": [
|
||||
"openai"
|
||||
],
|
||||
"summary": "Travel Agent ChatGPT",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Ask ChatGPT for suggestions as a travel agent",
|
||||
"name": "message",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "response",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/unraid/powerusage": {
|
||||
"get": {
|
||||
"description": "Gets the PSU Data from unraid",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"unraid"
|
||||
],
|
||||
"summary": "Unraid PSU Stats",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "response",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"securityDefinitions": {
|
||||
"ApiKeyAuth": {
|
||||
"description": "Description for what is this security definition being used",
|
||||
"type": "apiKey",
|
||||
"name": "Authorization",
|
||||
"in": "header"
|
||||
},
|
||||
"BasicAuth": {
|
||||
"type": "basic"
|
||||
},
|
||||
"OAuth2AccessCode": {
|
||||
"type": "oauth2",
|
||||
"flow": "accessCode",
|
||||
"authorizationUrl": "https://example.com/oauth/authorize",
|
||||
"tokenUrl": "https://example.com/oauth/token",
|
||||
"scopes": {
|
||||
"admin": "\t\t\t\t\t\t\tGrants read and write access to administrative information"
|
||||
}
|
||||
},
|
||||
"OAuth2Application": {
|
||||
"type": "oauth2",
|
||||
"flow": "application",
|
||||
"tokenUrl": "https://example.com/oauth/token",
|
||||
"scopes": {
|
||||
"admin": "\t\t\t\t\t\t\tGrants read and write access to administrative information",
|
||||
"write": "\t\t\t\t\t\t\tGrants write access"
|
||||
}
|
||||
},
|
||||
"OAuth2Implicit": {
|
||||
"type": "oauth2",
|
||||
"flow": "implicit",
|
||||
"authorizationUrl": "https://example.com/oauth/authorize",
|
||||
"scopes": {
|
||||
"admin": "\t\t\t\t\t\t\tGrants read and write access to administrative information",
|
||||
"write": "\t\t\t\t\t\t\tGrants write access"
|
||||
}
|
||||
},
|
||||
"OAuth2Password": {
|
||||
"type": "oauth2",
|
||||
"flow": "password",
|
||||
"tokenUrl": "https://example.com/oauth/token",
|
||||
"scopes": {
|
||||
"admin": "\t\t\t\t\t\t\tGrants read and write access to administrative information",
|
||||
"read": "\t\t\t\t\t\t\t\tGrants read access",
|
||||
"write": "\t\t\t\t\t\t\tGrants write access"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
110
docs/swagger.yaml
Normal file
110
docs/swagger.yaml
Normal file
@@ -0,0 +1,110 @@
|
||||
basePath: /api/v1
|
||||
host: localhost:8080
|
||||
info:
|
||||
contact:
|
||||
email: support@swagger.io
|
||||
name: API Support
|
||||
url: http://www.swagger.io/support
|
||||
description: This is a sample server celler server.
|
||||
license:
|
||||
name: Apache 2.0
|
||||
url: http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
termsOfService: http://swagger.io/terms/
|
||||
title: DurpAPI
|
||||
version: "1.0"
|
||||
paths:
|
||||
/openai/general:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Ask ChatGPT a general question
|
||||
parameters:
|
||||
- description: Ask ChatGPT a general question
|
||||
in: query
|
||||
name: message
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- text/plain
|
||||
responses:
|
||||
"200":
|
||||
description: response
|
||||
schema:
|
||||
type: string
|
||||
summary: Gerneral ChatGPT
|
||||
tags:
|
||||
- openai
|
||||
/openai/travelagent:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Ask ChatGPT for suggestions as if it was a travel agent
|
||||
parameters:
|
||||
- description: Ask ChatGPT for suggestions as a travel agent
|
||||
in: query
|
||||
name: message
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- text/plain
|
||||
responses:
|
||||
"200":
|
||||
description: response
|
||||
schema:
|
||||
type: string
|
||||
summary: Travel Agent ChatGPT
|
||||
tags:
|
||||
- openai
|
||||
/unraid/powerusage:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Gets the PSU Data from unraid
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: response
|
||||
schema:
|
||||
type: string
|
||||
summary: Unraid PSU Stats
|
||||
tags:
|
||||
- unraid
|
||||
securityDefinitions:
|
||||
ApiKeyAuth:
|
||||
description: Description for what is this security definition being used
|
||||
in: header
|
||||
name: Authorization
|
||||
type: apiKey
|
||||
BasicAuth:
|
||||
type: basic
|
||||
OAuth2AccessCode:
|
||||
authorizationUrl: https://example.com/oauth/authorize
|
||||
flow: accessCode
|
||||
scopes:
|
||||
admin: "\t\t\t\t\t\t\tGrants read and write access to administrative information"
|
||||
tokenUrl: https://example.com/oauth/token
|
||||
type: oauth2
|
||||
OAuth2Application:
|
||||
flow: application
|
||||
scopes:
|
||||
admin: "\t\t\t\t\t\t\tGrants read and write access to administrative information"
|
||||
write: "\t\t\t\t\t\t\tGrants write access"
|
||||
tokenUrl: https://example.com/oauth/token
|
||||
type: oauth2
|
||||
OAuth2Implicit:
|
||||
authorizationUrl: https://example.com/oauth/authorize
|
||||
flow: implicit
|
||||
scopes:
|
||||
admin: "\t\t\t\t\t\t\tGrants read and write access to administrative information"
|
||||
write: "\t\t\t\t\t\t\tGrants write access"
|
||||
type: oauth2
|
||||
OAuth2Password:
|
||||
flow: password
|
||||
scopes:
|
||||
admin: "\t\t\t\t\t\t\tGrants read and write access to administrative information"
|
||||
read: "\t\t\t\t\t\t\t\tGrants read access"
|
||||
write: "\t\t\t\t\t\t\tGrants write access"
|
||||
tokenUrl: https://example.com/oauth/token
|
||||
type: oauth2
|
||||
swagger: "2.0"
|
||||
Reference in New Issue
Block a user