mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-09-25 19:07:39 +00:00
Merge pull request #2413 from justincormack/runtime-config
Add a runtime config
This commit is contained in:
@@ -20,9 +20,6 @@ RUN git checkout $CONTAINERD_COMMIT
|
||||
RUN make binaries EXTRA_FLAGS="-buildmode pie" EXTRA_LDFLAGS="-extldflags \\\"-fno-PIC -static\\\""
|
||||
RUN cp bin/containerd bin/ctr bin/containerd-shim /usr/bin/
|
||||
|
||||
ADD cmd /go/src/cmd
|
||||
RUN cd /go/src/cmd/service && ./skanky-vendor.sh $GOPATH/src/github.com/containerd/containerd
|
||||
RUN go-compile.sh /go/src/cmd/service
|
||||
RUN mkdir -p /etc/init.d && ln -s /usr/bin/service /etc/init.d/020-containerd
|
||||
|
||||
WORKDIR /
|
||||
@@ -31,7 +28,7 @@ COPY . .
|
||||
FROM scratch
|
||||
ENTRYPOINT []
|
||||
WORKDIR /
|
||||
COPY --from=alpine /usr/bin/containerd /usr/bin/ctr /usr/bin/containerd-shim /go/bin/service /usr/bin/
|
||||
COPY --from=alpine /usr/bin/containerd /usr/bin/ctr /usr/bin/containerd-shim /usr/bin/
|
||||
COPY --from=alpine /etc/containerd/config.toml /etc/containerd/
|
||||
COPY --from=alpine /usr/share/zoneinfo/UTC /etc/localtime
|
||||
COPY --from=alpine /etc/init.d/ /etc/init.d/
|
||||
|
@@ -1,87 +0,0 @@
|
||||
package main
|
||||
|
||||
// Please note this file is shared between pkg/runc and pkg/containerd
|
||||
// Update it in both places if you make changes
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func prepare(path string) error {
|
||||
// see if we are dealing with a read only or read write container
|
||||
if _, err := os.Stat(filepath.Join(path, "lower")); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return prepareRO(path)
|
||||
}
|
||||
return err
|
||||
}
|
||||
return prepareRW(path)
|
||||
}
|
||||
|
||||
func prepareRO(path string) error {
|
||||
// make rootfs a mount point, as runc doesn't like it much otherwise
|
||||
rootfs := filepath.Join(path, "rootfs")
|
||||
if err := syscall.Mount(rootfs, rootfs, "", syscall.MS_BIND, ""); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func prepareRW(path string) error {
|
||||
// mount a tmpfs on tmp for upper and workdirs
|
||||
// make it private as nothing else should be using this
|
||||
tmp := filepath.Join(path, "tmp")
|
||||
if err := syscall.Mount("tmpfs", tmp, "tmpfs", 0, "size=10%"); err != nil {
|
||||
return err
|
||||
}
|
||||
// make it private as nothing else should be using this
|
||||
if err := syscall.Mount("", tmp, "", syscall.MS_REMOUNT|syscall.MS_PRIVATE, ""); err != nil {
|
||||
return err
|
||||
}
|
||||
upper := filepath.Join(tmp, "upper")
|
||||
// make the mount points
|
||||
if err := os.Mkdir(upper, 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
work := filepath.Join(tmp, "work")
|
||||
if err := os.Mkdir(work, 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
lower := filepath.Join(path, "lower")
|
||||
rootfs := filepath.Join(path, "rootfs")
|
||||
opt := fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s", lower, upper, work)
|
||||
if err := syscall.Mount("overlay", rootfs, "overlay", 0, opt); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// cleanup functions are best efforts only, mainly for rw onboot containers
|
||||
func cleanup(path string) {
|
||||
// see if we are dealing with a read only or read write container
|
||||
if _, err := os.Stat(filepath.Join(path, "lower")); err != nil {
|
||||
cleanupRO(path)
|
||||
} else {
|
||||
cleanupRW(path)
|
||||
}
|
||||
}
|
||||
|
||||
func cleanupRO(path string) {
|
||||
// remove the bind mount
|
||||
rootfs := filepath.Join(path, "rootfs")
|
||||
_ = syscall.Unmount(rootfs, 0)
|
||||
}
|
||||
|
||||
func cleanupRW(path string) {
|
||||
// remove the overlay mount
|
||||
rootfs := filepath.Join(path, "rootfs")
|
||||
_ = os.RemoveAll(rootfs)
|
||||
_ = syscall.Unmount(rootfs, 0)
|
||||
// remove the tmpfs
|
||||
tmp := filepath.Join(path, "tmp")
|
||||
_ = os.RemoveAll(tmp)
|
||||
_ = syscall.Unmount(tmp, 0)
|
||||
}
|
@@ -1,17 +1,28 @@
|
||||
FROM linuxkit/alpine:87a0cd10449d72f374f950004467737dbf440630 AS build
|
||||
RUN apk add --no-cache --initdb alpine-baselayout make gcc musl-dev
|
||||
FROM linuxkit/alpine:0fd732eb9e99c4db0953ae8de23d95de340ab847 AS build
|
||||
RUN apk add --no-cache --initdb alpine-baselayout make gcc musl-dev git linux-headers
|
||||
|
||||
ADD usermode-helper.c .
|
||||
RUN make usermode-helper
|
||||
ADD usermode-helper.c ./
|
||||
RUN LDFLAGS=-static CFLAGS=-Werror make usermode-helper
|
||||
|
||||
RUN apk add --no-cache go musl-dev
|
||||
ENV GOPATH=/go PATH=$PATH:/go/bin
|
||||
|
||||
COPY init.go /go/src/init/
|
||||
COPY vendor /go/src/init/vendor/
|
||||
RUN go-compile.sh /go/src/init/
|
||||
COPY cmd /go/src/cmd
|
||||
RUN go-compile.sh /go/src/cmd/init
|
||||
|
||||
FROM linuxkit/alpine:87a0cd10449d72f374f950004467737dbf440630 AS mirror
|
||||
# checkout containerd for vendoring
|
||||
ENV GOPATH=/go PATH=$PATH:/go/bin
|
||||
# CONTAINERD_REPO and CONTAINERD_COMMIT are defined in linuxkit/alpine
|
||||
RUN mkdir -p $GOPATH/src/github.com/containerd && \
|
||||
cd $GOPATH/src/github.com/containerd && \
|
||||
git clone $CONTAINERD_REPO
|
||||
WORKDIR $GOPATH/src/github.com/containerd/containerd
|
||||
RUN git checkout $CONTAINERD_COMMIT
|
||||
|
||||
RUN cd /go/src/cmd/service && ./skanky-vendor.sh $GOPATH/src/github.com/containerd/containerd
|
||||
RUN go-compile.sh /go/src/cmd/service
|
||||
|
||||
FROM linuxkit/alpine:6ed3b299f5243acb6459b4993549c5045e4ad7f4 AS mirror
|
||||
RUN mkdir -p /out/etc/apk && cp -r /etc/apk/* /out/etc/apk/
|
||||
RUN apk add --no-cache --initdb -p /out alpine-baselayout busybox musl
|
||||
|
||||
@@ -23,6 +34,7 @@ ENTRYPOINT []
|
||||
CMD []
|
||||
WORKDIR /
|
||||
COPY --from=build /go/bin/init /
|
||||
COPY --from=build /go/bin/service /usr/bin/
|
||||
COPY --from=build usermode-helper /sbin/
|
||||
COPY --from=mirror /out/ /
|
||||
COPY etc etc/
|
||||
|
@@ -1,4 +1,5 @@
|
||||
IMAGE=init
|
||||
DEPS=init.go vendor.conf usermode-helper.c $(wildcard etc/*) $(wildcard etc/init.d/*)
|
||||
NETWORK=1
|
||||
DEPS=usermode-helper.c $(wildcard etc/*) $(wildcard etc/init.d/*) $(shell find cmd -type f)
|
||||
|
||||
include ../package.mk
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user