1+ # Copyright The Accelerated Container Image Authors
2+
3+ # Licensed under the Apache License, Version 2.0 (the "License");
4+ # you may not use this file except in compliance with the License.
5+ # You may obtain a copy of the License at
6+
7+ # http://www.apache.org/licenses/LICENSE-2.0
8+
9+ # Unless required by applicable law or agreed to in writing, software
10+ # distributed under the License is distributed on an "AS IS" BASIS,
11+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ # See the License for the specific language governing permissions and
13+ # limitations under the License.
14+
15+ # build overlaybd-snapshotter
16+ ARG GO_VERSION
17+ ARG GO_IMAGE=golang:${GO_VERSION}
18+ FROM --platform=${BUILDPLATFORM} ${GO_IMAGE} AS builder
19+ WORKDIR /src
20+ # Copy go.mod and go.sum first for better layer caching
21+ COPY go.mod go.sum ./
22+ ENV DEBIAN_FRONTEND=noninteractive
23+ RUN echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | tee /etc/apt/sources.list.d/goreleaser.list && \
24+ apt update && \
25+ apt install -y nfpm && \
26+ go mod download
27+ # Copy the rest of the source code
28+ COPY . .
29+
30+ ARG TARGETOS TARGETARCH
31+ ENV GOOS=${TARGETOS}
32+ ENV GOARCH=${TARGETARCH}
33+ ARG RELEASE_VERSION
34+ ENV SEMVER=${RELEASE_VERSION}
35+ ARG RELEASE_NUM
36+ ENV RELEASE=${RELEASE_NUM}
37+ ENV COMMIT_ID="${RELEASE_VERSION}_${RELEASE_NUM}"
38+ RUN make && \
39+ nfpm pkg --packager deb --target /tmp/ && \
40+ nfpm pkg --packager rpm --target /tmp/
41+
42+ # minimal image for deb extraction
43+ FROM ubuntu:24.04 AS deb-only
44+ WORKDIR /app
45+ COPY --from=builder /tmp/overlaybd-snapshotter_*.deb .
0 commit comments