ci: fix Docker CGO build

This commit is contained in:
Mohamed Sohail 2023-01-06 11:45:33 +00:00
parent d9866196f9
commit 06d2677071
Signed by: kamikazechaser
GPG Key ID: 7DD45520C01CD85D

View File

@ -1,15 +1,25 @@
FROM debian:11-slim FROM golang:1.19-bullseye as build
RUN set -x && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ WORKDIR /build
ca-certificates && \ COPY . .
rm -rf /var/lib/apt/lists/* RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o cic-chain-events -ldflags="-s -w" cmd/*.go
WORKDIR /cic-chain-events FROM debian:bullseye-slim
COPY cic-chain-events . ENV DEBIAN_FRONTEND=noninteractive
RUN set -x && \
apt-get update && \
apt-get install -y ca-certificates && \
rm -rf /var/cache/apt/archives /var/lib/apt/lists/*
WORKDIR /service
COPY --from=build /build/cic-chain-events .
COPY config.toml . COPY config.toml .
COPY queries.sql . COPY queries.sql .
COPY LICENSE . COPY LICENSE .
COPY migrations migrations/ COPY migrations migrations/
CMD ["./cic-chain-events"] CMD ["./cic-chain-events"]
EXPOSE 8080