Skip to content

Commit

Permalink
Open-source
Browse files Browse the repository at this point in the history
  • Loading branch information
salilponde committed Dec 17, 2023
1 parent 1bda1cb commit e0c41bf
Show file tree
Hide file tree
Showing 221 changed files with 23,277 additions and 3 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/main.yml
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) || '' }}
25 changes: 25 additions & 0 deletions .gitignore
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
22 changes: 22 additions & 0 deletions .vscode/launch.json
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"
}
}
]
}
49 changes: 49 additions & 0 deletions Dockerfile.agent
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"]
74 changes: 74 additions & 0 deletions Dockerfile.server
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"]
19 changes: 19 additions & 0 deletions LICENSE
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.
30 changes: 27 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
![Alt text](/screenshots/dokemon-light.svg?raw=true "Dokemon Logo")

# Dokémon

Dokémon is a friendly GUI for managing Docker Containers on Virtual Machines.
Dokémon is a friendly GUI for managing Docker Containers. You can manage multiple servers from a single Dokemon instance.

**Website URL:** https://dokemon.dev
Check https://dokemon.dev for more details.

## Quickstart

Expand Down Expand Up @@ -64,10 +66,32 @@ This is an example configuration for running Dokémon behind Traefik with LetsEn
- ./dokemondata:/data
- /var/run/docker.sock:/var/run/docker.sock

In your DNS settings for you domain add an A record for the _Host_ which you have mentioned in the above config. The A record should point to the public IP address of your virtual machine.
In the DNS settings for your domain, add an A record for the _Host_ which you have mentioned in the above config. The A record should point to the public IP address of your virtual machine.

1. Create a file named `compose.yaml` on your server. Copy and paste the above YAML definition into the file. Modify the email and host. Make any other changes as per your requirements.
2. Run `mkdir ./letsencrypt && mkdir ./dokemondata`
3. Run `docker compose up -d`

Open https://dokemon.example.com (substitute your URL here which you entered as Host in the compose.yaml file) in the browser. It can take a few seconds for the SSL certificate to be provisioned. If you get an error related to SSL, please wait for a few moments and then refresh your browser.

## Screenshots

### Manage Multiple Servers

![Alt text](/screenshots/screenshot-dokemon-nodes.jpg?raw=true "Dokemon Nodes")

### Manage Variables for Different Environments

![Alt text](/screenshots/screenshot-dokemon-variables.jpg?raw=true "Dokemon Variables")

### Deploy Compose Projects

![Alt text](/screenshots/screenshot-dokemon-compose-up.jpg?raw=true "Dokemon Compose Up")

### Manage Containers, Images, Volumes, Networks

![Alt text](/screenshots/screenshot-dokemon-containers.jpg?raw=true "Dokemon Containers")

## License

This project is [MIT Licensed](LICENSE).
7 changes: 7 additions & 0 deletions cmd/agent/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "dokemon/pkg/agent"

func main() {
agent.Main()
}
16 changes: 16 additions & 0 deletions cmd/server/main.go
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"))
}
58 changes: 58 additions & 0 deletions go.mod
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
)
Loading

0 comments on commit e0c41bf

Please sign in to comment.