mikemadisonweb / go-autoreload-example Goto Github PK
View Code? Open in Web Editor NEWGolang auto reload within Docker containers
Home Page: https://mikemadisonweb.github.io/2018/03/06/go-autoreload/
Golang auto reload within Docker containers
Home Page: https://mikemadisonweb.github.io/2018/03/06/go-autoreload/
Directory structure
test
|-app
|--app_settings
|---log_wrapper.go
|--root
|---entrypoint.sh
|--Dockerfile
|--main.go
|-.env
|-docker-compose.yaml
Dockerfile looks like :-
FROM golang:1.9-alpine
COPY ./root /
COPY ./app_settings/ /go/src/app_settings/
RUN apk add --no-cache ca-certificates \
dpkg \
gcc \
git \
musl-dev \
bash
ENV GOPATH /go
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" \
&& chmod -R 777 "$GOPATH" \
&& chmod +x /entrypoint.sh
# RUN go get github.com/tockins/realize #<---placing this code giving me the error ERROR: Service 'app' #failed to build: The command '/bin/sh -c go install -v ./...' returned a non-zero code: 1
RUN go get -d -v ./...
RUN go install -v ./...
RUN go get github.com/tockins/realize #works fine here but when i output realize.yaml which is #created in root directory gives me output mentioned below (which is same as your common app)
WORKDIR $GOPATH
ENTRYPOINT ["/entrypoint.sh"]
EXPOSE 8080
CMD ["realize", "start"]
docker-compose.yaml
version: '3'
services:
app:
container_name: "app"
build: "./app/"
volumes:
- ".:${GO_PROJECT_DIR}"
ports:
- "8080:8080"
environment:
GO_WORK_DIR: "${GO_PROJECT_DIR}/app"
main.go
import (
l "app_settings/log_wrapper"
"fmt"
"io/ioutil"
"os"
"github.com/qiangxue/fasthttp-routing"
"github.com/valyala/fasthttp"
)
func main() {
l.Init(ioutil.Discard, os.Stdout, os.Stdout, os.Stderr)
l.Trace.Println("I have something standard to say")
l.Info.Println("Special Information")
l.Warning.Println("There is something you need to know about")
l.Error.Println("Something has failed")
router := routing.New()
router.Get("/", func(c *routing.Context) error {
fmt.Fprintf(c, "UP, and running with golang app!")
l.Info.Println("fasthttp, Hello, Go!")
return nil
})
panic(fasthttp.ListenAndServe(":8080", router.HandleRequest))
}
entrypoint.sh
#!/usr/bin/env bash
GO_WORK_DIR=${GO_WORK_DIR:-$GOPATH/src}
cd ${GO_WORK_DIR}
cd root && ls -a && exec "$@"
.realize.yaml output
app | legacy:
app | force: false
app | interval: 0s
app | server:
app | status: false
app | open: false
app | port: 5002
app | host: localhost
app | schema:
app | - name: app
app | path: .
app | commands:
app | run:
app | status: true
app | watcher:
app | paths:
app | - /
app | - ./../common
app | extensions:
app | - go
app | - html
app | - css
app | - js
app | - yaml
output of the above code base
[22:33:04][ROOT] : Watching 0 file/s 1 folder/s
but the changes made in main.go is not reflected, furthermore there seems to be some issue with the post as well.
I am still a newbie with go, try to bring up my own go test app. Any help would be appreciated. thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.