-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
16 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,19 @@ | ||
FROM golang:1.19.3-bullseye AS builder | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y gcc-aarch64-linux-gnu gcc-x86-64-linux-gnu && \ | ||
ln -s /usr/bin/aarch64-linux-gnu-gcc /usr/bin/arm64-linux-gnu-gcc && \ | ||
ln -s /usr/bin/x86_64-linux-gnu-gcc /usr/bin/amd64-linux-gnu-gcc | ||
|
||
ARG TARGETARCH | ||
FROM golang:1.18 AS builder | ||
ARG APP_SHA | ||
ARG VERSION | ||
|
||
WORKDIR /go/src/github.com/formancehq/payments | ||
|
||
# get deps first so it's cached | ||
WORKDIR /src | ||
COPY . . | ||
|
||
RUN go mod vendor | ||
|
||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH \ | ||
CC=$TARGETARCH-linux-gnu-gcc \ | ||
go build -o bin/payments \ | ||
-ldflags="-X github.com/formancehq/payments/cmd.Version=${VERSION} \ | ||
-X github.com/formancehq/payments/cmd.BuildDate=$(date +%s) \ | ||
-X github.com/formancehq/payments/cmd.Commit=${APP_SHA}" ./ | ||
|
||
FROM scratch | ||
|
||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | ||
COPY --from=builder /go/src/github.com/formancehq/payments/bin/payments /usr/local/bin/payments | ||
|
||
EXPOSE 8080 | ||
|
||
ENTRYPOINT ["payments"] | ||
|
||
CMD ["server"] | ||
WORKDIR /src/components/payments | ||
RUN go mod download | ||
RUN GOOS=linux go build -o payments \ | ||
-ldflags="-X $(cat go.mod |head -1|cut -d \ -f2)/cmd.Version=${VERSION} \ | ||
-X $(cat go.mod |head -1|cut -d \ -f2)/cmd.BuildDate=$(date +%s) \ | ||
-X $(cat go.mod |head -1|cut -d \ -f2)/cmd.Commit=${APP_SHA}" ./ | ||
|
||
FROM ubuntu:jammy | ||
RUN apt update && apt install -y ca-certificates curl && rm -rf /var/lib/apt/lists/* | ||
COPY --from=builder /src/components/payments/payments /payments | ||
EXPOSE 3068 | ||
ENV OTEL_SERVICE_NAME payments | ||
ENTRYPOINT ["/payments"] | ||
CMD ["serve"] |