Skip to content

bitxeno/go-docker-skeleton

Repository files navigation

go-docker-skeleton

release image size license

Skeleton for run go service in docker

Prerequisite

  • Go 1.21+
  • Node.js 20+
  • Vue3 + daisyUI

How To Start

  1. copy all file to project directory
  2. replace all github.com/bitxeno/go-docker-skeleton string to your repo
  3. update AppName and AppDesc variables in main.go
  4. execute shell:
# open shell #1:
# for frontend hot reload
cd web/static
npm install
npm run dev

# open shell #2:
go mod tidy
go run . server -vv
# or hot reload with go 1.22+
go install github.com/air-verse/air@latest
air -c .air.toml

How to integrated with vue-admin-template

rm -rf web/static
git clone --depth=1 https://github.com/PanJiaChen/vue-admin-template.git web/static
cd web/static
rm -rf ./.git
npm install

chnage package.json dev script to:

"dev": "vue-cli-service build --watch --mode production",

How to push DockerHub

  1. register dockerhub and create a repo
  2. on Dockerhub, goto Account Settings -> Security create aceess token
  3. on Github, goto repo Settings -> Secrets and add three github action variables
DOCKER_USERNAME
DOCKER_TOKEN
DOCKER_REPOSITORY

Run on Docker

docker run -d --name=app-name --restart=always -p 8080:80  -v /path/to/config/dir:/data xxxx/app-name

Awesome Go Library

  • goutil: Helper Utils(600+)
  • lo: samber/lo is a Lodash-style Go library based on Go 1.18+ Generics.
  • validator: Package validator implements value validations for structs and individual fields based on tags.
  • gods: GoDS (Go Data Structures) - Sets, Lists, Stacks, Maps, Trees, Queues, and much more
  • orderedmap: An ordered map in Go with amortized O(1) for Set, Get, Delete and Len.
  • cron: a cron library for go
  • gocron: Easy and fluent Go cron scheduling.
  • gjson: Get JSON values quickly - JSON parser for Go
  • ristretto: A high performance memory-bound Go cache
  • theine-go: High performance in-memory & hybrid cache with generics support
  • emitter: Emits events in Go way, with wildcard, predicates, cancellation possibilities and many other good wins
  • event: Lightweight event manager and dispatcher implements by Go
  • asynq: Simple, reliable, and efficient distributed task queue in Go
  • goja: ECMAScript/JavaScript engine in pure Go
  • do: ⚙️ A dependency injection toolkit based on Go 1.18+ Generics.
  • errors: errors with stacktraces for go
  • purego: A library for calling C functions from Go without Cgo.
  • go-i18n: Translate your Go program into multiple languages

Awesome Javascript Library

  • vue-sonner: 🔔 An opinionated toast component for Vue.
  • auto-animate: A zero-config, drop-in animation utility that adds smooth transitions to your web app.