Skip to content

Commit

Permalink
fix company
Browse files Browse the repository at this point in the history
  • Loading branch information
YukiOnishi1129 committed May 7, 2024
1 parent 7a553e8 commit bc6bb25
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
24 changes: 15 additions & 9 deletions batch-service/Dockerfile.article-company-crawler
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
FROM golang:1.22-alpine3.18
FROM golang:1.22-alpine3.18 AS go-builder

RUN apk update && apk add git

WORKDIR /app

COPY ./ ./
# COPY .env go.mod go.sum ./
# COPY ./database ./database
# COPY ./entity ./entity
# COPY ./domain ./domain
COPY go.mod go.sum ./
COPY ./cmd/article-company-crawler ./cmd/article-company-crawler
COPY ./database/init_db.go ./database/init_db.go
COPY ./domain ./domain
COPY ./entity ./entity
COPY ./infrastructure/api ./infrastructure/api
COPY ./infrastructure/rss ./infrastructure/rss
COPY ./internal ./internal

RUN go mod download
RUN go mod download \
&& go build -o main /app/cmd/article-company-crawler/main.go

# Build
RUN go build -o main /app/cmd/article-company-crawler/main.go

FROM alpine:3.18
WORKDIR /app
COPY --from=go-builder /app/main .

CMD ["/app/main"]
14 changes: 9 additions & 5 deletions batch-service/cmd/article-company-crawler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,25 @@ package main
import (
"context"
"database/sql"
"log"
"os"

"github.com/YukiOnishi1129/techpicks/batch-service/cmd/article-company-crawler/usecase"
"github.com/YukiOnishi1129/techpicks/batch-service/database"
"github.com/YukiOnishi1129/techpicks/batch-service/infrastructure/rss/client"
"github.com/YukiOnishi1129/techpicks/batch-service/infrastructure/rss/repository"
"github.com/joho/godotenv"
"log"
)

func main() {
log.Printf("Start batch service")
ctx := context.Background()
err := godotenv.Load(".env")
if err != nil {
log.Fatalf("Error loading .env file")
return
if os.Getenv("GO_ENV") != "production" && os.Getenv("GO_ENV") != "staging"{
err := godotenv.Load()
if err != nil {
log.Fatalf("Error loading .env file")
return
}
}

db, err := database.Init()
Expand Down

0 comments on commit bc6bb25

Please sign in to comment.