Modified codes to enable golang app in golang docker

docker-dev-guide_2
jason.zhu 2021-02-08 11:40:44 +11:00
parent fa93d79b01
commit 89a64c6a6f
4 changed files with 41 additions and 1 deletions

View File

@ -17,6 +17,14 @@ services:
container_name: golang container_name: golang
image: cruxlight/golang_sdk:1.0.0 image: cruxlight/golang_sdk:1.0.0
build: ./golang build: ./golang
working_dir: /work
entrypoint: /bin/sh
stdin_open: true
tty: true
volumes:
- ./golang/src/:/work
ports:
- 5501:5000
nodejs: nodejs:
container_name: nodejs container_name: nodejs
image: cruxlight/nodejs:1.0.0 image: cruxlight/nodejs:1.0.0

View File

@ -1 +1,9 @@
FROM golang:1.12.5-alpine3.9 as builder FROM golang:1.12.5-alpine3.9 as builder
# installing git
RUN apk update && apk upgrade && \
apk add --no-cache git
RUN go get github.com/sirupsen/logrus
RUN go get github.com/buaazp/fasthttprouter
RUN go get github.com/valyala/fasthttp

24
golang/src/main.go 100644
View File

@ -0,0 +1,24 @@
package main
import (
"fmt" //to print messages to stdout
"log" //logging :)
//our web server that will host the mock
"github.com/buaazp/fasthttprouter"
"github.com/valyala/fasthttp"
)
var searchMock []byte
func Response(ctx *fasthttp.RequestCtx) {
fmt.Fprintf(ctx, "Hello")
}
func main() {
fmt.Println("starting.")
router := fasthttprouter.New()
router.GET("/", Response)
log.Fatal(fasthttp.ListenAndServe(":5000", router.Handler))
}

BIN
golang/src/work 100644

Binary file not shown.