Skip to content

Commit c098211

Browse files
austinvazquezsondavidb
authored andcommitted
Change containerd-snapshotter-base to alpine based
This was done to use a smaller base image which makes us less prone to security issues. Additionally, this commit switches to using raw image URLs instead of inserting in the version via a variable, so that dependabot can track new versions. The Dockerfile line that pulls the registry was moved up to allow proper tagging when building locally instead of with Docker Compose. Signed-off-by: Austin Vazquez <[email protected]>
1 parent 3a5819f commit c098211

File tree

5 files changed

+21
-18
lines changed

5 files changed

+21
-18
lines changed

Dockerfile

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,27 @@
1515
ARG CONTAINERD_VERSION=1.6.30
1616
ARG RUNC_VERSION=1.1.12
1717
ARG NERDCTL_VERSION=1.7.1
18-
ARG GO_VERSION=1.21.10
19-
ARG REGISTRY_VERSION=3.0.0-alpha.1
2018

21-
FROM public.ecr.aws/docker/library/golang:${GO_VERSION}-bookworm AS golang-base
19+
FROM public.ecr.aws/docker/library/registry:3.0.0-alpha.1 AS registry
20+
21+
FROM public.ecr.aws/docker/library/golang:1.21.9-alpine AS containerd-snapshotter-base
2222

23-
FROM golang-base AS containerd-snapshotter-base
2423
ARG CONTAINERD_VERSION
2524
ARG RUNC_VERSION
2625
ARG NERDCTL_VERSION
27-
ARG GO_VERSION
2826
ARG TARGETARCH
2927
COPY ./integ_entrypoint.sh /integ_entrypoint.sh
3028
COPY . $GOPATH/src/github.com/awslabs/soci-snapshotter
3129
ENV GOPROXY direct
32-
RUN apt-get update -y && apt-get install -y libbtrfs-dev libseccomp-dev libz-dev gcc fuse pigz
30+
RUN apk add --no-cache \
31+
btrfs-progs-libs \
32+
curl \
33+
fuse \
34+
gcc \
35+
libc6-compat \
36+
libseccomp-dev \
37+
pigz \
38+
zlib-dev
3339
RUN cp $GOPATH/src/github.com/awslabs/soci-snapshotter/out/soci /usr/local/bin/ && \
3440
cp $GOPATH/src/github.com/awslabs/soci-snapshotter/out/soci-snapshotter-grpc /usr/local/bin/ && \
3541
mkdir /etc/soci-snapshotter-grpc && \
@@ -46,5 +52,3 @@ RUN curl -sSL --output /tmp/runc https://github.com/opencontainers/runc/releases
4652
RUN curl -sSL --output /tmp/nerdctl.tgz https://github.com/containerd/nerdctl/releases/download/v${NERDCTL_VERSION}/nerdctl-${NERDCTL_VERSION}-linux-${TARGETARCH:-amd64}.tar.gz && \
4753
tar zxvf /tmp/nerdctl.tgz -C /usr/local/bin/ && \
4854
rm -f /tmp/nerdctl.tgz
49-
50-
FROM public.ecr.aws/docker/library/registry:${REGISTRY_VERSION} AS registry

integ_entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/sh
22
#
33
# Copyright The Soci Snapshotter Authors.
44

integration/pull_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ insecure = true
739739
t.Fatalf("failed to write %v: %v", caCertDir, err)
740740
}
741741
sh.
742-
X("apt-get", "--no-install-recommends", "install", "-y", "iptables").
742+
X("apk", "add", "--no-cache", "iptables").
743743
X("update-ca-certificates").
744744
Retry(100, "nerdctl", "login", "-u", regConfig.user, "-p", regConfig.pass, regConfig.host)
745745

integration/run_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ disable = true
297297
rebootContainerd(t, sh, getContainerdConfigToml(t, false), getSnapshotterConfigToml(t, false, config))
298298
// Re-pull image from our local registry mirror
299299
sh.X(append(imagePullCmd, "--soci-index-digest", indexDigest, regConfig.mirror(containerImage).ref)...)
300-
sh.X("apt-get", "-qq", "--no-install-recommends", "install", "-y", "iptables")
300+
sh.X("apk", "add", "--no-cache", "--quiet", "iptables")
301+
301302
// Block network access to the registry
302303
if tt.config.networkDisableMsec > 0 {
303304
sh.X("iptables", "-A", "OUTPUT", "-d", registryHostIP, "-j", "DROP")
@@ -392,7 +393,7 @@ func TestRootFolderPermission(t *testing.T) {
392393
func TestRestartAfterSigint(t *testing.T) {
393394
const containerImage = alpineImage
394395
const killTimeout = 5
395-
const startTimeout = "5s"
396+
const startTimeout = "5"
396397

397398
regConfig := newRegistryConfig()
398399
sh, done := newShellWithRegistry(t, regConfig)
@@ -402,7 +403,7 @@ func TestRestartAfterSigint(t *testing.T) {
402403
copyImage(sh, dockerhub(containerImage), regConfig.mirror(containerImage))
403404
indexDigest := buildIndex(sh, regConfig.mirror(containerImage), withMinLayerSize(0), withSpanSize(100*1024))
404405
sh.X(append(imagePullCmd, "--soci-index-digest", indexDigest, regConfig.mirror(containerImage).ref)...)
405-
sh.X("pkill", "-SIGINT", "soci-snapshotte") // pkill can only take up to 15 chars
406+
testutil.KillMatchingProcess(sh, "soci-snapshotter-grpc")
406407

407408
var buffer []byte
408409
timedOut := true
@@ -419,16 +420,14 @@ func TestRestartAfterSigint(t *testing.T) {
419420
t.Fatalf("failed to kill snapshotter daemon")
420421
}
421422

422-
timeoutCmd := []string{"timeout", "--preserve-status", startTimeout}
423+
timeoutCmd := []string{"timeout", "-s", "SIGKILL", startTimeout}
423424
cmd := shell.C("/usr/local/bin/soci-snapshotter-grpc", "--log-level", sociLogLevel,
424425
"--address", "/run/soci-snapshotter-grpc/soci-snapshotter-grpc.sock")
425426
cmd = addConfig(t, sh, getSnapshotterConfigToml(t, false, tcpMetricsConfig), cmd...)
426427
cmd = append(timeoutCmd, cmd...)
427428

428-
// exit status 0 — command timed out, so server is running — PASS
429-
// exit status 1 — server crashed before time limit — FAIL
430429
if _, err := sh.OLog(cmd...); err != nil {
431-
if err.Error() != "exit status 0" {
430+
if err.Error() != "exit status 137" { // Killed by SIGKILL
432431
t.Fatalf("error starting snapshotter daemon: %v", err)
433432
}
434433
}

util/testutil/shell.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ func KillMatchingProcess(sh *shell.Shell, psLinePattern string) error {
357357
if len(es) < 2 {
358358
continue
359359
}
360-
pid, err := strconv.ParseInt(es[1], 10, 32)
360+
pid, err := strconv.ParseInt(es[0], 10, 32)
361361
if err != nil {
362362
continue
363363
}

0 commit comments

Comments
 (0)