Skip to content

Commit

Permalink
Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
metachris committed Jun 24, 2024
1 parent 954e54b commit c4a1b8f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# syntax=docker/dockerfile:1
FROM golang:1.20 as builder
FROM golang:1.22 AS builder
ARG VERSION
WORKDIR /build
ADD . /build/
RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags "-s -X main.version=${VERSION}" -v -o your-project main.go
ENV GOCACHE=/root/.cache/go-build
RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags "-s -X main.version=${VERSION}" -v -o ./bin/collect cmd/collect/*
RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags "-s -X main.version=${VERSION}" -v -o ./bin/merge cmd/merge/*
RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags "-s -X main.version=${VERSION}" -v -o ./bin/analyze cmd/analyze/*

FROM alpine:latest
WORKDIR /app
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /build/your-project /app/your-project
ENV LISTEN_ADDR=":8080"
EXPOSE 8080
CMD ["/app/your-project"]
COPY --from=builder /build/bin/* /app/
CMD ["/app/collect"]

0 comments on commit c4a1b8f

Please sign in to comment.