File tree Expand file tree Collapse file tree 4 files changed +15
-83
lines changed Expand file tree Collapse file tree 4 files changed +15
-83
lines changed Original file line number Diff line number Diff line change 1- FROM golang:1.19-alpine AS base
1+ # syntax=docker/dockerfile:1
2+
3+ FROM golang:alpine AS base
24ENV CGO_ENABLED=0
35RUN apk add --no-cache file git
46WORKDIR /src
57
6- FROM base as build
7- COPY go.mod go.sum ./
8- RUN go mod download -x
9- COPY . .
10- RUN go build -ldflags "-s -w" -o /usr/bin/app .
8+ FROM base AS build
9+ RUN --mount=type=bind,target=/src \
10+ --mount=type=cache,target=/root/.cache/go-build \
11+ go build -ldflags "-s -w" -o /usr/bin/app .
1112
1213FROM scratch AS binary
1314COPY --from=build /usr/bin/app /bin/app
1415
15- FROM alpine:3.17 AS image
16+ FROM alpine AS image
1617COPY --from=build /usr/bin/app /bin/app
18+ EXPOSE 8080
19+ ENTRYPOINT ["/bin/app" ]
Original file line number Diff line number Diff line change 11module github.com/docker/build-push-action/test/go
22
33go 1.18
4-
5- require github.com/labstack/echo/v4 v4.9.1
6-
7- require (
8- github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
9- github.com/labstack/gommon v0.4.0 // indirect
10- github.com/mattn/go-colorable v0.1.11 // indirect
11- github.com/mattn/go-isatty v0.0.14 // indirect
12- github.com/valyala/bytebufferpool v1.0.0 // indirect
13- github.com/valyala/fasttemplate v1.2.1 // indirect
14- golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
15- golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f // indirect
16- golang.org/x/sys v0.0.0-20211103235746-7861aae1554b // indirect
17- golang.org/x/text v0.3.7 // indirect
18- golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 // indirect
19- )
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11package main
22
33import (
4+ "fmt"
5+ "log"
46 "net/http"
5- "os"
6-
7- "github.com/labstack/echo/v4"
8- "github.com/labstack/echo/v4/middleware"
97)
108
119func main () {
12- e := echo .New ()
13-
14- e .Use (middleware .Logger ())
15- e .Use (middleware .Recover ())
16-
17- e .GET ("/" , func (c echo.Context ) error {
18- return c .HTML (http .StatusOK , "Hello World" )
10+ http .HandleFunc ("/" , func (w http.ResponseWriter , r * http.Request ) {
11+ fmt .Fprintf (w , "Hello, Go!" )
1912 })
20-
21- e .GET ("/ping" , func (c echo.Context ) error {
22- return c .JSON (http .StatusOK , struct { Status string }{Status : "OK" })
23- })
24-
25- httpPort := os .Getenv ("HTTP_PORT" )
26- if httpPort == "" {
27- httpPort = "8080"
28- }
29-
30- e .Logger .Fatal (e .Start (":" + httpPort ))
13+ log .Fatal (http .ListenAndServe (":8080" , nil ))
3114}
You can’t perform that action at this time.
0 commit comments