Skip to content

Instantly share code, notes, and snippets.

@hyperized
Created December 17, 2019 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hyperized/e68ff49d001fe170e348a116368de59c to your computer and use it in GitHub Desktop.
Save hyperized/e68ff49d001fe170e348a116368de59c to your computer and use it in GitHub Desktop.
FROM linuxkit/alpine:6906a00130f0b0209db8cc50803b7423e0c3f245 as alpine
RUN apk add -U tzdata
RUN mkdir -p /etc/init.d
RUN ln -s /usr/bin/service /etc/init.d/020-containerd
FROM golang:1.13-alpine as builder
ENV containerd_version "v1.3.2"
ENV GOPATH=/go
ENV PATH=$PATH:/go/bin
# Requirements
RUN \
apk add \
bash \
git \
libseccomp-dev \
linux-headers \
build-base \
btrfs-progs-dev
RUN mkdir -p $GOPATH/src/github.com/containerd
WORKDIR cd $GOPATH/src/github.com/containerd
RUN git clone --depth=1 --branch=$containerd_version \
https://github.com/containerd/containerd.git $GOPATH/src/github.com/containerd/containerd
WORKDIR $GOPATH/src/github.com/containerd/containerd
RUN make EXTRA_FLAGS="-buildmode pie" \
EXTRA_LDFLAGS='-extldflags "-fno-PIC -static"' \
BUILDTAGS="netgo osusergo static_build"
RUN bin/containerd --version
RUN bin/ctr --version
RUN mkdir -p /usr/bin/containerd/
RUN cp bin/* /usr/bin/containerd/
RUN ls -lisah /usr/bin/containerd/
# CNI - Loosely based on: https://github.com/containerd/containerd/blob/master/script/setup/install-cni
ENV FASTBUILD=true
ENV CNI_DIR=/opt/cni
WORKDIR $GOPATH
RUN go get -d github.com/containernetworking/plugins/...
WORKDIR /go/src/github.com/containernetworking/plugins
RUN git checkout $(grep containernetworking/plugins ${GOPATH}/src/github.com/containerd/containerd/vendor.conf | awk '{print $2}')
RUN ./build.sh
RUN mkdir -p $CNI_DIR
RUN cp -r ./bin $CNI_DIR
FROM scratch
ENTRYPOINT []
WORKDIR /
COPY --from=alpine /usr/share/zoneinfo/UTC /etc/localtime
COPY --from=builder /usr/bin/containerd/ /usr/bin/
COPY --from=builder /opt/cni/ /opt/cni/
COPY --from=alpine /etc/init.d/ /etc/init.d/
COPY config.toml /etc/containerd/config.toml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment