| 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 |
ARG GO_VERSION |
| 16 |
ARG GO_IMAGE=golang:${GO_VERSION} |
| 17 |
FROM --platform=${BUILDPLATFORM} ${GO_IMAGE} AS builder |
| 18 |
WORKDIR /src/github.com/containerd/accelerated-container-image |
| 19 |
COPY . . |
| 20 |
ENV DEBIAN_FRONTEND=noninteractive |
| 21 |
RUN echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | tee /etc/apt/sources.list.d/goreleaser.list && \ |
| 22 |
apt update && \ |
| 23 |
apt install -y nfpm && \ |
| 24 |
go mod tidy |
| 25 |
|
| 26 |
ARG TARGETOS TARGETARCH |
| 27 |
ENV GOOS=${TARGETOS} |
| 28 |
ENV GOARCH=${TARGETARCH} |
| 29 |
ARG RELEASE_VERSION |
| 30 |
ENV SEMVER=${RELEASE_VERSION} |
| 31 |
ARG RELEASE_NUM |
| 32 |
ENV RELEASE=${RELEASE_NUM} |
| 33 |
ENV COMMIT_ID="${RELEASE_VERSION}_${RELEASE_NUM}" |
| 34 |
RUN make && \ |
| 35 |
nfpm pkg --packager deb --target /tmp/ && \ |
| 36 |
nfpm pkg --packager rpm --target /tmp/ |
| 37 |
|
| 38 |
FROM scratch AS release |
| 39 |
COPY --from=builder /tmp/* / |