Skip to content

Latest commit

 

History

History
75 lines (61 loc) · 5.15 KB

README.md

File metadata and controls

75 lines (61 loc) · 5.15 KB

golang-example

This project enable you to build golang application

Inspired by

Golang Docker Official Images

Use multi-stage builds with Golang

A OpenID / Keycloak Proxy service written in golang

Official Golang website: The Go Programming Language

Create the smallest and secured golang docker image based on scratch

Package build

This project get soure code from

Possible direction

Branch

  • keycloak-gatekeeper
  • go-kit (Failed, do not use)
  • gin-and-gorm-rest-api (based on project )
    • Using tableplus, GUI and SQLite3
    • Using sqlite3
    • import mod from local path
    • using go lang viper and godotenv and go env var from medium
    • Need to remove the volume by docker volume ls and docker volume rm <uuid>
    • The Gorm seem faulty, need to add the key words: sslmode:disable, see more info
    • Great help from here
    • Start project
      • go mod init
      • go mod vendor
      • go run main.go
    • Deploy into Kubernetes
    • Using go mod download to speed up Golang Docker builds
    • Using Power environment
      • docker network create golang-example
      • docker run -d -e POSTGRES_DB=postgres -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=example --name postgres --network golang-example --mount source=prosgret-vol,destination=/var/lib/postgresql/data -p 5432:5432 postgres:latest
      • docker run -d -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=example -e POSTGRES_DB=postgres -e POSTGRES_HOST=postgres -e POSTGRES_PORT=5432 --network golang-example --name golang-example -p 8080:8080 moxing9876/golang-example:0.0.3
        • example output
        CONTAINER ID        IMAGE                             COMMAND                  CREATED             STATUS              PORTS                    NAMES
        9168b3afde13        moxing9876/golang-example:0.0.3   "/go/bin/hello"          4 seconds ago       Up 3 seconds        0.0.0.0:8080->8080/tcp   golang-example
        6949a79586fb        postgres:latest                   "docker-entrypoint.s…"   6 minutes ago       Up 6 minutes        0.0.0.0:5432->5432/tcp   postgres
        
      • $ curl http://localhost:8080/books
        • example output :
        {"data":[{"id":1,"title":"title1","author":"author1"},{"id":2,"title":"title1","author":"author1"}]}