Skip to content

Commit bafb403

Browse files
committed
Totally the initial commit
0 parents  commit bafb403

28 files changed

+4682
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.idea
2+
bin
3+
.DS_Store

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
build-bins:
2+
mkdir -p bin && \
3+
cd backend && \
4+
GOOS=linux GOARCH=amd64 go build -o ../bin/backend ./... && \
5+
cd ../frontend && \
6+
GOOS=linux GOARCH=amd64 go build -o ../bin/frontend ./...

backend/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# syntax=docker/dockerfile:1
2+
3+
FROM golang:1.17-alpine as builder
4+
WORKDIR /app
5+
COPY . .
6+
RUN go mod download
7+
RUN go build -o ./backend
8+
9+
FROM alpine:3.15.0
10+
RUN apk add --no-cache curl
11+
RUN apk add --no-cache openssl
12+
COPY --from=builder /app/backend /bin/backend
13+
ENV GIN_MODE=release
14+
ENTRYPOINT ["/bin/backend"]

backend/birds.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package main
2+
3+
import (
4+
_ "embed"
5+
"encoding/json"
6+
"log"
7+
)
8+
9+
//go:embed birds.json
10+
var birdData []byte
11+
12+
//go:embed canaries.json
13+
var canaryData []byte
14+
15+
type birdRawData struct {
16+
Title string `json:"title"`
17+
Thumbnail struct {
18+
Source string `json:"source"`
19+
} `json:"thumbnail"`
20+
ExtractHTML string `json:"extract_html"`
21+
}
22+
23+
// birds returns a list of birds parsed from birds.json.
24+
func birds() []birdRawData {
25+
var birdList []birdRawData
26+
if err := json.Unmarshal(birdData, &birdList); err != nil {
27+
log.Fatalf("unable to parse birds.json: %s\n", err)
28+
}
29+
return birdList
30+
}
31+
32+
// canaries returns a list of canaries parsed from canaries.json.
33+
func canaries() []birdRawData {
34+
var canaryList []birdRawData
35+
if err := json.Unmarshal(canaryData, &canaryList); err != nil {
36+
log.Fatalf("unable to parse canaries.json: %s\n", err)
37+
}
38+
return canaryList
39+
}

backend/birds.json

Lines changed: 1717 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)