-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redesign gocrane caching and configuration model (#16)
* wip: outline new digest-based idea * Improve flag setup * add project exploration * Add digest calculation * implement build command * implement run capability * remove unused package * update readme * add example * Use stat-based digest * Have gocrane run in alpine * Restore old flags behavior * Enhance file inclusion and exclusion * Extend over V2 branch with a new idea (#17) * Rework the README.md documentation * Apply suggestion Co-authored-by: Ivan Borshukov <[email protected]> * Apply suggestion Co-authored-by: Ivan Borshukov <[email protected]> Co-authored-by: Ivan Borshukov <[email protected]>
- Loading branch information
Showing
44 changed files
with
1,867 additions
and
675 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
name: Pull Request | ||
|
||
on: | ||
pull_request: | ||
branches: [ master ] | ||
on: [pull_request] | ||
|
||
jobs: | ||
build: | ||
name: Compile | ||
name: Verify | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v2 | ||
uses: actions/setup-go@v2.1.3 | ||
with: | ||
go-version: 1.16 | ||
|
||
- name: Build | ||
env: | ||
GO111MODULE: on | ||
run: go build -o gocrane . | ||
|
||
- name: Get Ginkgo | ||
run: go install github.com/onsi/ginkgo/ginkgo@latest | ||
|
||
- name: Run Tests | ||
run: ginkgo -r --race --randomizeAllSpecs --randomizeSuites |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM mokiat/gocrane:latest AS gocrane | ||
|
||
FROM golang:1.16 | ||
COPY --from=gocrane /bin/gocrane /bin/gocrane | ||
COPY . /src/project | ||
WORKDIR /src/project | ||
|
||
ENV GOCRANE_RESOURCES='./public' | ||
ENV GOCRANE_MAIN='./cmd/example' | ||
ENV GOCRANE_BINARY='/bin/example' | ||
RUN gocrane build -v | ||
|
||
CMD ["gocrane", "run", "-v"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"fmt" | ||
"log" | ||
"net/http" | ||
"os" | ||
"os/signal" | ||
"syscall" | ||
|
||
"github.com/mokiat/gocrane/example/internal" | ||
) | ||
|
||
func main() { | ||
mux := http.NewServeMux() | ||
mux.Handle("/", http.FileServer(http.Dir("./public"))) | ||
mux.Handle("/greet", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
fmt.Fprint(w, internal.Greet()) | ||
})) | ||
server := &http.Server{ | ||
Addr: "0.0.0.0:8080", | ||
Handler: mux, | ||
} | ||
|
||
log.Println("listening...") | ||
go func() { | ||
if err := server.ListenAndServe(); !errors.Is(err, http.ErrServerClosed) { | ||
log.Fatalf("http server error: %s\n", err) | ||
} | ||
}() | ||
|
||
sigChan := make(chan os.Signal, 1) | ||
signal.Notify(sigChan, syscall.SIGTERM, syscall.SIGINT) | ||
defer signal.Stop(sigChan) | ||
<-sigChan | ||
|
||
log.Println("shutting down...") | ||
if err := server.Shutdown(context.Background()); err != nil { | ||
log.Fatalf("failed to shutdown server: %w", err) | ||
} | ||
log.Println("good bye") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: '2.4' | ||
|
||
services: | ||
example: | ||
build: ./ | ||
image: 'example:latest' | ||
volumes: | ||
- "$PWD:/src/project" | ||
ports: | ||
- "8080:8080" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/mokiat/gocrane/example | ||
|
||
go 1.15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package internal | ||
|
||
func Greet() string { | ||
return "Hello World" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<html> | ||
<body> | ||
<h1>Hello World</h1> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.