-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: CrazyMax <[email protected]>
- Loading branch information
Showing
4 changed files
with
15 additions
and
83 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
FROM golang:1.19-alpine AS base | ||
# syntax=docker/dockerfile:1 | ||
|
||
FROM golang:alpine AS base | ||
ENV CGO_ENABLED=0 | ||
RUN apk add --no-cache file git | ||
WORKDIR /src | ||
|
||
FROM base as build | ||
COPY go.mod go.sum ./ | ||
RUN go mod download -x | ||
COPY . . | ||
RUN go build -ldflags "-s -w" -o /usr/bin/app . | ||
FROM base AS build | ||
RUN --mount=type=bind,target=/src \ | ||
--mount=type=cache,target=/root/.cache/go-build \ | ||
go build -ldflags "-s -w" -o /usr/bin/app . | ||
|
||
FROM scratch AS binary | ||
COPY --from=build /usr/bin/app /bin/app | ||
|
||
FROM alpine:3.17 AS image | ||
FROM alpine AS image | ||
COPY --from=build /usr/bin/app /bin/app | ||
EXPOSE 8080 | ||
ENTRYPOINT ["/bin/app"] |
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,19 +1,3 @@ | ||
module github.com/docker/bake-action/test/go | ||
|
||
go 1.18 | ||
|
||
require github.com/labstack/echo/v4 v4.9.1 | ||
|
||
require ( | ||
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect | ||
github.com/labstack/gommon v0.4.0 // indirect | ||
github.com/mattn/go-colorable v0.1.11 // indirect | ||
github.com/mattn/go-isatty v0.0.14 // indirect | ||
github.com/valyala/bytebufferpool v1.0.0 // indirect | ||
github.com/valyala/fasttemplate v1.2.1 // indirect | ||
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect | ||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f // indirect | ||
golang.org/x/sys v0.0.0-20211103235746-7861aae1554b // indirect | ||
golang.org/x/text v0.3.7 // indirect | ||
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 // indirect | ||
) |
This file was deleted.
Oops, something went wrong.
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,31 +1,14 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"net/http" | ||
"os" | ||
|
||
"github.com/labstack/echo/v4" | ||
"github.com/labstack/echo/v4/middleware" | ||
) | ||
|
||
func main() { | ||
e := echo.New() | ||
|
||
e.Use(middleware.Logger()) | ||
e.Use(middleware.Recover()) | ||
|
||
e.GET("/", func(c echo.Context) error { | ||
return c.HTML(http.StatusOK, "Hello World") | ||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | ||
fmt.Fprintf(w, "Hello, Go!") | ||
}) | ||
|
||
e.GET("/ping", func(c echo.Context) error { | ||
return c.JSON(http.StatusOK, struct{ Status string }{Status: "OK"}) | ||
}) | ||
|
||
httpPort := os.Getenv("HTTP_PORT") | ||
if httpPort == "" { | ||
httpPort = "8080" | ||
} | ||
|
||
e.Logger.Fatal(e.Start(":" + httpPort)) | ||
log.Fatal(http.ListenAndServe(":8080", nil)) | ||
} |