Skip to content

Commit caf0600

Browse files
2 parents bb3e7bd + 88a8cea commit caf0600

File tree

8 files changed

+27
-81
lines changed

8 files changed

+27
-81
lines changed

Dockerfile

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
#build stage
2-
FROM golang:1.10.3-alpine AS build-env
3-
ENV GOPROXY=https://gocenter.io
4-
ADD . /src
5-
RUN cd /src && go build -o myapp
6-
7-
# iron/go is the alpine image with only ca-certificates added
8-
FROM alpine
9-
#RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.1/main' >> /etc/apk/repositories
10-
#RUN apk add "openssh==6.7_p1-r6"
11-
#added just to get security vulnerabilities in
12-
# RUN apk add openssh
1+
FROM golang:1.16-alpine3.13 AS build-env
2+
3+
WORKDIR /tmp/workdir
4+
5+
COPY . .
6+
7+
RUN CGO_ENABLED=0 GOOS=linux go build
8+
9+
FROM alpine:3.13
10+
11+
EXPOSE 8080
12+
13+
RUN apk add --no-cache ca-certificates bash
14+
15+
COPY --from=build-env /tmp/workdir/static /app/static
16+
COPY --from=build-env /tmp/workdir/canary-app /app/canary-app
17+
1318
WORKDIR /app
14-
COPY --from=build-env /src/myapp /app/
15-
ENTRYPOINT ["./myapp"]
19+
20+
CMD ["./canary-app"]

app.go

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,23 @@
11
package main
2-
2+
33
import (
4-
"os"
54
"fmt"
65
"net/http"
7-
// "github.com/golangci/golangci-lint/pkg/exitcodes"
86
)
97

108
func main() {
119

12-
//Add a GPL3 package to cause havock
13-
// os.Setenv("test", string(exitcodes.Success))
14-
10+
version := "1.0"
1511

16-
c := os.Getenv("COLOR")
17-
if len(c) == 0{
18-
// os.Setenv("COLOR", "#44B3C2") //Blue 44B3C2 and Yellow F1A94E
19-
os.Setenv("COLOR", "#F1A94E") //Blue 44B3C2 and Yellow F1A94E
20-
}
12+
color := "#44B3C2" //Blue 44B3C2 and Yellow F1A94E
2113

22-
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
23-
fmt.Fprintf(w, "<html onclick=\"window.location.href = '/die'\" style='background:" + os.Getenv("COLOR") + "'> Requested: %s\n </html>", r.URL.Path)
14+
http.HandleFunc("/callme", func(w http.ResponseWriter, r *http.Request) {
15+
fmt.Fprintf(w, "<div class='pod' style='background:%s'> ver: %s\n </div>", color, version)
2416
})
2517

26-
http.HandleFunc("/dashboard", func(w http.ResponseWriter, r *http.Request) {
27-
fmt.Fprintf(w, "<html> DASHBOARD Requested: %s\n </html>", r.URL.Path)
28-
})
29-
30-
http.HandleFunc("/die", func(w http.ResponseWriter, r *http.Request) {
31-
die();
32-
})
18+
fs := http.FileServer(http.Dir("./static"))
19+
http.Handle("/", fs)
3320

21+
fmt.Println("Listening now at port 8080")
3422
http.ListenAndServe(":8080", nil)
3523
}
36-
37-
func die() {
38-
os.Exit(3)
39-
}
File renamed without changes.

source-code-canary/Dockerfile

Lines changed: 0 additions & 20 deletions
This file was deleted.

source-code-canary/app.go

Lines changed: 0 additions & 23 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)