Merge branch 'hotfix/220518_docker_deploy_minimalize' into 'main'
HOTFIX: Change docker golang image golang:1.17.3 -> golang:1.17.3-alpine build with multi stage build in alpine add chromium in alpine image See merge request !11
Showing
4 changed files
with
15 additions
and
6 deletions
1 | -FROM golang:1.17.3 | 1 | +FROM golang:1.17.3-alpine AS builder |
2 | 2 | ||
3 | WORKDIR /src | 3 | WORKDIR /src |
4 | COPY . /src | 4 | COPY . /src |
5 | 5 | ||
6 | -RUN apt-get update | 6 | +RUN go build -o joongna_api_server |
7 | -RUN apt-get install -y libgconf-2-4 libatk1.0-0 libatk-bridge2.0-0 libgdk-pixbuf2.0-0 libgtk-3-0 libgbm-dev libnss3-dev libxss-dev libasound2 | 7 | + |
8 | -RUN go build -o Joongna_api_server | 8 | +FROM alpine |
9 | + | ||
10 | +WORKDIR /src | ||
11 | +COPY --from=builder /src/joongna_api_server /src/joongna_api_server | ||
12 | +COPY --from=builder /src/config/.env /src/config/.env | ||
13 | + | ||
14 | +RUN apk add chromium | ||
9 | 15 | ||
10 | EXPOSE 8080 | 16 | EXPOSE 8080 |
11 | -CMD ["./Joongna_api_server"] | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
17 | +CMD ["./joongna_api_server"] | ... | ... |
joongna/deploy.sh
100644 → 100755
File mode changed
... | @@ -17,6 +17,7 @@ import ( | ... | @@ -17,6 +17,7 @@ import ( |
17 | 17 | ||
18 | "github.com/PuerkitoBio/goquery" | 18 | "github.com/PuerkitoBio/goquery" |
19 | "github.com/go-rod/rod" | 19 | "github.com/go-rod/rod" |
20 | + "github.com/go-rod/rod/lib/launcher" | ||
20 | ) | 21 | ) |
21 | 22 | ||
22 | func GetItemByKeyword(keyword string) ([]model.Item, error) { | 23 | func GetItemByKeyword(keyword string) ([]model.Item, error) { |
... | @@ -81,7 +82,9 @@ func getItemsInfoByKeyword(keyword string) ([]model.ApiResponseItem, error) { | ... | @@ -81,7 +82,9 @@ func getItemsInfoByKeyword(keyword string) ([]model.ApiResponseItem, error) { |
81 | } | 82 | } |
82 | 83 | ||
83 | func crawlingNaverCafe(cafeUrl string) (*model.Item, error) { | 84 | func crawlingNaverCafe(cafeUrl string) (*model.Item, error) { |
84 | - frame := rod.New().MustConnect().MustPage(cafeUrl).MustElement("iframe#cafe_main") | 85 | + path, _ := launcher.LookPath() |
86 | + u := launcher.New().Bin(path).MustLaunch() | ||
87 | + frame := rod.New().ControlURL(u).MustConnect().MustPage(cafeUrl).MustElement("iframe#cafe_main") | ||
85 | time.Sleep(time.Second * 2) | 88 | time.Sleep(time.Second * 2) |
86 | source := frame.MustFrame().MustHTML() | 89 | source := frame.MustFrame().MustHTML() |
87 | html, err := goquery.NewDocumentFromReader(bytes.NewReader([]byte(source))) | 90 | html, err := goquery.NewDocumentFromReader(bytes.NewReader([]byte(source))) | ... | ... |
joongna/undeploy.sh
100644 → 100755
File mode changed
-
Please register or login to post a comment