new approach
Some checks failed
${{ github.actor }} executed Build Push Prod / build (push) Successful in 18m27s
${{ github.actor }} executed Build Push Prod / deploy (push) Failing after 16s

This commit is contained in:
maximo tejeda 2024-12-04 11:26:57 -04:00
parent fc7d5c71d6
commit 14e54b060d

View File

@ -1,16 +1,31 @@
# Stage 1: Modules caching
FROM golang:latest as modules
COPY go.mod go.sum /modules/
WORKDIR /modules
RUN go mod download
FROM golang:latest AS builder FROM golang:latest AS builder
ARG TARGETARCH ARG TARGETARCH
ARG version=not-set ARG version=not-set
ARG SHORTSHA=not-set ARG SHORTSHA=not-set
COPY --from=modules /go/pkg /go/pkg
RUN apt update && apt install git RUN apt update && apt install git
WORKDIR /app WORKDIR /app
COPY . . COPY . .
RUN go mod tidy
RUN go run github.com/playwright-community/playwright-go/cmd/playwright@latest install --with-deps # Install playwright cli with right version for later use
RUN PWGO_VER=$(grep -oE "playwright-go v\S+" /app/go.mod | sed 's/playwright-go //g') \
&& go install github.com/playwright-community/playwright-go/cmd/playwright@${PWGO_VER}
# https://stackoverflow.com/questions/70369368/check-architecture-in-dockerfile-to-get-amd-arm # https://stackoverflow.com/questions/70369368/check-architecture-in-dockerfile-to-get-amd-arm
RUN go build -o bin/crawler \ RUN go build -o bin/crawler \
-ldflags "-X main.Shortsha=${SHORTSHA} \ -ldflags "-X main.Shortsha=${SHORTSHA} \
-X main.Version=${version} \ -X main.Version=${version} \
-X main.Aarch=${TARGETARCH}" ./cmd/crawler/main.go -X main.Aarch=${TARGETARCH}" ./cmd/crawler/main.go
ENTRYPOINT /app/bin/crawler
FROM ubuntu:noble
COPY --from=builder /go/bin/playwright /app/bin/crawler /
RUN apt-get update && apt-get install -y ca-certificates tzdata \
# Install dependencies and all browsers (or specify one)
&& /playwright install --with-deps \
&& rm -rf /var/lib/apt/lists/*
CMD ["/crawler"]