forked from productiveops/dokemon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1bda1cb
commit e0c41bf
Showing
221 changed files
with
23,277 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Docker Image CI | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: ["*"] | ||
pull_request: | ||
branches: ["main"] | ||
|
||
env: | ||
VERSION: "1.2.1" | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Extract tag | ||
shell: bash | ||
run: echo "tag=`echo ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} | awk '{ if ($0 == "main") {print "latest"} else {print $0;} }'`" >> $GITHUB_OUTPUT | ||
id: extract_tag | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login to ProductiveOps Docker Hub Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERREGISTRY_USERNAME }} | ||
password: ${{ secrets.DOCKERREGISTRY_PASSWORD }} | ||
- name: Build and Push Server | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: "{{defaultContext}}" | ||
file: Dockerfile.server | ||
push: true | ||
platforms: linux/amd64,linux/arm64 | ||
tags: productiveops/dokemon:${{ steps.extract_tag.outputs.tag }}${{ steps.extract_tag.outputs.tag == 'latest' && format(' , productiveops/dokemon:{0}', env.VERSION) || '' }} | ||
- name: Build and Push Agent | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: "{{defaultContext}}" | ||
file: Dockerfile.agent | ||
push: true | ||
platforms: linux/amd64,linux/arm64 | ||
tags: productiveops/dokemon-agent:${{ steps.extract_tag.outputs.tag }}${{ steps.extract_tag.outputs.tag == 'latest' && format(' , productiveops/dokemon-agent:{0}', env.VERSION) || '' }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# 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 | ||
|
||
# App Binaries in root directory | ||
/agent | ||
/server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Launch Package", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"program": "cmd/server/main.go", | ||
"env": { | ||
"NODE": "127.0.0.1:9090", | ||
"ENCRYPTION_KEY": "ZsuCF1rjwC2FyNyWkdSvpjonetOIK7eOcgh3c2+Ognc=", | ||
"DB_CONNECTION_STRING": "root:Password123!@tcp(127.0.0.1:3306)", | ||
"RABBITMQ_URL": "amqp://user:password@127.0.0.1:5672", | ||
"DB_NAME": "kd_test" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
# Build the Go application | ||
FROM --platform=$BUILDPLATFORM golang:1.21 AS build-stage | ||
|
||
WORKDIR /temp | ||
|
||
ARG TARGETARCH | ||
RUN if [ "$TARGETARCH" = "amd64" ]; then \ | ||
wget https://download.docker.com/linux/static/stable/x86_64/docker-24.0.7.tgz; \ | ||
fi | ||
ARG TARGETARCH | ||
RUN if [ "$TARGETARCH" = "arm64" ]; then \ | ||
wget https://download.docker.com/linux/static/stable/aarch64/docker-24.0.7.tgz; \ | ||
fi | ||
RUN cd /bin && tar xvzf /temp/docker-24.0.7.tgz --strip-components 1 docker/docker | ||
ARG TARGETARCH | ||
RUN if [ "$TARGETARCH" = "amd64" ]; then \ | ||
curl -SL https://github.com/docker/compose/releases/download/v2.23.3/docker-compose-linux-x86_64 -o /bin/docker-compose; \ | ||
fi | ||
ARG TARGETARCH | ||
RUN if [ "$TARGETARCH" = "arm64" ]; then \ | ||
curl -SL https://github.com/docker/compose/releases/download/v2.23.3/docker-compose-linux-aarch64 -o /bin/docker-compose; \ | ||
fi | ||
RUN chmod 755 /bin/docker-compose | ||
|
||
WORKDIR /app | ||
|
||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
|
||
COPY . ./ | ||
|
||
ARG TARGETOS TARGETARCH | ||
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /dokemon-agent ./cmd/agent | ||
|
||
RUN mkdir -p /data | ||
|
||
# Deploy the application binary into a lean image | ||
FROM --platform=$BUILDPLATFORM gcr.io/distroless/base-debian11 AS build-release-stage | ||
|
||
WORKDIR / | ||
|
||
COPY --from=build-stage /dokemon-agent /dokemon-agent | ||
COPY --from=build-stage /data /data | ||
COPY --from=build-stage /bin/docker /bin/docker | ||
COPY --from=build-stage /bin/docker-compose /bin/docker-compose | ||
|
||
ENTRYPOINT ["/dokemon-agent"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
# Build the React application | ||
FROM node:18-alpine AS base | ||
FROM base AS deps | ||
RUN apk add --no-cache libc6-compat | ||
WORKDIR /app | ||
COPY web/package.json web/yarn.lock* web/package-lock.json* web/pnpm-lock.yaml* ./ | ||
RUN \ | ||
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ | ||
elif [ -f package-lock.json ]; then npm ci; \ | ||
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \ | ||
else echo "Lockfile not found." && exit 1; \ | ||
fi | ||
# Rebuild the source code only when needed | ||
FROM base AS react-builder | ||
WORKDIR /app | ||
COPY --from=deps /app/node_modules ./node_modules | ||
COPY ./web . | ||
RUN npm run build | ||
|
||
# Build the Go application | ||
FROM --platform=$BUILDPLATFORM golang:1.21 AS build-stage | ||
RUN go install github.com/GeertJohan/go.rice/rice@latest | ||
|
||
WORKDIR /temp | ||
|
||
ARG TARGETARCH | ||
RUN if [ "$TARGETARCH" = "amd64" ]; then \ | ||
wget https://download.docker.com/linux/static/stable/x86_64/docker-24.0.7.tgz; \ | ||
fi | ||
ARG TARGETARCH | ||
RUN if [ "$TARGETARCH" = "arm64" ]; then \ | ||
wget https://download.docker.com/linux/static/stable/aarch64/docker-24.0.7.tgz; \ | ||
fi | ||
RUN cd /bin && tar xvzf /temp/docker-24.0.7.tgz --strip-components 1 docker/docker | ||
ARG TARGETARCH | ||
RUN if [ "$TARGETARCH" = "amd64" ]; then \ | ||
curl -SL https://github.com/docker/compose/releases/download/v2.23.3/docker-compose-linux-x86_64 -o /bin/docker-compose; \ | ||
fi | ||
ARG TARGETARCH | ||
RUN if [ "$TARGETARCH" = "arm64" ]; then \ | ||
curl -SL https://github.com/docker/compose/releases/download/v2.23.3/docker-compose-linux-aarch64 -o /bin/docker-compose; \ | ||
fi | ||
RUN chmod 755 /bin/docker-compose | ||
|
||
WORKDIR /app | ||
|
||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
|
||
COPY . ./ | ||
COPY --from=react-builder /app/dist ./web/dist | ||
|
||
RUN $GOPATH/bin/rice embed-go -i ./web | ||
|
||
ARG TARGETOS TARGETARCH | ||
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /dokemon ./cmd/server | ||
|
||
RUN mkdir -p /data | ||
|
||
# Deploy the application binary into a lean image | ||
FROM --platform=$BUILDPLATFORM gcr.io/distroless/base-debian11 AS build-release-stage | ||
|
||
WORKDIR / | ||
|
||
COPY --from=build-stage /dokemon /dokemon | ||
COPY --from=build-stage /data /data | ||
COPY --from=build-stage /bin/docker /bin/docker | ||
COPY --from=build-stage /bin/docker-compose /bin/docker-compose | ||
|
||
EXPOSE 9090 | ||
|
||
ENTRYPOINT ["/dokemon"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (c) 2023 Salil Ponde | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the “Software”), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package main | ||
|
||
import "dokemon/pkg/agent" | ||
|
||
func main() { | ||
agent.Main() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package main | ||
|
||
import ( | ||
"dokemon/pkg/server" | ||
"os" | ||
) | ||
|
||
func main() { | ||
s := server.Server{} | ||
s.Init( | ||
os.Getenv("DB_CONNECTION_STRING"), | ||
os.Getenv("DATA_PATH"), | ||
os.Getenv("LOG_LEVEL"), | ||
) | ||
s.Run(os.Getenv("BIND_ADDRESS")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
module dokemon | ||
|
||
go 1.21 | ||
|
||
require ( | ||
github.com/GeertJohan/go.rice v1.0.3 | ||
github.com/docker/docker v24.0.7+incompatible | ||
github.com/glebarez/sqlite v1.10.0 | ||
github.com/go-playground/validator/v10 v10.14.0 | ||
github.com/google/uuid v1.4.0 | ||
github.com/gorilla/websocket v1.5.1 | ||
github.com/labstack/echo/v4 v4.11.3 | ||
github.com/labstack/gommon v0.4.0 | ||
github.com/rs/zerolog v1.31.0 | ||
golang.org/x/crypto v0.16.0 | ||
gorm.io/gorm v1.25.5 | ||
) | ||
|
||
require ( | ||
github.com/Microsoft/go-winio v0.6.1 // indirect | ||
github.com/daaku/go.zipexe v1.0.2 // indirect | ||
github.com/distribution/reference v0.5.0 // indirect | ||
github.com/docker/distribution v2.8.3+incompatible // indirect | ||
github.com/docker/go-connections v0.4.0 // indirect | ||
github.com/docker/go-units v0.5.0 // indirect | ||
github.com/dustin/go-humanize v1.0.1 // indirect | ||
github.com/gabemarshall/pty v0.0.0-20220927143247-d84f0bb0c17e // indirect | ||
github.com/gabriel-vasile/mimetype v1.4.2 // indirect | ||
github.com/glebarez/go-sqlite v1.21.2 // indirect | ||
github.com/go-playground/locales v0.14.1 // indirect | ||
github.com/go-playground/universal-translator v0.18.1 // indirect | ||
github.com/gogo/protobuf v1.3.2 // indirect | ||
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect | ||
github.com/jinzhu/inflection v1.0.0 // indirect | ||
github.com/jinzhu/now v1.1.5 // indirect | ||
github.com/leodido/go-urn v1.2.4 // indirect | ||
github.com/mattn/go-colorable v0.1.13 // indirect | ||
github.com/mattn/go-isatty v0.0.20 // indirect | ||
github.com/moby/term v0.5.0 // indirect | ||
github.com/morikuni/aec v1.0.0 // indirect | ||
github.com/opencontainers/go-digest v1.0.0 // indirect | ||
github.com/opencontainers/image-spec v1.0.2 // indirect | ||
github.com/pkg/errors v0.9.1 // indirect | ||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect | ||
github.com/valyala/bytebufferpool v1.0.0 // indirect | ||
github.com/valyala/fasttemplate v1.2.2 // indirect | ||
golang.org/x/mod v0.8.0 // indirect | ||
golang.org/x/net v0.17.0 // indirect | ||
golang.org/x/sys v0.15.0 // indirect | ||
golang.org/x/text v0.14.0 // indirect | ||
golang.org/x/time v0.3.0 // indirect | ||
golang.org/x/tools v0.6.0 // indirect | ||
gotest.tools/v3 v3.5.1 // indirect | ||
modernc.org/libc v1.22.5 // indirect | ||
modernc.org/mathutil v1.5.0 // indirect | ||
modernc.org/memory v1.5.0 // indirect | ||
modernc.org/sqlite v1.23.1 // indirect | ||
) |
Oops, something went wrong.