윤준석

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
FROM golang:1.17.3
FROM golang:1.17.3-alpine AS builder
WORKDIR /src
COPY . /src
RUN apt-get update
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
RUN go build -o Joongna_api_server
RUN go build -o joongna_api_server
FROM alpine
WORKDIR /src
COPY --from=builder /src/joongna_api_server /src/joongna_api_server
COPY --from=builder /src/config/.env /src/config/.env
RUN apk add chromium
EXPOSE 8080
CMD ["./Joongna_api_server"]
\ No newline at end of file
CMD ["./joongna_api_server"]
......
File mode changed
......@@ -17,6 +17,7 @@ import (
"github.com/PuerkitoBio/goquery"
"github.com/go-rod/rod"
"github.com/go-rod/rod/lib/launcher"
)
func GetItemByKeyword(keyword string) ([]model.Item, error) {
......@@ -81,7 +82,9 @@ func getItemsInfoByKeyword(keyword string) ([]model.ApiResponseItem, error) {
}
func crawlingNaverCafe(cafeUrl string) (*model.Item, error) {
frame := rod.New().MustConnect().MustPage(cafeUrl).MustElement("iframe#cafe_main")
path, _ := launcher.LookPath()
u := launcher.New().Bin(path).MustLaunch()
frame := rod.New().ControlURL(u).MustConnect().MustPage(cafeUrl).MustElement("iframe#cafe_main")
time.Sleep(time.Second * 2)
source := frame.MustFrame().MustHTML()
html, err := goquery.NewDocumentFromReader(bytes.NewReader([]byte(source)))
......
File mode changed