Debian Codegraph @

ci/build_image/Dockerfile

raw
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 . .
21 ENV DEBIAN_FRONTEND=noninteractive
22 RUN echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | tee /etc/apt/sources.list.d/goreleaser.list && \
23 apt update && \
24 apt install -y nfpm && \
25 go mod tidy
26
27 ARG TARGETOS TARGETARCH
28 ENV GOOS=${TARGETOS}
29 ENV GOARCH=${TARGETARCH}
30 ARG RELEASE_VERSION
31 ENV SEMVER=${RELEASE_VERSION}
32 ARG RELEASE_NUM
33 ENV RELEASE=${RELEASE_NUM}
34 ENV COMMIT_ID="${RELEASE_VERSION}_${RELEASE_NUM}"
35 RUN make && \
36 nfpm pkg --packager deb --target /tmp/ && \
37 nfpm pkg --packager rpm --target /tmp/
38
39 # build image
40 FROM ubuntu:22.04 AS release
41 ARG OBD_VERSION
42 ARG RELEASE_VERSION
43 SHELL ["/bin/bash", "-c"]
44 WORKDIR /app
45 COPY --from=builder /tmp/overlaybd-snapshotter_${RELEASE_VERSION}_amd64.deb .
46 COPY ./ci/build_image/start_services.sh .
47
48 RUN apt-get update && apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release software-properties-common && \
49 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg && \
50 echo \
51 "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
52 $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null && \
53 apt-get update && apt-get install -y docker-ce docker-ce-cli containerd.io && \
54 apt-get install -y libnl-3-200 libnl-genl-3-200 libcurl4-openssl-dev libaio-dev wget less kmod && \
55 apt-get clean && rm -rf /var/lib/apt/lists/* && \
56 wget https://github.com/containerd/overlaybd/releases/download/v${OBD_VERSION}/overlaybd-${OBD_VERSION}-20240717.b5b704b.ubuntu1.22.04.x86_64.deb && \
57 dpkg -i overlaybd-${OBD_VERSION}-20240717.b5b704b.ubuntu1.22.04.x86_64.deb && \
58 dpkg -i overlaybd-snapshotter_${RELEASE_VERSION}_amd64.deb && \
59 sed -i 's/"autoRemoveDev": false,/"autoRemoveDev": true,/g' /etc/overlaybd-snapshotter/config.json && \
60 cat /etc/overlaybd-snapshotter/config.json && \
61 mkdir -p /etc/containerd/ && \
62 echo -e '[proxy_plugins.overlaybd]\n\ttype = "snapshot"\n\taddress = "/run/overlaybd-snapshotter/overlaybd.sock"' | tee -a /etc/containerd/config.toml && \
63 cat /etc/containerd/config.toml && \
64 chmod +x /app/start_services.sh && \
65 cat /app/start_services.sh