forked from LelouchFR/skill-icons
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
29 lines (21 loc) · 1.15 KB
/
Copy pathDockerfile
File metadata and controls
29 lines (21 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
FROM golang:latest AS builder
WORKDIR /app
COPY api/index.go /app/api/index.go
COPY build.go /app/build.go
COPY assets/ /app/assets/
COPY go.mod /app/go.mod
COPY go.sum /app/go.sum
RUN sed -i \
-e 's/package handler/package main/' \
-e '/var app \*gin.Engine/d' \
-e '/func init() {/,/^}/d' \
-e '/func Handler(/,/^}/d' \
api/index.go && \
printf '\nfunc main() {\n gin.SetMode(gin.ReleaseMode)\n app := gin.New()\n r := app.Group("/api")\n iconRoute(r)\n\n decoder := json.NewDecoder(strings.NewReader(iconsJSON))\n if err := decoder.Decode(&icons); err != nil {\n panic(err)\n }\n\n for key := range icons {\n iconNameList = append(iconNameList, strings.Split(key, "-")[0])\n if strings.Contains(key, "-light") || strings.Contains(key, "-dark") || strings.Contains(key, "-auto") {\n themedIcons = append(themedIcons, strings.Split(key, "-")[0])\n }\n }\n\n app.Run()\n}\n' >> api/index.go
RUN go mod tidy
RUN go run build.go
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix nocgo -ldflags="-s -w" -o skillicons ./api/index.go
FROM scratch
COPY --from=builder /app/skillicons /skillicons
EXPOSE 8080
ENTRYPOINT ["/skillicons"]